답안 #948505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948505 2024-03-18T07:14:54 Z vjudge1 무지개나라 (APIO17_rainbow) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "rainbow.h"
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=2e5+5;
int g[100][N],vis[100][N],cnt[100][N];
int r,c;
void init(int R, int C, int sr, int sc, int M, string S){
    r=R;
    c=C;
    g[sr][sc]=1;
    for(int i=0;i<M;i++){
        if(S[i]=='N')sr--;
        else if(S[i]=='S')sr++;
        else if(S[i]=='W')sc--;
        else sc++;
        g[sr][sc]=1;
    }
    
    for(int i=1;i<=r;i++){
        g[i][0]=1;
        for(int j=1;j<=c;j++){
            cnt[i][j]=cnt[i][j-1];
            if(!g[i][j] && g[i][j-1])cnt[i][j]++;
        }
    }
       
}
int colour(int ar, int ac, int br, int bc){
    if(r==2){
        if(ar==br){
            int ans=cnt[ar][bc]-cnt[ar][ac-1];
            if(!g[ar][ac-1] && !g[ar][ac])ans++;
            return ans;
        }
        int x=cnt[ar][bc]-cnt[ar][ac-1];
        if(!g[ar][ac-1] && !g[ar][ac])x++;
        int y=cnt[br][bc]-cnt[br][ac-1];
        if(!g[br][ac-1] && !g[br][ac])y++;
        if(x==1 && y==1)return 1;
        int res=x+y;
        
        if(!g[ar][ac] && !g[br][ac])res--;
        if(!g[ar][bc] && !g[br][bc])res--;
        return res;
        
    }
    queue <pair <int,int> > q;
    vector <int> X={0,0,-1,1};
    vector <int> Y={1,-1,0,0};
    int ans=0;
    for(int i=ar;i<=br;i++){
        for(int j=ac;j<=bc;j++){
            if(!vis[i][j] && !g[i][j]){
                ans++;
                vis[i][j]=1;
                q.push({i,j});
                while(!q.empty()){
                    int x=q.front().ff;
                    int y=q.front().ss;
                    q.pop();
                    for(int k=0;k<4;k++){
                        if(x+X[k]>=ar && x+X[k]<=br && y+Y[k]>=ac && y+Y[k]<=bc && !g[x+X[k]][y+Y[k]] && !vis[x+X[k]][y+Y[k]]){
                            vis[x+X[k]][y+Y[k]]=1;
                            q.push({x+X[k],y+Y[k]});
                        }
                    }
                }
            }
            
        }
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            vis[i][j]=0;
        }
    }
    return ans;
}
/*signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int r,c,m,q,x,y;
    cin>>r>>c>>m>>q>>x>>y;
    string s;
    cin>>s;
    init(r,c,x,y,m,s);
    for(int i=0;i<q;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<colour(a,b,c,d)<<"\n";
    }
}*/

Compilation message

/usr/bin/ld: /tmp/ccDWmoPt.o: in function `main':
grader.cpp:(.text.startup+0xed): undefined reference to `init(int, int, int, int, int, char*)'
collect2: error: ld returned 1 exit status