#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
int marc[5][200000], f;
vector< int > vl,vr;
void init(int r, int c, int sr, int sc, int m, char *s) {
f = 0;
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)marc[i][j] = 0;
vl.clear(); vr.clear();
for(int i = 0; i < m; i++){
if(s[i] == 'N')sr--;
else if(s[i] == 'S')sr++;
else if(s[i] == 'W')sc--;
else sc++;
marc[sr][sc] = 1;
}
int l = 0;
for(int i = 1; i <= c; i++){
if(marc[1][i] == 1 && marc[2][i] == 1 && l == 0)l = i;
else if((marc[1][i] == 0 || marc[2][i]==0) && l != 0){
vl.push_back(l);
vr.push_back(i-1);
l = 0;
}
}
if((int)vl.size() == 0){
int l = 0;
for(int i = 1; i <= c; i++){
if(marc[1][i] == 1){
if(l == 0)l = i;
f = 1;
}
if(marc[2][i] == 1){
if(l == 0)l = i;
f = 2;
}
if(f!=0 && marc[f][i] == 0){
vl.push_back(l);
vr.push_back(i-1);
l = 0;
}
}
}
}
int colour(int ar, int ac, int br, int bc) {
if(f){
if(ar != br)return 1;
if(ar != f)return 1;
if(ac < vl[0] && vr[0] < bc)return 2;
return 1;
}
int idl = lower_bound(vl.begin(),vl.end(), ac)-vl.begin();
int idr = upper_bound(vr.begin(),vr.end(), bc)-vr.begin();
if(idl == (int)vl.size() || idr == 0)return 1;
idr--;
int ans = idr-idl;
if(ac < vl[idl])ans++;
if(vr[idr] < bc)ans++;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
4688 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
4688 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
4688 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
4688 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |