| Task: | Ruudukko |
| Sender: | JesseNiininen |
| Submission time: | 2017-01-19 15:57:29 +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 | WRONG ANSWER | 0.05 s | 1 | details |
| #2 | WRONG ANSWER | 0.04 s | 1 | details |
| #3 | WRONG ANSWER | 0.02 s | 1 | details |
| #4 | WRONG ANSWER | 0.03 s | 1 | details |
| #5 | WRONG ANSWER | 0.06 s | 1 | details |
| #6 | WRONG ANSWER | 0.12 s | 1 | details |
| #7 | TIME LIMIT EXCEEDED | -- | 1 | details |
| #8 | TIME LIMIT EXCEEDED | -- | 1 | details |
| #9 | TIME LIMIT EXCEEDED | -- | 1 | details |
| #10 | WRONG ANSWER | 0.04 s | 2 | details |
| #11 | WRONG ANSWER | 0.03 s | 2 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #14 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #15 | TIME LIMIT EXCEEDED | -- | 2 | details |
| #16 | WRONG ANSWER | 0.03 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
// g++ testi.cpp -o testi
// g++ -std=c++11 testi.cpp -o testi -O2
// g++ -std=c++11 ruudukko.cpp -o ruudukko -O2
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n;
vector<int> v;
bool check(){
unordered_set<ll> used;
for(int i = 0; i < n; i++){
ll s = 1;
for(int j = 0; j < n; j++){
s *= v[n * i + j];
}
if(used.find(s) != used.end())
return false;
used.insert(s);
}
for(int i = 0; i < n; i++){
ll s = 1;
for(int j = 0; j < n; j++){
s *= v[n * j + i];
}
if(used.find(s) != used.end())
return false;
used.insert(s);
}
return true;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
ll n2 = n * n;
v.resize(n2);
for(int i = 0; i < n2; i++)
v[i] = (i / n) + 1;
while(next_permutation(v.begin(), v.end())){
if(check()){
int lvl = 0;
for(int i = 0; i < n2; i++){
if(i / n > lvl){
cout << "\n";
lvl++;
}
cout << v[i];
}
return 0;
}
}
}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 2 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| (empty) |
Test 2
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 3 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| 111 223 233 |
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 |
|---|
| 1111 2223 2343 4344 |
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 |
|---|
| 11111 22222 33334 34454 54555 |
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 |
|---|
| 111111 222222 333333 444455 445656 ... |
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 |
|---|
| 1111111 2222222 3333333 4444444 5555566 ... |
Test 7
Group: 1
Verdict: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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 |
|---|
| (empty) |
Test 9
Group: 1
Verdict: TIME LIMIT EXCEEDED
| 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 |
|---|
| (empty) |
Test 10
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 3 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| 111 223 233 |
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 |
|---|
| 1111 2223 2343 4344 |
Test 12
Group: 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 29 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| (empty) |
Test 13
Group: 2
Verdict: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: 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: WRONG ANSWER
| input |
|---|
| 3 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| 111 223 233 |
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 |
|---|
| 1111 2223 2343 4344 |
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) |
