| Task: | Chair Game |
| Sender: | Akseli Järvinen |
| Submission time: | 2024-03-06 16:50:18 +0200 |
| Language: | C++ (C++11) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp:1:1: error: 'include' does not name a type
1 | include <bits/stdc++.h>
| ^~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:7:5: error: 'cin' was not declared in this scope
7 | cin.tie(0) -> sync_with_stdio(0);
| ^~~
input/code.cpp:13:9: error: 'vector' was not declared in this scope
13 | vector<int> a(n);
| ^~~~~~
input/code.cpp:2:13: error: expected primary-expression before 'long'
2 | #define int long long
| ^~~~
input/code.cpp:13:16: note: in expansion of macro 'int'
13 | vector<int> a(n);
| ^~~
input/code.cpp:14:23: error: 'a' was not declared in this scope
14 | for (int &i : a)
| ^
input/code.cpp:17:18: error: 'a' was not declared in this scope
17 | sort(all(a));
| ^
input/code.cpp:3:16: note: in definition of macro 'all'
3 | #define all(x) x.begin(), x.end()
|...Code
include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a)
cin >> i;
sort(all(a));
bool ok = 1;
set<int> st;
for (int i = 0; i < n; ++i) {
st.insert(a[i]);
if (a[i] != i+1) {
ok = 0;
}
}
if (st.size() == 2 && *st.begin() == 1 && *(++st.begin()) == 2) {
cout << "NO\n";
}
else if (ok) {
if (n & 1) {
cout << "YES\n";
for (int i : a)
cout << i << ' ';
cout << '\n';
}
else {
cout << "NO\n";
}
}
else {
vector<int> ans;
do {
vector<bool> filled(n,0);
for (int i = 0; i < n; ++i) {
filled[(i+a[i])%n] = 1;
}
bool ok = 1;
for (int i = 0; i < n; ++i) {
if (!filled[i])
ok = 0;
}
if (ok) {
ans = a;
break;
}
} while (next_permutation(a.begin(),a.end()));
if (!ans.size()) {
cout << "NO\n";
}
else {
cout << "YES\n";
for (int i : ans)
cout << i << ' ';
cout << '\n';
}
}
}
}