Task: | Grid |
Sender: | Wrinx |
Submission time: | 2017-01-21 22:16:35 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1 | details |
#2 | ACCEPTED | 0.04 s | 1 | details |
#3 | WRONG ANSWER | 0.03 s | 1 | details |
#4 | WRONG ANSWER | 0.06 s | 1 | details |
#5 | ACCEPTED | 0.04 s | 1 | details |
#6 | ACCEPTED | 0.04 s | 1 | details |
#7 | WRONG ANSWER | 0.04 s | 1 | details |
#8 | ACCEPTED | 0.05 s | 1 | details |
#9 | ACCEPTED | 0.05 s | 1 | details |
#10 | ACCEPTED | 0.04 s | 2 | details |
#11 | WRONG ANSWER | 0.04 s | 2 | details |
#12 | ACCEPTED | 0.04 s | 2 | details |
#13 | WRONG ANSWER | 0.04 s | 2 | details |
#14 | WRONG ANSWER | 0.03 s | 2 | details |
#15 | ACCEPTED | 0.03 s | 2 | details |
#16 | ACCEPTED | 0.04 s | 3 | details |
#17 | WRONG ANSWER | 0.04 s | 3 | details |
#18 | ACCEPTED | 0.04 s | 3 | details |
#19 | ACCEPTED | 0.07 s | 3 | details |
#20 | WRONG ANSWER | 0.71 s | 3 | details |
#21 | ACCEPTED | 0.11 s | 3 | details |
Compiler report
input/code.cpp: In function 'bool check()': input/code.cpp:24:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (s.size() == 2 * n) return true; ^
Code
#include<bits/stdc++.h> #define F first #define S second #define ll long long #define ull unsigned long long #define pb push_back using namespace std; int n, a[2000][2000], s1[2000], s2[2000]; bool check() { set < int > s; for (int i = 1; i <= n; i++){ s1[i] = 0; s2[i] = 0; } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++){ s1[i] += a[i][j]; s2[j] += a[i][j]; } for (int i = 1; i <= n; i++) s.insert(s1[i]); for (int j = 1; j <= n; j++) s.insert(s2[j]); if (s.size() == 2 * n) return true; return false; } void print(){ for (int i = 1; i <= n; i++, cout << endl) for (int j = 1; j <= n; j++){ s1[i] += a[i][j]; s2[j] += a[i][j]; cout << a[i][j] << " "; } exit(0); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; if (n <= 4){ cout << "QAQ" << endl; return 0; } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) a[i][j] = j; for (int i = 1; i <= n; i += 2){ if (i == n) continue; int p1 = i / 2 + 1; int p2 = n - i / 2 - (i == n); int k1 = i; int k2 = i + 1; if (k2 > n) k2 -= 2; swap(a[k1][p1], a[k2][p2]); } for (int i = 1; i <= n; i++){ swap(a[n][n / 2 + 1], a[n][i]); if (check()) print(); swap(a[n][n / 2 + 1], a[n][i]); } }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
2 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
4 |
correct output |
---|
3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
user output |
---|
QAQ |
Test 4
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 |
correct output |
---|
2 3 4 1 1 3 4 2 1 2 4 2 3 1 3 4 3 2 1 4 5 5 5 5 5 |
user output |
---|
(empty) |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
2 3 4 5 1 1 3 4 5 2 1 2 4 5 2 3 1 3 5 2 3 4 1 4 5 4 3 2 1 5 ... |
user output |
---|
6 2 3 4 5 6 1 2 3 4 5 1 1 5 3 4 5 6 1 2 3 4 2 6 1 2 4 4 5 6 ... |
Test 6
Group: 1
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
2 3 4 5 6 1 1 3 4 5 6 2 1 2 4 5 6 2 3 1 3 5 6 2 3 4 1 4 6 2 3 4 5 1 5 ... |
user output |
---|
7 2 3 4 5 6 7 1 2 3 4 5 6 1 1 6 3 4 5 6 7 1 2 3 4 5 2 7 1 2 5 4 5 6 7 ... |
Test 7
Group: 1
Verdict: WRONG ANSWER
input |
---|
8 |
correct output |
---|
2 3 4 5 6 7 1 1 3 4 5 6 7 2 1 2 4 5 6 7 2 3 1 3 5 6 7 2 3 4 1 4 6 7 2 3 4 5 1 5 ... |
user output |
---|
(empty) |
Test 8
Group: 1
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
2 3 4 5 6 7 8 1 1 3 4 5 6 7 8 2 1 2 4 5 6 7 8 2 3 1 3 5 6 7 8 2 3 4 1 4 6 7 8 2 3 4 5 1 5 ... |
user output |
---|
9 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 1 1 8 3 4 5 6 7 8 9 1 2 3 4 5 6 7 2 9 1 2 7 4 5 6 7 8 9 ... |
Test 9
Group: 1
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
2 3 4 5 6 7 8 9 1 1 3 4 5 6 7 8 9 2 1 2 4 5 6 7 8 9 2 3 1 3 5 6 7 8 9 2 3 4 1 4 6 7 8 9 2 3 4 5 1 5 ... |
user output |
---|
10 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 1 1 9 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 2 10 1 2 8 4 5 6 7 8 9 10 ... |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 11
Group: 2
Verdict: WRONG ANSWER
input |
---|
4 |
correct output |
---|
3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
user output |
---|
QAQ |
Test 12
Group: 2
Verdict: ACCEPTED
input |
---|
29 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
29 2 3 4 5 6 7 8 9 10 11 12 13... |
Test 13
Group: 2
Verdict: WRONG ANSWER
input |
---|
48 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
(empty) |
Test 14
Group: 2
Verdict: WRONG ANSWER
input |
---|
80 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
(empty) |
Test 15
Group: 2
Verdict: ACCEPTED
input |
---|
97 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
97 2 3 4 5 6 7 8 9 10 11 12 13... |
Test 16
Group: 3
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 17
Group: 3
Verdict: WRONG ANSWER
input |
---|
4 |
correct output |
---|
3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
user output |
---|
QAQ |
Test 18
Group: 3
Verdict: ACCEPTED
input |
---|
111 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
111 2 3 4 5 6 7 8 9 10 11 12 1... |
Test 19
Group: 3
Verdict: ACCEPTED
input |
---|
506 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
506 2 3 4 5 6 7 8 9 10 11 12 1... |
Test 20
Group: 3
Verdict: WRONG ANSWER
input |
---|
844 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
(empty) |
Test 21
Group: 3
Verdict: ACCEPTED
input |
---|
991 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
991 2 3 4 5 6 7 8 9 10 11 12 1... |