Submission #252955

# Submission time Handle Problem Language Result Execution time Memory
252955 2020-07-26T14:18:27 Z orgiooo Land of the Rainbow Gold (APIO17_rainbow) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <rainbow.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 colour(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:23: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:23:1: error: ambiguating new declaration of 'int init(int, int, int, int, int, char*)'
 init(int R, int C, int sr, int sc, int M, char *S) {
 ^~~~
In file included from rainbow.cpp:2:0:
rainbow.h:4:6: note: old declaration 'void init(int, int, int, int, int, char*)'
 void init(int R, int C, int sr, int sc, int M, char *S);
      ^~~~
rainbow.cpp:47:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
rainbow.cpp: In function 'void colour(int, int, int, int)':
rainbow.cpp:48:6: error: ambiguating new declaration of 'void colour(int, int, int, int)'
 void colour(int ar, int ac, int br, int bc) {
      ^~~~~~
In file included from rainbow.cpp:2:0:
rainbow.h:5:5: note: old declaration 'int colour(int, int, int, int)'
 int colour(int ar, int ac, int br, int bc);
     ^~~~~~
rainbow.cpp:119:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return l-2+1;
                ^