Submission #100421

# Submission time Handle Problem Language Result Execution time Memory
100421 2019-03-11T06:00:15 Z 1Khan Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
3000 ms 19932 KB
// In the name of GOD

#include "rainbow.h"

#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

#define BeGood ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define orset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nl '\n'
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

typedef long long ll;
typedef double db;

const int N = 1e4 + 5;
//const int M = 1e9 + 7;

int a[1111][1111];
int b[1111][1111];
void man(int i, int j, int l, int r, int L, int R){
     if(i > L || i < l || j > R || j < r){
          return;
     }
     if(!a[i + 1][j] && !b[i + 1][j]){
          b[i + 1][j] = 2;
          man(i + 1, j, l, r, L, R);
     }
     if(!a[i][j + 1] && !b[i][j + 1]){
          b[i][j + 1] = 2;
          man(i, j + 1, l, r, L, R);
     }
     if(!a[i][j - 1] && !b[i][j - 1]){
          b[i][j - 1] = 2;
          man(i, j - 1, l, r, L, R);
     }
     if(!a[i - 1][j] && !b[i - 1][j]){
          b[i - 1][j] = 2;
          man(i - 1, j, l, r, L, R);
     } else{
          return;
     }
}
void init(int R, int C, int sr, int sc, int M, char *S){

     int n = R;
     int k = C;
     int x = sr;
     int y = sc;
     int slen = M;

          for(int i = 0; i < slen; ++i){
               a[x][y] = 1;
               if(S[i] == 'N'){
                    x--;
               }
               if(S[i] == 'W'){
                    y--;
               }
               if(S[i] == 'S'){
                    x++;
               }
               if(S[i] == 'E'){
                    y++;
               }
          }
          a[x][y] = 1;
}

int colour(int ar, int ac, int br, int bc){
     int x1 = ar;
     int x2 = br;
     int y1 = ac;
     int y2 = bc;
     memset(b, 0, sizeof(b));
     int ans = 0;
     for(int i = x1; i <= x2; ++i){
          for(int j = y1; j <= y2; ++j){
               if(a[i][j] == 0){
                    if(b[i][j] == 0){
                         ans++;
                    }
                    b[i][j] = 2;
                    man(i, j, x1, y1, x2, y2);
               }
          }
     }
     return ans;
}

Compilation message

rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:56:10: warning: unused variable 'n' [-Wunused-variable]
      int n = R;
          ^
rainbow.cpp:57:10: warning: unused variable 'k' [-Wunused-variable]
      int k = C;
          ^
# Verdict Execution time Memory Grader output
1 Correct 244 ms 5372 KB Output is correct
2 Correct 265 ms 5436 KB Output is correct
3 Correct 306 ms 5632 KB Output is correct
4 Correct 293 ms 5596 KB Output is correct
5 Correct 280 ms 5752 KB Output is correct
6 Correct 10 ms 5248 KB Output is correct
7 Correct 9 ms 5120 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 10 ms 5248 KB Output is correct
10 Correct 10 ms 5248 KB Output is correct
11 Correct 286 ms 5540 KB Output is correct
12 Correct 270 ms 5504 KB Output is correct
13 Correct 260 ms 5504 KB Output is correct
14 Correct 264 ms 5496 KB Output is correct
15 Correct 6 ms 5092 KB Output is correct
16 Correct 9 ms 5248 KB Output is correct
17 Correct 9 ms 5248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 5248 KB Output is correct
2 Correct 9 ms 5248 KB Output is correct
3 Execution timed out 3007 ms 5712 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5092 KB Output is correct
2 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 244 ms 5372 KB Output is correct
2 Correct 265 ms 5436 KB Output is correct
3 Correct 306 ms 5632 KB Output is correct
4 Correct 293 ms 5596 KB Output is correct
5 Correct 280 ms 5752 KB Output is correct
6 Correct 10 ms 5248 KB Output is correct
7 Correct 9 ms 5120 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 10 ms 5248 KB Output is correct
10 Correct 10 ms 5248 KB Output is correct
11 Correct 286 ms 5540 KB Output is correct
12 Correct 270 ms 5504 KB Output is correct
13 Correct 260 ms 5504 KB Output is correct
14 Correct 264 ms 5496 KB Output is correct
15 Correct 6 ms 5092 KB Output is correct
16 Correct 9 ms 5248 KB Output is correct
17 Correct 9 ms 5248 KB Output is correct
18 Execution timed out 3006 ms 19932 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 244 ms 5372 KB Output is correct
2 Correct 265 ms 5436 KB Output is correct
3 Correct 306 ms 5632 KB Output is correct
4 Correct 293 ms 5596 KB Output is correct
5 Correct 280 ms 5752 KB Output is correct
6 Correct 10 ms 5248 KB Output is correct
7 Correct 9 ms 5120 KB Output is correct
8 Correct 8 ms 5248 KB Output is correct
9 Correct 10 ms 5248 KB Output is correct
10 Correct 10 ms 5248 KB Output is correct
11 Correct 286 ms 5540 KB Output is correct
12 Correct 270 ms 5504 KB Output is correct
13 Correct 260 ms 5504 KB Output is correct
14 Correct 264 ms 5496 KB Output is correct
15 Correct 6 ms 5092 KB Output is correct
16 Correct 9 ms 5248 KB Output is correct
17 Correct 9 ms 5248 KB Output is correct
18 Execution timed out 3006 ms 19932 KB Time limit exceeded
19 Halted 0 ms 0 KB -