Task: | Ruudukko |
Sender: | siirikuoppala |
Submission time: | 2023-11-16 18:56:12 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 35 |
#2 | ACCEPTED | 21 |
#3 | ACCEPTED | 44 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1 | details |
#2 | ACCEPTED | 0.00 s | 1 | details |
#3 | ACCEPTED | 0.00 s | 1 | details |
#4 | ACCEPTED | 0.00 s | 1 | details |
#5 | ACCEPTED | 0.00 s | 1 | details |
#6 | ACCEPTED | 0.00 s | 1 | details |
#7 | ACCEPTED | 0.00 s | 1 | details |
#8 | ACCEPTED | 0.00 s | 1 | details |
#9 | ACCEPTED | 0.00 s | 1 | details |
#10 | ACCEPTED | 0.00 s | 2 | details |
#11 | ACCEPTED | 0.00 s | 2 | details |
#12 | ACCEPTED | 0.00 s | 2 | details |
#13 | ACCEPTED | 0.00 s | 2 | details |
#14 | ACCEPTED | 0.00 s | 2 | details |
#15 | ACCEPTED | 0.01 s | 2 | details |
#16 | ACCEPTED | 0.00 s | 3 | details |
#17 | ACCEPTED | 0.00 s | 3 | details |
#18 | ACCEPTED | 0.01 s | 3 | details |
#19 | ACCEPTED | 0.04 s | 3 | details |
#20 | ACCEPTED | 0.09 s | 3 | details |
#21 | ACCEPTED | 0.12 s | 3 | details |
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define N (1<<11) vector<int> v; ll t[N], S[N], hyhh[N]; ll res[N][N]; int brute(int n) { if(n<=3) { cout << "QAQ\n"; return 0; } for(int i=1; i<=n; ++i){ for(int j=0; j<n; ++j){ v.push_back(i); } } while(true){ random_shuffle(v.begin(), v.end()); for(int i=0; i<n; ++i){ int s=0; for(int j=0; j<n; ++j) s+=v[i*n+j]; ++S[s]; s=0; for(int j=0; j<n; ++j) s+=v[j*n+i]; ++S[s]; } int c=0; for(int i=0; i<N; ++i){ if(S[i]>1) c=S[i]; S[i]=0; } if(c>1) continue; for(int i=0; i<n; ++i){ for(int j=0; j<n; ++j) cout << v[i*n+j] << " "; cout << "\n"; } return 0; } } int main() { int n; cin >> n; if(n < 5) return brute(n); for(int i=0; i<n; ++i) res[0][i] = n; for(int i=1; i<n; ++i) res[i][0] = 1; for(int i=1; i<n; ++i) res[i][i] = i; for(int i=1; i<n; ++i){ int val = (n-1-i) % (n-2); for(int j=1; j<n; ++j){ if(i == j) continue; res[i][j] = val + 2; val = (val + 1) % (n-2); } } // n n n n n n n n n // 1 1 2 3 4 5 // 1 2 2 3 4 5 // 1 3 // .... for(int i=0; i<n; ++i){ for(int j=0; j<n; ++j){ cout << res[i][j] << " "; } cout << "\n"; } // for(int i=0; i<n; ++i) { // int s = 0; // for(int j=0; j<n; ++j) s += res[i][j]; // if(t[s]) cout << "QAQ\n"; // t[s] = 1; // for(int j=0; j<n; ++j) s += res[j][i]; // if(t[s]) cout << "QAQ\n" << s << "\n"; // t[s] = 1; // } 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 |
---|
1 1 3 2 2 1 2 4 3 3 3 4 2 1 4 4 |
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 |
---|
5 5 5 5 5 1 1 2 3 4 1 4 2 2 3 1 3 4 3 2 1 2 3 4 4 |
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 6 6 6 6 6 1 1 2 3 4 5 1 5 2 2 3 4 1 4 5 3 2 3 1 3 4 5 4 2 ... |
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 7 7 7 7 7 7 1 1 2 3 4 5 6 1 6 2 2 3 4 5 1 5 6 3 2 3 4 1 4 5 6 4 2 3 ... |
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 |
---|
8 8 8 8 8 8 8 8 1 1 2 3 4 5 6 7 1 7 2 2 3 4 5 6 1 6 7 3 2 3 4 5 1 5 6 7 4 2 3 4 ... |
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 9 9 9 9 9 9 9 9 1 1 2 3 4 5 6 7 8 1 8 2 2 3 4 5 6 7 1 7 8 3 2 3 4 5 6 1 6 7 8 4 2 3 4 5 ... |
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 10 10 10 10 10 10 10 10 10 1 1 2 3 4 5 6 7 8 9 1 9 2 2 3 4 5 6 7 8 1 8 9 3 2 3 4 5 6 7 1 7 8 9 4 2 3 4 5 6 ... |
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 |
---|
1 1 3 2 2 1 2 4 3 3 3 4 2 1 4 4 |
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 29 29 29 29 29 29 29 29 29 ... |
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 |
---|
48 48 48 48 48 48 48 48 48 48 ... |
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 |
---|
80 80 80 80 80 80 80 80 80 80 ... |
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 97 97 97 97 97 97 97 97 97 ... |
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 |
---|
1 1 3 2 2 1 2 4 3 3 3 4 2 1 4 4 |
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 111 111 111 111 111 111 11... |
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 506 506 506 506 506 506 50... |
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 |
---|
844 844 844 844 844 844 844 84... |
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 991 991 991 991 991 991 99... |