QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619174#2446. Block BreakerCheek_support#WA 212ms7296kbC++201.8kb2024-10-07 13:25:132024-10-07 13:25:19

Judging History

This is the latest submission verdict.

  • [2024-10-07 13:25:19]
  • Judged
  • Verdict: WA
  • Time: 212ms
  • Memory: 7296kb
  • [2024-10-07 13:25:13]
  • Submitted

answer

#pragma GCC optimizeA("Ofast")
#pragma GCC optimizeA("inline")
#pragma GCC optimizeA("unroll-loops")

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define DEBUG_VAR(x) { cerr << "* "#x" = " << x << endl; }
using namespace std;
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
const int N=2000,M=2000;
bool dropped[N+10][M+10];
queue<pair<int,int> >Q;

int n,m,q;
bool chk(int x,int y){
    if(dropped[x][y])return 0;
    if(x<1||x>n||y<1||y>m)return 0;
    int cnt1=0,cnt2=0;
    rep(k,0,3){
        int tx=x+dir[k][0];
        int ty=y+dir[k][1];
        if(k<=1){
            cnt1+=dropped[tx][ty];
        }else{
            cnt2+=dropped[tx][ty];
        }
    }
    return (cnt1&&cnt2);
}
int main()
{
    // freopen("1.in", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(nullptr);

    
    int T;
    cin>>T;
    while(T--){
        cin>>n>>m>>q;
        rep(i,1,n){
            rep(j,1,m){
                dropped[i][j]=0;
            }
        }

        rep(i,1,q){
            int x,y;
            cin>>x>>y;
            if(dropped[x][y]){
                cout<<0<<endl;
                continue;
            }

            int cnt=0;
            Q.push(make_pair(x,y));
            dropped[x][y]=1;
            while(!Q.empty()){
                cnt++;
                auto p=Q.front();
                Q.pop();
                
                rep(k,0,3){
                    int x=p.first+dir[k][0];
                    int y=p.second+dir[k][1];
                    if(chk(x,y)){
                        Q.push(make_pair(x,y));
                        dropped[x][y]=1;
                    }
                }
            }
            cout<<cnt<<endl;
        }
        
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 212ms
memory: 7296kb

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:

wrong answer 89214th lines differ - expected: '1', found: '2'