QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#364142 | #8309. Mountain | ucup-team173# | WA | 0ms | 3552kb | C++20 | 1.9kb | 2024-03-24 12:22:58 | 2024-03-24 12:22:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define Mp make_pair
#define SZ(x) (int((x).size()))
typedef double db;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
void solve() {
ll n, d, c;
cin >> n >> d >> c;
if(d == 0) {
if(n == c) {
cout << "Yes\n";
for(int i = 1; i <= n; i++)
cout << '\n';
} else {
cout << "No\n";
}
return;
}
if(d == 1) {
if(n % 2 || c != n / 2) {
cout << "No\n";
} else {
cout << "Yes\n";
for(int i = 1; i <= n; i++) {
if(i % 2) cout << i + 1;
else cout << i - 1;
cout << '\n';
}
}
return;
}
if(c * (d + 1) > n || n * d % 2) {
cout << "No\n";
return;
}
ll lst = n - (c - 1) * (d + 1);
vector G(n, vi());
auto add = [&](int x, int y) {
G[x].pb(y), G[y].pb(x);
};
for(int t = lst; t < n; t += d + 1) {
for(int i = 0; i < d + 1; i++) {
for(int j = 1; j <= d; j++) {
G[i + t].pb((t + (i + j) % (d + 1)));
}
}
}
for(int t = 1; t <= d / 2; t++) {
for(int i = 0; i < lst; i++) {
add(i, (i + t) % lst);
}
}
if(d % 2) {
assert(lst % 2 == 0);
for(int i = 0; i < lst / 2; i++) {
add(i, i + lst / 2);
}
}
cout << "Yes\n";
for(int i = 0; i < n; i++) {
sort(G[i].begin(), G[i].end());
for(int j : G[i]) cout << j + 1 << ' ';
cout << '\n';
}
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int t = 1;
// cin >> t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
3 1 2 2 1 3
output:
No
result:
wrong output format Expected double, but "No" found