Submission #200296

# Submission time Handle Problem Language Result Execution time Memory
200296 2020-02-06T09:05:03 Z Nordway Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
73 ms 4192 KB
#include<bits/stdc++.h>
#include "rainbow.h"

#define x first
#define y second
#define pb push_back
#define sz(v) (int)v.size()

using namespace std;

const int N=1e3+11;
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};

int n,m;
int x,y;
string s;
bool used[N][N];

void init(int R, int C, int sr, int sc, int M, char* S) {
  n=R;
  m=C;
  x=sr,y=sc;
  s=S;
}

void dfs(int r,int c){
  used[r][c]=1;
  //cout<<r<<" "<<c<<endl;
  for(int i=0;i<4;i++){
    int nx=r+dx[i],ny=c+dy[i];
    if(used[nx][ny])continue;
    dfs(nx,ny);
  }
}

int colour(int ar, int ac, int br, int bc) {
  if(max(n,m)<=50){
    int ans=0;
    for(int i=0;i<=n+1;i++){
      for(int j=0;j<=m+1;j++){
        if(ar<=i&&i<=br&&ac<=j&&j<=bc){
          used[i][j]=0;
          continue;
        }
        used[i][j]=1;
      }
    }
    int sr=x,sc=y;
    used[sr][sc]=1;
    for(int i=0;i<sz(s);i++){
      if(s[i]=='N')sr--;
      if(s[i]=='S')sr++;
      if(s[i]=='W')sc--;
      if(s[i]=='E')sc++;
      used[sr][sc]=1;
    }
   /* for(int i=0;i<=n+1;i++){
      for(int j=0;j<=m+1;j++){
        cout<<used[i][j];
      }
      cout<<endl;
    }*/
    for(int i=ar;i<=br;i++){
      for(int j=ac;j<=bc;j++){
        if(!used[i][j]){
          dfs(i,j);
          //cout<<endl;
          ans++;
        }
      }
    }
    return ans;
  }
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 15 ms 504 KB Output is correct
3 Correct 19 ms 504 KB Output is correct
4 Correct 19 ms 504 KB Output is correct
5 Correct 16 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 19 ms 504 KB Output is correct
12 Correct 19 ms 504 KB Output is correct
13 Correct 16 ms 504 KB Output is correct
14 Correct 17 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Incorrect 70 ms 3960 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 15 ms 504 KB Output is correct
3 Correct 19 ms 504 KB Output is correct
4 Correct 19 ms 504 KB Output is correct
5 Correct 16 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 19 ms 504 KB Output is correct
12 Correct 19 ms 504 KB Output is correct
13 Correct 16 ms 504 KB Output is correct
14 Correct 17 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Incorrect 73 ms 4192 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 15 ms 504 KB Output is correct
3 Correct 19 ms 504 KB Output is correct
4 Correct 19 ms 504 KB Output is correct
5 Correct 16 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 19 ms 504 KB Output is correct
12 Correct 19 ms 504 KB Output is correct
13 Correct 16 ms 504 KB Output is correct
14 Correct 17 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Incorrect 73 ms 4192 KB Output isn't correct
19 Halted 0 ms 0 KB -