#include <bits/stdc++.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,pf; vi pf2;
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;
pf.resize(n+1,vi(m+1,0));arr[0][0] = arr[1][0] = 1;
pf2.resize(m+1,0);
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;
}
fore(i,1,m+1){
fore(j,1,n+1){
if(arr[j][i] == 1 and arr[j][i-1] == 0)pf[j][i]++;
pf[j][i] += pf[j][i-1];
}
if(arr[1][i] and arr[2][i] and !(arr[1][i-1] and arr[2][i-1]))pf2[i]++;
pf2[i]+=pf2[i-1];
}
}
int colour(int r1, int c1, int r2 ,int c2){
if(r1==r2)return pf[r1][c2] - pf[r1][c1] + (arr[r1][c2] == 0);
return pf2[c2] - pf2[c1] + !(arr[1][c2] and arr[2][c2]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
57 ms |
14828 KB |
Output is correct |
4 |
Correct |
50 ms |
15040 KB |
Output is correct |
5 |
Correct |
47 ms |
14904 KB |
Output is correct |
6 |
Correct |
46 ms |
14896 KB |
Output is correct |
7 |
Correct |
46 ms |
14900 KB |
Output is correct |
8 |
Correct |
48 ms |
14924 KB |
Output is correct |
9 |
Correct |
47 ms |
14900 KB |
Output is correct |
10 |
Correct |
47 ms |
15040 KB |
Output is correct |
11 |
Correct |
47 ms |
14900 KB |
Output is correct |
12 |
Correct |
44 ms |
14988 KB |
Output is correct |
13 |
Correct |
44 ms |
14900 KB |
Output is correct |
14 |
Correct |
44 ms |
15004 KB |
Output is correct |
15 |
Correct |
47 ms |
14844 KB |
Output is correct |
16 |
Correct |
45 ms |
14900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |