QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#370337 | #4325. Kraljice | nvujica | 0 | 1ms | 3708kb | C++14 | 2.6kb | 2024-03-29 02:07:40 | 2024-03-29 02:07:42 |
answer
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
const int maxn = 1e5 + 10;
void nep(int n){
if(n == 1){
cout << "1 1\n";
return;
}
nep(n - 2);
for(int i = 0; i < (n - 3) / 2; i += 2){
cout << n << ' ' << i + 1 << "\n";
cout << n - 1 << ' ' << i + 1 << "\n";
cout << i + 1 << ' ' << n - 1 << "\n";
cout << i + 1 << ' ' << n << "\n";
cout << n - 1 << ' ' << i + 2 << "\n";
cout << n << ' ' << i + 2 << "\n";
cout << i + 2 << ' ' << n << "\n";
cout << i + 2 << ' ' << n - 1 << "\n";
}
cout << n << ' ' << n - 1 << "\n";
cout << n << ' ' << n - 2 << "\n";
cout << n - 2 << ' ' << n << "\n";
cout << n - 1 << ' ' << n << "\n";
cout << n - 2 << ' ' << n - 1 << "\n";
cout << n - 1 << ' ' << n - 1 << "\n";
cout << n - 1 << ' ' << n - 2 << "\n";
cout << n << ' ' << n << "\n";
}
void par(int n){
if(n == 4){
cout << "3 3\n";
cout << "1 2\n";
cout << "1 3\n";
cout << "3 1\n";
cout << "2 1\n";
cout << "3 2\n";
cout << "2 2\n";
cout << "2 4\n";
cout << "1 4\n";
cout << "4 1\n";
cout << "3 4\n";
cout << "4 4\n";
cout << "4 2\n";
cout << "4 3\n";
return;
}
par(n - 2);
cout << n - 1 << ' ' << 1 << "\n";
cout << n << ' ' << 1 << "\n";
cout << 1 << ' ' << n << "\n";
cout << 1 << ' ' << n - 1 << "\n";
cout << n - 1 << ' ' << 2 << "\n";
cout << n << ' ' << 2 << "\n";
cout << 2 << ' ' << n - 1 << "\n";
cout << 2 << ' ' << n << "\n";
cout << n - 1 << ' ' << 3 << "\n";
cout << n << ' ' << 3 << "\n";
cout << 3 << ' ' << n - 1 << "\n";
cout << 3 << ' ' << n << "\n";
for(int i = 4; i <= n - 3; i++){
if(i % 2 == 1){
cout << n << ' ' << i << "\n";
cout << n - 1 << ' ' << i << "\n";
cout << i << ' ' << n - 1 << "\n";
cout << i << ' ' << n << "\n";
}
else {
cout << n - 1 << ' ' << i << "\n";
cout << n << ' ' << i << "\n";
cout << i << ' ' << n << "\n";
cout << i << ' ' << n - 1 << "\n";
}
}
cout << n << ' ' << n - 2 << "\n";
cout << n - 1 << ' ' << n << "\n";
cout << n - 2 << ' ' << n - 1 << "\n";
cout << n - 1 << ' ' << n - 1 << "\n";
cout << n - 2 << ' ' << n << "\n";
cout << n - 1 << ' ' << n - 2 << "\n";
cout << n << ' ' << n - 1 << "\n";
cout << n << ' ' << n << "\n";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
if(n == 2){
cout << "1\n";
cout << "1 1\n";
return 0;
}
if(n % 2 == 1){
cout << n * n << "\n";
nep(n);
}
else {
cout << n * n - 2 << "\n";
par(n);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 1ms
memory: 3620kb
input:
1
output:
1 1 1
result:
ok 1 queen(s)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
2
output:
1 1 1
result:
ok 1 queen(s)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
3
output:
9 1 1 3 2 3 1 1 3 2 3 1 2 2 2 2 1 3 3
result:
ok 9 queen(s)
Test #4:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
4
output:
14 3 3 1 2 1 3 3 1 2 1 3 2 2 2 2 4 1 4 4 1 3 4 4 4 4 2 4 3
result:
ok 14 queen(s)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
5
output:
25 1 1 3 2 3 1 1 3 2 3 1 2 2 2 2 1 3 3 5 1 4 1 1 4 1 5 4 2 5 2 2 5 2 4 5 4 5 3 3 5 4 5 3 4 4 4 4 3 5 5
result:
ok 25 queen(s)
Test #6:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
6
output:
34 3 3 1 2 1 3 3 1 2 1 3 2 2 2 2 4 1 4 4 1 3 4 4 4 4 2 4 3 5 1 6 1 1 6 1 5 5 2 6 2 2 5 2 6 5 3 6 3 3 5 3 6 6 4 5 6 4 5 5 5 4 6 5 4 6 5 6 6
result:
ok 34 queen(s)
Test #7:
score: -6
Wrong Answer
time: 0ms
memory: 3620kb
input:
7
output:
49 1 1 3 2 3 1 1 3 2 3 1 2 2 2 2 1 3 3 5 1 4 1 1 4 1 5 4 2 5 2 2 5 2 4 5 4 5 3 3 5 4 5 3 4 4 4 4 3 5 5 7 1 6 1 1 6 1 7 6 2 7 2 2 7 2 6 7 6 7 5 5 7 6 7 5 6 6 6 6 5 7 7
result:
wrong answer the cell (7, 5) is attacking by 11 queen(s)
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%