답안 #948321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948321 2024-03-18T04:06:32 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=100;
int g[N][N],vis[N][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;
    }
}
int colour(int ar, int ac, int br, int bc){
    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/cc44cely.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