QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546951 | #7733. Cool, It’s Yesterday Four Times More | pzc2004# | WA | 1ms | 7904kb | C++14 | 2.6kb | 2024-09-04 16:09:07 | 2024-09-04 16:09:07 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i=l, _=r; i<=_; ++i)
using namespace std;
template<class T>inline void read(T &x){
x=0;
char c=getchar();
while(!isdigit(c))c=getchar();
while(isdigit(c))x=x*10+(c&15),c=getchar();
}
int n, m;
// int f[5005];
// unsigned int b[1005][1005];
// unsigned int tt=4294967295u;
char a[2005][2005];
bitset<2005> A[2005], B[2005];
bool vis[2005][2005];
const int dx[]= {-1, 0, 1, 0}, dy[]= {0, -1, 0, 1};
int mnx, mxx, mny, mxy;
int dfs(int sx, int sy) {
static int top, sta[4000005][2];
top=1, sta[top][0]=sx, sta[top][1]=sy;
vis[sx][sy]=1;
int res=0;
while(top) {
int x=sta[top][0], y=sta[top][1];
if(x-sx<mnx) mnx=x-sx;
else if(x-sx>mxx) mxx=x-sx;
if(y-sy<mny) mny=y-sy;
else if(y-sy>mxy) mxy=y-sy;
// fprintf(stderr, "%d %d\n", x, y);
--top;
rep(d, 0, 3) {
int nx=x+dx[d], ny=y+dy[d];
if(nx>=0 && nx<n && ny>=0 && ny<m) {
if(a[nx][ny]=='.' && !vis[nx][ny]) {
sta[++top][0]=nx, sta[top][1]=ny;
vis[nx][ny]=1;
}
}
}
++res;
}
return res;
}
int main(){
int T_T;
scanf("%d", &T_T);
while(T_T--) {
rep(i, 0, n-1) rep(j, 0, m-1) {
vis[i][j]=0;
A[i][j]=0;
}
// puts("??");
scanf("%d%d", &n, &m);
rep(i, 0, n-1) {
scanf("\n%s", a[i]);
rep(j, 0, m-1) {
A[i][j]=(a[i][j]=='.');
}
}
int ans=0;
rep(i, 0, n-1) rep(j, 0, m-1) {
if(a[i][j]=='.' && !vis[i][j]) {
// printf("%d %d\n", i, j);
mnx=0, mxx=0;
mny=0, mxy=0;
int cnt=dfs(i, j);
rep(u, mnx, mxx) {
B[u-mnx].reset();
rep(v, mny, mxy) {
B[u-mnx][v-mny]=A[i+u][j+v];
}
}
int lenx=mxx-mnx+1, leny=mxy-mny+1;
// printf("i = %d, j = %d, lenx = %d, leny = %d\n", i, j, lenx, leny);
// printf("B: %d %d, A: %d\n", (int) B[0][0], (int) B[0][1], (int) A[0][0]);
bool suc=1;
rep(x, 0, n-lenx) rep(y, 0, m-leny) if(x!=i+mnx || y!=j+mny) {
bool res=1;
// puts("????F?ASDF?SA?DF");
rep(u, 0, lenx-1) if((A[x+u]>>y&B[u])!=B[u]) {
res=0;
break;
}
if(res) {
// printf("%d %d %d %d x\n", i, j, x, y);
suc=0;
break;
}
}
if(suc) {
ans+=cnt;
}
}
}
printf("%d\n", ans);
// for(int i = 1; i <= n; i++) {
// for(int j = 1, k = 0; j <= m; j++) {
// if(j&31==1) k++, b[k]=0;
// b[k]=b[k]*2+(a[i][j]=='.');
// }
// }
// for(int i = 1; i <= n; i++)
// for(int j = 1; j <= m; j++) if(a[i][j]=='.') {
// int t=0;
// if(a[i-1][j]=='.') t=1;
// if(a[i][j-1]=='.') t=1;
// if(!t) num++;
// }
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7904kb
input:
4 2 5 .OO.. O..O. 1 3 O.O 1 3 .O. 2 3 OOO OOO
output:
3 1 0 0
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 5972kb
input:
200 2 4 OOO. OO.. 2 3 OOO .O. 3 3 O.O OOO OO. 4 1 . . O O 1 2 .O 1 1 . 2 5 .OO.. .O.O. 2 1 O O 1 1 O 1 3 .OO 5 1 O O . O . 5 2 O. .. O. .O .. 5 3 ... ... .OO ..O OOO 3 5 ..O.O .O.O. .OO.O 5 2 .O OO O. O. .. 2 1 O O 3 5 .O.OO O...O ..OO. 1 5 ..... 5 1 O . O . . 5 3 OOO OO. .OO OO. O.O 2 1 O . 5 2 O. ...
output:
3 0 0 2 1 1 3 0 0 1 0 7 9 4 4 0 6 5 2 0 1 6 4 5 2 0 0 5 3 3 1 4 1 0 7 5 2 3 7 3 0 6 2 2 2 0 4 6 6 3 3 2 3 5 2 1 0 3 3 4 4 2 2 0 7 6 4 8 5 3 2 5 2 1 2 1 4 0 0 2 5 1 4 6 6 1 6 2 2 3 4 5 2 1 0 1 9 3 4 11 0 3 2 1 0 0 4 3 1 4 3 8 3 0 3 6 2 5 1 3 3 4 0 2 11 2 2 4 0 4 4 6 2 1 2 3 0 5 0 16 4 3 2 6 0 8 3 3 1...
result:
ok 200 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 6036kb
input:
50 10 9 OOOO.O... O...O.OOO .....O... ..OO..O.O ...O..O.O ..OOO..O. ..OOO...O .OO.O..OO .O.O.OO.. .O..O.O.O 10 10 .O.OOO.OO. ...OOOOOOO ...O.O..O. .O.O..O... .O.O.OO..O ..OO.O..OO O....O..OO OO...OOOOO OO.OO.O..O .O.O.OOOOO 10 8 O..OOO.O O.OOOO.. O..OO.OO OO..OO.. .OOO..O. .OO.OO.O OOO..OO. ..O..OO....
output:
31 40 13 30 40 37 27 29 20 26 25 29 21 29 21 31 32 31 33 34 25 31 18 25 41 28 20 45 20 29 18 21 27 28 35 13 20 17 32 29 28 23 23 23 24 18 28 17 35 24
result:
wrong answer 4th lines differ - expected: '25', found: '30'