QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#258050#7733. Cool, It’s Yesterday Four Times MoreSSH#Compile Error//C++203.0kb2023-11-19 14:41:102023-11-19 14:41:10

Judging History

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

  • [2023-11-19 14:41:10]
  • 评测
  • [2023-11-19 14:41:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
void solve();
signed main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}
#define N 5000
bitset<N> st[N];
char g[N];
int n,m,X[4]={0,0,1,-1},Y[4]={1,-1,0,0};
map<pair<int,int>,int>mp;
int idx;
int getid(int x,int y){
    return x*(m+2)+y+3500;
}
void solve(){
    idx=0;
    mp.clear();
    cin>>n>>m;
    for(int i=0;i<=n+1;i++){
        for(int j=0;j<=m+1;j++){
            g[getid(i,j)]='O';
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>g[getid(i,j)];
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(g[getid(i,j)] != 'O'){
                cnt++;
                queue<pair<int,int>> q;
                q.push({0,0});
                set<pair<int,int>> vis;
                while(q.size()){
                    auto [dx,dy]=q.front();
                    q.pop();
                    if(vis.count({dx,dy}))continue;
                    vis.insert({dx,dy});
                    if(g[getid(i+dx,j+dy)]=='O'){
                        st[getid(dx,dy)].set(getid(i,j),1);
                        continue;
                    }
                    for(int k=0;k<4;k++){
                        int ndx=dx+X[k];
                        int ndy=dy+Y[k];
                        if(vis.count({ndx,ndy})==false){
                            q.push({ndx,ndy});
                        }
                    }
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            
            if(g[getid(i,j)]!='O'){
                bitset<N> nt;
                queue<pair<int,int>> q;
                q.push({0,0});
                set<pair<int,int>> vis;
                while(q.size()){
                    if(nt.count()==cnt-1){
                        ans++;
                        break;
                    }
                    auto [dx,dy]=q.front();
                    q.pop();
                    if(vis.count({dx,dy}))continue;
                    vis.insert({dx,dy});
                    if(g[getid(i+dx,j+dy)]=='O'){
                        continue;
                    }
                    else{
                        nt|=st[getid(dx,dy)];
                        if(nt.count()==cnt-1){
                            ans++;
                            break;
                        }
                    }
                    for(int k=0;k<4;k++){
                        int ndx=dx+X[k];
                        int ndy=dy+Y[k];
                        if(vis.count({ndx,ndy})==false){
                            q.push({ndx,ndy});
                        }
                    }
                }
                
            }
            
        }
    }
    cout<<ans<<"\n";
    for(int i=0;i<N;i++){
        st[i].reset();
    }

Details

answer.code: In function ‘void solve()’:
answer.code:110:6: error: expected ‘}’ at end of input
  110 |     }
      |      ^
answer.code:24:13: note: to match this ‘{’
   24 | void solve(){
      |             ^