# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
115459 |
2019-06-07T15:17:15 Z |
구사과(#2864) |
무지개나라 (APIO17_rainbow) |
C++14 |
|
3000 ms |
10048 KB |
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
vector<pi> pnt, vtx, edx, edy;
int minx = 1e9, miny = 1e9, maxx = -1e9, maxy = -1e9;
void init(int R, int C, int sr, int sc, int M, char *S) {
auto upload = [&](int x, int y){
pnt.emplace_back(x, y);
vtx.emplace_back(x, y);
vtx.emplace_back(x+1, y);
vtx.emplace_back(x, y+1);
vtx.emplace_back(x+1, y+1);
edx.emplace_back(x, y);
edx.emplace_back(x, y+1);
edy.emplace_back(x, y);
edy.emplace_back(x+1, y);
minx = min(minx, x); maxx = max(maxx, x + 1);
miny = min(miny, y); maxy = max(maxy, y + 1);
};
upload(sr, sc);
for(int i=0; i<M; i++){
if(S[i] == 'N') sr--;
if(S[i] == 'S') sr++;
if(S[i] == 'E') sc++;
if(S[i] == 'W') sc--;
upload(sr, sc);
}
auto normalize = [&](vector<pi> &v){
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end()) - v.begin());
};
normalize(pnt);
normalize(vtx);
normalize(edx);
normalize(edy);
}
bool in(int sx, int ex, int sy, int ey, pi x){
return sx <= x.first && x.first <= ex && sy <= x.second && x.second <= ey;
}
int colour(int ar, int ac, int br, int bc) {
int V = 0;
int E = 0;
int F = 0;
for(auto &i : vtx){
if(in(ar + 1, br, ac + 1, bc, i)) V++;
}
for(auto &i : edx){
if(in(ar, br, ac + 1, bc, i)) E++;
}
for(auto &i : edy){
if(in(ar + 1, br, ac, bc, i)) E++;
}
for(auto &i : pnt){
if(in(ar, br, ac, bc, i)) F++;
}
// printf("%d %d %d\n", V, E, F);
if(F == 0) return 1;
if(ar < minx && maxx < br + 1 && ac < miny && maxy < bc + 1){
return 2 + E - V - F;
}
return 1 + E - V - F;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
12 ms |
512 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
10 ms |
512 KB |
Output is correct |
13 |
Correct |
16 ms |
512 KB |
Output is correct |
14 |
Correct |
22 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Execution timed out |
3092 ms |
6672 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
64 ms |
9324 KB |
Output is correct |
3 |
Correct |
33 ms |
9324 KB |
Output is correct |
4 |
Correct |
34 ms |
9324 KB |
Output is correct |
5 |
Correct |
39 ms |
8688 KB |
Output is correct |
6 |
Correct |
80 ms |
9324 KB |
Output is correct |
7 |
Correct |
90 ms |
9324 KB |
Output is correct |
8 |
Correct |
65 ms |
9324 KB |
Output is correct |
9 |
Correct |
78 ms |
9324 KB |
Output is correct |
10 |
Correct |
44 ms |
5360 KB |
Output is correct |
11 |
Correct |
92 ms |
9324 KB |
Output is correct |
12 |
Correct |
61 ms |
9316 KB |
Output is correct |
13 |
Correct |
32 ms |
9324 KB |
Output is correct |
14 |
Correct |
32 ms |
9444 KB |
Output is correct |
15 |
Correct |
41 ms |
8688 KB |
Output is correct |
16 |
Correct |
92 ms |
9316 KB |
Output is correct |
17 |
Correct |
92 ms |
9324 KB |
Output is correct |
18 |
Correct |
80 ms |
9316 KB |
Output is correct |
19 |
Correct |
43 ms |
9320 KB |
Output is correct |
20 |
Correct |
44 ms |
9324 KB |
Output is correct |
21 |
Correct |
62 ms |
9324 KB |
Output is correct |
22 |
Correct |
93 ms |
9324 KB |
Output is correct |
23 |
Correct |
45 ms |
5404 KB |
Output is correct |
24 |
Correct |
83 ms |
9196 KB |
Output is correct |
25 |
Correct |
60 ms |
9324 KB |
Output is correct |
26 |
Correct |
38 ms |
9324 KB |
Output is correct |
27 |
Correct |
38 ms |
9324 KB |
Output is correct |
28 |
Correct |
47 ms |
8688 KB |
Output is correct |
29 |
Correct |
85 ms |
9312 KB |
Output is correct |
30 |
Correct |
89 ms |
9324 KB |
Output is correct |
31 |
Correct |
72 ms |
9324 KB |
Output is correct |
32 |
Correct |
40 ms |
9324 KB |
Output is correct |
33 |
Correct |
42 ms |
9324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
12 ms |
512 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
10 ms |
512 KB |
Output is correct |
13 |
Correct |
16 ms |
512 KB |
Output is correct |
14 |
Correct |
22 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Execution timed out |
3034 ms |
10048 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
12 ms |
512 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
10 ms |
512 KB |
Output is correct |
13 |
Correct |
16 ms |
512 KB |
Output is correct |
14 |
Correct |
22 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Execution timed out |
3034 ms |
10048 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |