Task: | Ruudukko |
Sender: | jubidubi |
Submission time: | 2019-10-01 10:08:37 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.02 s | details |
#6 | ACCEPTED | 0.02 s | details |
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 |
---|
1 |
user output |
---|
1 |
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 |