답안 #252951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252951 2020-07-26T14:15:33 Z orgiooo 무지개나라 (APIO17_rainbow) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ret return 0
#define con continue
#define db double
#define gcd __gcd
#define freopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
ll n,m,ans,t,cnt,x,y,z,u;
ll i,j,r,l,k;
ll a[1231234],b[1234567],d[1234567],e[1234567];
map <ll,ll> f;
set<pair<ll,ll>> s;
set<int>::iterator it;
vector <ll> c[1234567];
string p[2000000],q,w[2000000];
ll lcm(ll x,ll y){
    ll z=gcd(x,y);
    return x*y/z;
}
init(int R, int C, int sr, int sc, int M, char *S) {
    n=R;m=C;x=sr;y=sc;k=M;
    x--;y--;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            w[i][j]='0';
        }
    }
    w[x][y]='1';
    for(i=0;i<k;i++){
        if (q[i]=='W'){
            y--;
        }
        if (q[i]=='E'){
            y++;
        }
        if (q[i]=='N'){
            x--;
        }
        if (q[i]=='S'){
            x++;
        }
        w[x][y]='1';
    }
}
void colours(int ar, int ac, int br, int bc) {
    ll x1 = ar;
    ll y1 = ac;
    ll x2 = br;
    ll y2 = bc;
    x1--;y1--;x2--;y2--;
    for(i=x1;i<=x2;i++){
        for(j=y1;j<=y2;j++){
            p[i-x1][j-y1]=w[i][j];
        }
    }
    x=x2-x1;y=y2-y1;x++;y++;
    cnt=0 ;
    for (i=0;i<x;i++){
        for(j=0;j<y;j++){
            if (p[i][j]=='0'){
                cnt ++ ;
            }
        }
    }
    l=1;
    while (cnt>0){
        ll ss =0 ;
        for (i=0;i<x;i++){
            for(j=0;j<y;j++){
                if (p[i][j]>49){
                    if (i+1<x&&p[i+1][j]=='0'){
                        ss++;
                        p[i+1][j]=p[i][j];
                    }
                    if (j+1<y&&p[i][j+1]=='0'){
                        ss++;
                        p[i][j+1]=p[i][j];
                    }
                    if (i-1>=0&&p[i-1][j]=='0'){
                        ss++;
                        p[i-1][j]=p[i][j];
                    }
                    if (j-1>=0&&p[i][j-1]=='0'){
                        ss++;
                        p[i][j-1]=p[i][j];
                    }
                }
            }
            
        }
        if (ss==0){
            l++;
            for (i=0;i<x;i++){
                ll kk =0;
                for(j=0;j<y;j++){
                    if (p[i][j]=='0'){
                        p[i][j]=char(l+48);
                        kk++;break;
                    }
                }
                if (kk>0){
                    break;
                }
            }
        }
        cnt=0;
        for (i=0;i<x;i++){
            for(j=0;j<y;j++){
                if (p[i][j]=='0'){
                    cnt ++ ;
                }
            }
        }
        
    }
    return l-2+1;
 }

Compilation message

rainbow.cpp:22:50: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
 init(int R, int C, int sr, int sc, int M, char *S) {
                                                  ^
rainbow.cpp: In function 'int init(int, int, int, int, int, char*)':
rainbow.cpp:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
rainbow.cpp: In function 'void colours(int, int, int, int)':
rainbow.cpp:118:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return l-2+1;
                ^