QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#672858 | #7733. Cool, It’s Yesterday Four Times More | xxk2006 | WA | 1ms | 3752kb | C++23 | 3.7kb | 2024-10-24 19:32:11 | 2024-10-24 19:32:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define Enter putchar('\n')
#define spc putchar(' ')
#define pb push_back
#define fi first
#define se second
inline void read(int &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
inline void lread(long long &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
void print(long long num){if(num<0){putchar('-');num=-num;}if(num>9){print(num/10);}putchar((num%10)^48);}
char a[1009];
int f[1009];
vector<int> g[1009];
int xx[4]={1,-1,0,0},yy[4]={0,0,1,-1};
int n,m;
inline int d(int x,int y){
return (x-1)*m+y;
}
inline bool ck(int x){
return x>0&&x<=n*m;
}
int find(int re){
return f[re]==re?re:f[re]=find(f[re]);
}
int cal(int x,int y,int z,int h,int i){
int s=z%m;
if(s==0)s=m;
int v=(z-1)/m+1;
return d(h+v-x,i+s-y);
}
int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
f[d(i,j)]=d(i,j);
scanf(" %c",&a[d(i,j)]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[d(i,j)]=='O')continue;
for(int k=0;k<4;k++){
if(ck(d(i+xx[k],j+yy[k]))&&a[d(i+xx[k],j+yy[k])]=='.'){
f[find(d(i,j))]=find(d(i+xx[k],j+yy[k]));
}
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[d(i,j)]=='O')continue;
g[find(d(i,j))].pb(d(i,j));
}
}
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++){
// if(a[d(i,j)]=='O'||find(d(i,j))!=d(i,j))continue;
// cout<<i<<' '<<j<<' '<<d(i,j)<<':';
// for(int k=0;k<g[d(i,j)].size();k++){
// cout<<g[d(i,j)][k]<<' ';
// }
// cout<<endl;
// }
// }
int re,p,ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
bool flag=1;
re=d(i,j);
if(a[re]=='O')continue;
for(int b=1;b<=n&&flag;b++){
for(int c=1;c<=m;c++){
if(b==i&&c==j)continue;
bool vi=1;
int z=find(re);
if(a[d(b,c)]=='O'||z==find(d(b,c)))continue;
//cout<<i<<' '<<j<<' '<<b<<' '<<c<<' '<<re<<endl;
for(int e=0;e<g[z].size();e++){
p=cal(i,j,g[z][e],b,c);
//printf("%d %d %d %d %d %d\n",i,j,g[z][e],b,c,p);
if(ck(p)==0||a[p]=='O'){
//cout<<i<<' '<<j<<':'<<b<<' '<<c<<'#'<<g[z][e]<<endl;
vi=0;
break;
}
}
//cout<<"Yes"<<' '<<i<<' '<<j<<' '<<vi<<endl;
if(vi){
flag=0;
break;
}
}
}
if(flag)++ans;
}
}
print(ans),Enter;
for(int i=1;i<=n*m;i++)g[i].clear();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
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: -100
Wrong Answer
time: 1ms
memory: 3752kb
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 5 0 0 1 0 7 9 5 4 0 6 5 2 2 1 7 6 10 2 0 0 6 3 3 1 4 1 0 7 5 2 3 7 3 0 6 3 3 2 0 4 6 6 5 5 3 3 5 2 1 0 3 3 4 4 3 2 0 8 6 4 8 5 3 2 5 2 1 2 1 4 0 0 2 5 1 4 6 6 1 6 2 2 5 5 5 2 1 0 1 9 3 4 11 0 3 2 1 2 0 4 3 1 4 3 8 4 0 3 6 2 5 1 3 3 4 0 2 11 2 2 5 0 4 4 5 2 1 2 3 0 7 0 16 4 3 2 6 0 8 3 3 ...
result:
wrong answer 7th lines differ - expected: '3', found: '5'