QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619179#2446. Block BreakerAfterlife#AC ✓134ms11272kbC++20867b2024-10-07 13:26:192024-10-07 13:26:19

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 13:26:19]
  • 评测
  • 测评结果:AC
  • 用时:134ms
  • 内存:11272kb
  • [2024-10-07 13:26:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2020;
int n,m,q;
bool ok[N][N];
int ans;
const int d[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
bool check(int x,int y){
    return (ok[x-1][y]|ok[x+1][y])&(ok[x][y-1]|ok[x][y+1]);
}
bool In(int x,int y){
    return x>=1&&x<=n&&y>=1&&y<=m;
}
void D(int x,int y){
    if(ok[x][y])return;
    ++ans;
    ok[x][y]=1;
    for(int i=0;i<4;++i){
        int nx=x+d[i][0];
        int ny=y+d[i][1];
        if(!In(nx,ny)||ok[nx][ny]||!check(nx,ny))continue;
        D(nx,ny);
    }
}
void Solve(){
    cin>>n>>m>>q;
    memset(ok,0,sizeof(ok));
    while(q--){
        int x,y;
        cin>>x>>y;
        ans=0;
        D(x,y);
        cout<<ans<<'\n';
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--)Solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 134ms
memory: 11272kb

input:

10
1 1 2
1 1
1 1
1 2 5
1 2
1 2
1 1
1 2
1 1
1651 1852 69820
938 1459
98 243
1504 554
725 245
601 587
1465 1687
1037 1172
433 1112
173 493
1175 278
302 558
1326 633
375 1043
495 1673
1275 1672
1629 1299
1588 432
507 1754
953 270
1475 1805
1343 1096
798 1633
1124 809
525 1163
1201 1633
1381 578
1489 89...

output:

1
0
1
0
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 576535 lines