| Task: | Ruudukko |
| Sender: | Pohjantahti |
| Submission time: | 2017-06-22 19:42:39 +0300 |
| 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.03 s | 1 | details |
| #3 | WRONG ANSWER | 0.04 s | 1 | details |
| #4 | WRONG ANSWER | 0.05 s | 1 | details |
| #5 | WRONG ANSWER | 0.04 s | 1 | details |
| #6 | WRONG ANSWER | 0.04 s | 1 | details |
| #7 | WRONG ANSWER | 0.04 s | 1 | details |
| #8 | WRONG ANSWER | 0.04 s | 1 | details |
| #9 | WRONG ANSWER | 0.04 s | 1 | details |
| #10 | ACCEPTED | 0.05 s | 2 | details |
| #11 | WRONG ANSWER | 0.05 s | 2 | details |
| #12 | WRONG ANSWER | 0.04 s | 2 | details |
| #13 | WRONG ANSWER | 0.09 s | 2 | details |
| #14 | WRONG ANSWER | 0.52 s | 2 | details |
| #15 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #16 | ACCEPTED | 0.04 s | 3 | details |
| #17 | WRONG ANSWER | 0.04 s | 3 | details |
| #18 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #19 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #20 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #21 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int n;
int gind(int y, int x) {
return n*y+x;
}
bool ok(vector<int> v) {
set<int> s1, s2;
for (int i = 0; i < n; ++i) {
int csum = 0;
int osum = 0;
for (int j = 0; j < n; ++j) {
csum += v[gind(i, j)];
osum += v[gind(j, i)];
}
if (s1.find(csum) != s1.end()) return false;
s1.insert(csum);
if (s2.find(osum) != s2.end()) return false;
s2.insert(osum);
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
if (n <= 3) {
cout << "QAQ\n";
return 0;
}
vector<int> v;
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < n; ++j) {
v.push_back(i);
}
}
while (!ok(v)) {
random_shuffle(v.begin(), v.end());
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cout << v[gind(i, j)] << " ";
}
cout << "\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: WRONG ANSWER
| input |
|---|
| 4 |
| correct output |
|---|
| 3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
| user output |
|---|
| 3 2 1 4 1 4 1 2 2 4 2 1 3 3 3 4 |
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 |
|---|
| 2 3 2 5 5 2 1 1 4 3 3 2 1 5 1 1 4 3 3 4 4 4 2 5 5 |
Test 5
Group: 1
Verdict: WRONG ANSWER
| 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 |
|---|
| 4 3 4 1 2 3 2 2 4 6 6 6 2 2 4 3 2 1 5 3 6 5 6 3 3 1 6 4 1 5 ... |
Test 6
Group: 1
Verdict: WRONG ANSWER
| 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 6 6 2 5 2 3 7 6 4 4 2 5 7 5 4 3 2 4 1 5 4 2 1 1 6 4 3 6 7 3 4 3 7 3 ... |
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 |
|---|
| 2 1 8 5 4 3 4 1 1 5 1 1 5 3 7 6 7 8 1 4 8 8 4 6 2 5 6 1 7 1 7 6 5 2 2 2 2 8 4 5 ... |
Test 8
Group: 1
Verdict: WRONG ANSWER
| 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 |
|---|
| 8 6 3 1 4 4 2 3 1 5 3 5 6 8 1 9 7 5 9 5 5 9 1 9 7 8 6 4 9 6 1 3 8 1 7 5 6 8 2 4 9 4 2 8 8 ... |
Test 9
Group: 1
Verdict: WRONG ANSWER
| 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 |
|---|
| 3 4 1 5 8 8 9 7 2 2 3 2 5 5 3 8 6 3 3 8 3 7 5 10 4 4 10 6 9 9 6 4 10 8 9 7 1 9 8 2 2 10 4 10 4 10 9 8 5 3 ... |
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 |
|---|
| 3 2 1 4 1 4 1 2 2 4 2 1 3 3 3 4 |
Test 12
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 29 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 22 7 7 10 11 22 6 15 29 24 23 ... |
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 |
|---|
| 43 9 19 43 3 46 20 40 2 23 39 ... |
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 |
|---|
| 35 66 44 38 28 6 12 79 53 21 7... |
Test 15
Group: 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 97 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| (empty) |
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 |
|---|
| 3 2 1 4 1 4 1 2 2 4 2 1 3 3 3 4 |
Test 18
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 111 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| (empty) |
Test 19
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 506 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| (empty) |
Test 20
Group: 3
Verdict: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| input |
|---|
| 991 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| (empty) |
