CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:jubidubi
Submission time:2019-10-01 10:08:37 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.02 sdetails
#6ACCEPTED0.02 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
set<int> w[101];
set<int> h[101];
int main() {
int n;
cin >> n;
for (int j = 1; j < 101; ++j) {
for (int i = 1; i <= n*2; ++i) {
w[j].insert(i);
h[j].insert(i);
}
}
int z = -1;
for (int y = 1; y <= n; ++y) {
for (int x = 1; x <= n; ++x) {
auto itw = w[y].begin();
auto ith = h[x].begin();
while (true) {
if (itw == w[y].end() || ith == h[x].end()) {
cout << "QAQ\n";
return 0;
}
/**
cout << '\n';
cout << x << " " << y << '\n';
cout << *itw << " " << *ith << '\n';
cout << "cw: " << w[y].count(*ith) << ", ch: " << h[x].count(*itw) << '\n';
*/
if (*itw >= *ith) {
z = *itw;
if (h[x].count(z) == 1) {
h[x].erase(h[x].find(z));
w[y].erase(w[y].find(z));
break;
} else ++ith;
} else {
z = *ith;
if (w[y].count(z) == 1) {
w[y].erase(w[y].find(z));
h[x].erase(h[x].find(z));
break;
} else ++itw;
}
}
//cout << '\n';
cout << z << " ";
}
cout << '\n';
}
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output

Test 2

Verdict: ACCEPTED

input
2

correct output
1 2 
2 1 

user output
1 2 
2 1 

Test 3

Verdict: ACCEPTED

input
5

correct output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

user output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

Test 4

Verdict: ACCEPTED

input
42

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated

Test 5

Verdict: ACCEPTED

input
99

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated

Test 6

Verdict: ACCEPTED

input
100

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated