#include <bits/stdc++.h>
#include "rainbow.h"
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ii = pair<int,int>; using ll = long long; using ull = unsigned long long;
using vi = vector<ll>;
void valid(int in){cout<<((in)?"YES\n":"NO\n");return;}
vector<vi> arr;
void init(int n, int m, int sr ,int sc, int movs, char *moves){
arr.resize(n+1, vi(m+1,0));arr[sr][sc] = 1;
fo(i,movs){
if(moves[i] == 'N')sr--;
else if(moves[i]=='S')sr++;
else if(moves[i]=='E')sc++;
else if(moves[i]=='W')sc--;
arr[sr][sc] = 1;
}
}
int colour(int r1, int c1, int r2 ,int c2){
vector<vi> vis(55, vi(55,0));vi dir = {0,1,0,-1,0};int con = 0;
fore(i, r1, r2+1){
fore(j, c1, c2+1){
if(vis[i][j] || arr[i][j])continue;
queue<ii> q;q.push({i,j});vis[i][j]=1;con++;
while(q.size()){
ii where = q.front();q.pop();
fo(k,4){
int ni = where.f + dir[k], nj = where.s + dir[k+1];
if(ni<r1 || nj<c1 || ni>r2 || nj>c2)continue;
if(vis[ni][nj] || arr[ni][nj]) continue;
vis[ni][nj]=1;q.push({ni, nj});
}
}
}
}return con;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
492 KB |
Output is correct |
3 |
Correct |
18 ms |
348 KB |
Output is correct |
4 |
Correct |
25 ms |
488 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
15 ms |
492 KB |
Output is correct |
12 |
Correct |
14 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
492 KB |
Output is correct |
14 |
Correct |
14 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
7 ms |
10044 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
501 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
492 KB |
Output is correct |
3 |
Correct |
18 ms |
348 KB |
Output is correct |
4 |
Correct |
25 ms |
488 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
15 ms |
492 KB |
Output is correct |
12 |
Correct |
14 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
492 KB |
Output is correct |
14 |
Correct |
14 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Runtime error |
15 ms |
16984 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
492 KB |
Output is correct |
3 |
Correct |
18 ms |
348 KB |
Output is correct |
4 |
Correct |
25 ms |
488 KB |
Output is correct |
5 |
Correct |
12 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
15 ms |
492 KB |
Output is correct |
12 |
Correct |
14 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
492 KB |
Output is correct |
14 |
Correct |
14 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Runtime error |
15 ms |
16984 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |