Task: | Grid |
Sender: | eduardische |
Submission time: | 2017-01-20 00:45:02 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 35 |
#2 | ACCEPTED | 21 |
#3 | ACCEPTED | 44 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1 | details |
#2 | ACCEPTED | 0.04 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.04 s | 1 | details |
#5 | ACCEPTED | 0.04 s | 1 | details |
#6 | ACCEPTED | 0.04 s | 1 | details |
#7 | ACCEPTED | 0.03 s | 1 | details |
#8 | ACCEPTED | 0.04 s | 1 | details |
#9 | ACCEPTED | 0.05 s | 1 | details |
#10 | ACCEPTED | 0.03 s | 2 | details |
#11 | ACCEPTED | 0.04 s | 2 | details |
#12 | ACCEPTED | 0.04 s | 2 | details |
#13 | ACCEPTED | 0.04 s | 2 | details |
#14 | ACCEPTED | 0.05 s | 2 | details |
#15 | ACCEPTED | 0.04 s | 2 | details |
#16 | ACCEPTED | 0.04 s | 3 | details |
#17 | ACCEPTED | 0.04 s | 3 | details |
#18 | ACCEPTED | 0.05 s | 3 | details |
#19 | ACCEPTED | 0.06 s | 3 | details |
#20 | ACCEPTED | 0.15 s | 3 | details |
#21 | ACCEPTED | 0.16 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:8:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&N); ^
Code
#include <bits/stdc++.h>#define MAXN 1005using namespace std;int main () {int N;scanf("%d",&N);if (N < 4) {printf("QAQ\n");return 0;}if (N == 4) {printf("3 2 4 3\n");printf("1 2 2 1\n");printf("1 3 3 1\n");printf("4 4 4 2\n");return 0;}static int a[MAXN][MAXN];static int h[MAXN];static int v[MAXN];a[0][0] = 1; a[0][1] = 1; a[0][2] = 2; a[0][3] = 4; a[0][4] = 3; v[0] = 11;a[1][0] = 2; a[1][1] = 5; a[1][2] = 2; a[1][3] = 2; a[1][4] = 3; v[1] = 14;a[2][0] = 3; a[2][1] = 1; a[2][2] = 4; a[2][3] = 3; a[2][4] = 4; v[2] = 15;a[3][0] = 1; a[3][1] = 2; a[3][2] = 4; a[3][3] = 4; a[3][4] = 5; v[3] = 16;a[4][0] = 1; a[4][1] = 3; a[4][2] = 5; a[4][3] = 5; a[4][4] = 5; v[4] = 19;h[0] = 8; h[1] = 12; h[2] = 17; h[3] = 18; h[4] = 20;int n = 5;while (n < N) {int hp = 0;int vp = 0;int cur = 1;while ((hp < n) || (vp < n)) {if ((hp < n) && (vp < n)) {if (h[hp] < v[vp]) {a[n][hp] = cur;hp++;} else if (h[hp] > v[vp]) {a[vp][n] = cur;vp++;}} else if (hp < n) {a[n][hp] = cur;hp++;} else {a[vp][n] = cur;vp++;}cur++;if (cur > n+1) cur--;}a[n][n] = cur;h[n] = cur;v[n] = cur;for (int i = 0; i < n; i++) {h[i] += a[n][i];v[n] += a[n][i];v[i] += a[i][n];h[n] += a[i][n];}if (h[n] == v[n]) {int temp = a[n][0]; a[n][0] = a[0][n]; a[0][n] = temp;for (int i = 0; i < n; i++) {h[i] -= a[n][i];v[i] -= a[i][n];}h[n] = cur;v[n] = cur;for (int i = 0; i < n; i++) {h[i] += a[n][i];v[n] += a[n][i];v[i] += a[i][n];h[n] += a[i][n];}}n++;}for (int i = 0; i < N; i++) {for (int j = 0; j < N; j++) {if (j) printf(" ");printf("%d",a[i][j]);}printf("\n");}return 0;}
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: ACCEPTED
input |
---|
4 |
correct output |
---|
3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
user output |
---|
3 2 4 3 1 2 2 1 1 3 3 1 4 4 4 2 |
Test 4
Group: 1
Verdict: ACCEPTED
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 |
---|
1 1 2 4 3 2 5 2 2 3 3 1 4 3 4 1 2 4 4 5 1 3 5 5 5 |
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 |
---|
1 1 2 4 3 2 2 5 2 2 3 4 3 1 4 3 4 5 1 2 4 4 5 6 1 3 5 5 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 |
---|
1 1 2 4 3 2 2 2 5 2 2 3 4 4 3 1 4 3 4 5 5 1 2 4 4 5 6 6 1 3 5 5 5 6 7 ... |
Test 7
Group: 1
Verdict: ACCEPTED
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 |
---|
1 1 2 4 3 2 2 2 2 5 2 2 3 4 4 4 3 1 4 3 4 5 5 5 1 2 4 4 5 6 6 6 1 3 5 5 5 6 7 8 ... |
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 |
---|
1 1 2 4 3 2 2 2 2 2 5 2 2 3 4 4 4 4 3 1 4 3 4 5 5 5 5 1 2 4 4 5 6 6 6 6 1 3 5 5 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 |
---|
1 1 2 4 3 2 2 2 2 2 2 5 2 2 3 4 4 4 4 4 3 1 4 3 4 5 5 5 5 5 1 2 4 4 5 6 6 6 6 6 1 3 5 5 5 6 7 8 9 9 ... |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 11
Group: 2
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
user output |
---|
3 2 4 3 1 2 2 1 1 3 3 1 4 4 4 2 |
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 |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
Test 13
Group: 2
Verdict: ACCEPTED
input |
---|
48 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
Test 14
Group: 2
Verdict: ACCEPTED
input |
---|
80 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
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 |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
Test 16
Group: 3
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
QAQ |
user output |
---|
QAQ |
Test 17
Group: 3
Verdict: ACCEPTED
input |
---|
4 |
correct output |
---|
3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
user output |
---|
3 2 4 3 1 2 2 1 1 3 3 1 4 4 4 2 |
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 |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
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 |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
Test 20
Group: 3
Verdict: ACCEPTED
input |
---|
844 |
correct output |
---|
2 3 4 5 6 7 8 9 10 11 12 13 14... |
user output |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |
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 |
---|
1 1 2 4 3 2 2 2 2 2 2 2 2 2 2 ... |