QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#189827 | #5473. Move One Coin | GenshinImpactsFault | WA | 8ms | 5668kb | C++17 | 3.5kb | 2023-09-27 23:23:31 | 2023-09-27 23:23:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 510;
int n, m, nn, mm;
int a[N][N], b[N][N], c[N][N];
pii aa[2], bb[2];
int la, lb;
int gval(int x, int y) {
if(x < 1 || y < 1 || x > n || y > m) return 0;
return a[x][y];
}
void solve() {
la = lb = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++)
if(a[i][j]) {
aa[la++] = {i, j};
if(la == 2) break;
}
if(la == 2) break;
}
for(int i = 1; i <= nn; i++) {
for(int j = 1; j <= mm; j++)
if(b[i][j]) {
bb[lb++] = {i, j};
if(lb == 2) break;
}
if(lb == 2) break;
}
int dx, dy, ax, ay, sx, sy;
for(int ii = 0; ii < 2; ii++)
for(int jj = 0; jj < 2; jj++) {
dx = aa[ii].first - bb[jj].first;
dy = aa[ii].second - bb[jj].second;
ax = -1, ay = -1, sx = -1, sy = -1;
int cnt = 0;
for(int i = 1; i <= nn; i++)
for(int j = 1; j <= mm; j++) {
if(b[i][j] ^ gval(i + dx, j + dy)) ++cnt;
if(b[i][j] && !gval(i + dx, j + dy))
ax = i + dx, ay = j + dy;
if(!b[i][j] && gval(i + dx, j + dy))
sx = i + dx, sy = j + dy;
}
if(cnt > 2) continue;
if(cnt == 0) {
ax = aa[ii].first, ay = aa[ii].second;
sx = aa[ii].first, sy = aa[ii].second;
cout << sy - 1 << " " << sx - 1 << "\n";
cout << ay - 1 << " " << ax - 1 << "\n";
exit(0);
}
// if(sx == -1 || sy == -1 || ax == -1 || ay == -1) {
// continue;
// }
cout << sy - 1 << " " << sx - 1 << "\n";
cout << ay - 1 << " " << ax - 1 << "\n";
exit(0);
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(nullptr);
cin >> n >> m;
int cnt = 0;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) {
char c; cin >> c;
for(; c != 'x' && c != 'o'; cin >> c);
if(c == 'o') a[i][j] = 1, ++cnt;
}
cin >> nn >> mm;
for(int i = 1; i <= nn; i++)
for(int j = 1; j <= mm; j++) {
char c; cin >> c;
for(; c != 'x' && c != 'o'; cin >> c);
if(c == 'o') b[i][j] = 1;
}
// for(int i = 1; i <= n; i++) {
// for(int j = 1; j <= m; j++) cout << a[i][j];
// cout << "\n";
// }
// cout << "\n";
// for(int i = 1; i <= nn; i++) {
// for(int j = 1; j <= mm; j++) cout << b[i][j];
// cout << "\n";
// }
// cout << "\n";
if(cnt == 1) {
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
if(a[i][j]) {
cout << j - 1 << " " << i - 1 << "\n" << j - 1 << " " << i - 1 << "\n";
exit(0);
}
return 0;
}
for(int h = 0; h < 4; h++) {
solve();
for(int i = 1; i <= nn; i++)
for(int j = 1; j <= mm; j++)
c[mm - j + 1][i] = b[i][j];
swap(nn, mm);
for(int i = 1; i <= nn; i++)
for(int j = 1; j <= mm; j++)
b[i][j] = c[i][j];
}
assert(0);
return 0;
}
// 1 3
// xoo
// 5 1
// x
// x
// x
// o
// o
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5616kb
input:
2 3 xox ooo 4 2 ox ox ox ox
output:
1 0 3 1
result:
ok OK! rot=1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
3 3 xox oxo xox 4 4 oxxx xxox xoxo xxxx
output:
1 2 -1 -1
result:
ok OK! rot=0
Test #3:
score: 0
Accepted
time: 6ms
memory: 3416kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
498 498 0 0
result:
ok OK! rot=0
Test #4:
score: 0
Accepted
time: 3ms
memory: 5508kb
input:
500 500 oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 0 498 498
result:
ok OK! rot=0
Test #5:
score: 0
Accepted
time: 6ms
memory: 3460kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
497 1 0 499
result:
ok OK! rot=0
Test #6:
score: 0
Accepted
time: 5ms
memory: 5600kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 499 497 1
result:
ok OK! rot=0
Test #7:
score: 0
Accepted
time: 3ms
memory: 5620kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 498 -498 996
result:
ok OK! rot=3
Test #8:
score: 0
Accepted
time: 8ms
memory: 5624kb
input:
500 500 oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 0 498 498
result:
ok OK! rot=1
Test #9:
score: 0
Accepted
time: 5ms
memory: 3492kb
input:
500 500 xooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
1 0 -497 -498
result:
ok OK! rot=0
Test #10:
score: -100
Wrong Answer
time: 5ms
memory: 5668kb
input:
500 500 oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
-2 -2 499 499
result:
wrong answer x1 out of range