QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#189830 | #5473. Move One Coin | GenshinImpactsFault | WA | 6ms | 6264kb | C++17 | 3.4kb | 2023-09-27 23:30:00 | 2023-09-27 23:30:01 |
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;
bool vis[N][N];
int gval(int x, int y) {
if(x < 1 || y < 1 || x > n || y > m) return 0;
vis[x][y] = 1;
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 <= n; i++)
for(int j = 1; j <= m; j++)
vis[i][j] = 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);
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) {
if(!a[i][j]) continue;
if(vis[i][j]) continue;
sx = i, sy = j;
}
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;
}
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];
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5508kb
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: 1ms
memory: 5448kb
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: 5932kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
498 498 0 0
result:
ok OK! rot=0
Test #4:
score: 0
Accepted
time: 6ms
memory: 3684kb
input:
500 500 oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 0 498 498
result:
ok OK! rot=0
Test #5:
score: 0
Accepted
time: 5ms
memory: 5552kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
497 1 0 499
result:
ok OK! rot=0
Test #6:
score: 0
Accepted
time: 5ms
memory: 5784kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 499 497 1
result:
ok OK! rot=0
Test #7:
score: 0
Accepted
time: 3ms
memory: 5708kb
input:
500 500 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 498 -498 996
result:
ok OK! rot=3
Test #8:
score: 0
Accepted
time: 3ms
memory: 6264kb
input:
500 500 oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 0 498 498
result:
ok OK! rot=1
Test #9:
score: 0
Accepted
time: 6ms
memory: 5920kb
input:
500 500 xooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
1 0 -497 -498
result:
ok OK! rot=0
Test #10:
score: -100
Wrong Answer
time: 6ms
memory: 5588kb
input:
500 500 oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
497 499 499 499
result:
wrong answer Pattern did not match after movement