QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296776 | #7178. Bishops | AlphaMale06 | WA | 17ms | 3460kb | C++14 | 1.7kb | 2024-01-03 16:14:31 | 2024-01-03 16:14:33 |
Judging History
answer
#include <bits/stdc++.h>
/*
Oce nas,
koji si na nebesima,
da se sveti ime Tvoje,
da dodje carstvo Tvoje,
da bude volja Tvoja,
i na zemlji, kao i na nebu.
Hleb nas nasusni daj nam danas,
i oprosti nam dugove nase,
kao sto i mi oprastamo duznicima svojim,
i ne uvedi nas u iskusenje,
no izbavi nas od zloga.
Jer je Tvoje Carstvo,
i sila, i slava,
u vekove vekova.
Amin.
*/
using namespace std;
typedef vector<int> vc;
typedef vector<vector<int>> vvc;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(), (x).end()
#define int long long
void print(int x, int y, bool swp){
if(swp)cout << y << " " << x << '\n';
else cout << x << " " << y << '\n';
}
void sol(int n, int m, bool swp){
for(int i=1; i<=n; i++){
print(i, 1, swp);
print(i, m, swp);
}
int f, l;
f=n/2+2;
l=m-n/2-1;
for(int i=f; i<=l; i+=2){
print(n/2, i, swp);
print(n/2+1, i, swp);
}
}
void solve(){
int n, m;
cin >> n >> m;
bool swp=0;
if(n>m){
swap(n, m);
swp=1;
}
if(n==m || (n%2==0 && m%2==0)){
cout << n+m-2 << '\n';
if(n==m){
for(int i=1; i<=n; i++){
cout << 1 << " " << i << '\n';
}
for(int i=2; i<n; i++){
cout << n << " " << i << '\n';
}
}
else{
sol(n, m, swp);
}
}
else{
cout << n+m-1 << '\n';
if(n%2==0){
sol(n, m, swp);
}
else{
for(int i=1; i<=n; i++){
print(i, m, swp);
print(i, 1, swp);
}
for(int i=n; i<=m-n+1; i++){
print((n+1)/2, i, swp);
}
}
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3392kb
input:
2 5
output:
6 1 1 1 5 2 1 2 5 1 3 2 3
result:
ok n: 2, m: 5, bishops: 6
Test #2:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
5 5
output:
8 1 1 1 2 1 3 1 4 1 5 5 2 5 3 5 4
result:
ok n: 5, m: 5, bishops: 8
Test #3:
score: 0
Accepted
time: 17ms
memory: 3444kb
input:
100000 100000
output:
199998 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 ...
result:
ok n: 100000, m: 100000, bishops: 199998
Test #4:
score: 0
Accepted
time: 17ms
memory: 3456kb
input:
100000 99999
output:
199998 100000 1 1 1 100000 2 1 2 100000 3 1 3 100000 4 1 4 100000 5 1 5 100000 6 1 6 100000 7 1 7 100000 8 1 8 100000 9 1 9 100000 10 1 10 100000 11 1 11 100000 12 1 12 100000 13 1 13 100000 14 1 14 100000 15 1 15 100000 16 1 16 100000 17 1 17 100000 18 1 18 100000 19 1 19 100000 20 1 20 100000 21 1...
result:
ok n: 100000, m: 99999, bishops: 199998
Test #5:
score: 0
Accepted
time: 13ms
memory: 3344kb
input:
100000 50000
output:
149998 1 1 100000 1 1 2 100000 2 1 3 100000 3 1 4 100000 4 1 5 100000 5 1 6 100000 6 1 7 100000 7 1 8 100000 8 1 9 100000 9 1 10 100000 10 1 11 100000 11 1 12 100000 12 1 13 100000 13 1 14 100000 14 1 15 100000 15 1 16 100000 16 1 17 100000 17 1 18 100000 18 1 19 100000 19 1 20 100000 20 1 21 100000...
result:
ok n: 100000, m: 50000, bishops: 149998
Test #6:
score: -100
Wrong Answer
time: 6ms
memory: 3444kb
input:
1 100000
output:
100000 1 100000 1 1 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58...
result:
wrong answer Sum diagonals are not distinct