Submission #128547

# Submission time Handle Problem Language Result Execution time Memory
128547 2019-07-11T06:15:17 Z 임유진(#3161) None (JOI16_ho_t4) C++14
15 / 100
137 ms 12764 KB
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

#define MAXN 100005
#define fi first
#define se second

typedef long long lint;
typedef pair<lint, lint> pll;

const int mm[4][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}};
char S[MAXN];
vector<pll> dot;
lint dotX[MAXN], dotY[MAXN];
vector<lint> ty;
vector<int> ds[MAXN];
vector<pll> cell;

int main() {
	int N, K;
	lint A, B;

	scanf("%d%d%s", &N, &K, S);

	//printf("[%s]", S);

	dot.push_back(make_pair(0ll, 0ll));
	for(int i = 0; i < N; i++) {
		dot.push_back(dot.back());
		if(S[i] == 'W') dot[i + 1].fi--;
		else if(S[i] == 'E') dot[i + 1].fi++;
		else if(S[i] == 'N') dot[i + 1].se++;
		else dot[i + 1].se--;
		//printf("*%c*", S[i]);
	}
	for(int i = 0; i <= N; i++) for(int j = 0; j < 4; j++) 
		cell.push_back(make_pair(dot[i].fi - mm[j][0], dot[i].se - mm[j][1]));

	A = dot[N].fi;
	B = dot[N].se;
	//printf("A = %lld, B = %lld\n", A, B);
	if(A == B || K == 1) {
		sort(dot.begin(), dot.end());
		dot.resize(unique(dot.begin(), dot.end()) - dot.begin());
		sort(cell.begin(), cell.end());
		cell.resize(unique(cell.begin(), cell.end()) - cell.begin());
		//printf("%lu", cell.size());
		//for(auto a : cell) printf("(%lld, %lld)\n", a.fi, a.se);

		int ans = 0;
		for(auto a : cell) {
			bool b = true;
			for(int j = 0; j < 4; j++) b &= binary_search(dot.begin(), dot.end(), make_pair(a.fi + mm[j][0], a.se + mm[j][1]));
			if(b) ans++;
		}
		printf("%d", ans);
		return 0;
	}
	/*
	for(int i = 0; i <= N; i++) ty.push_back(B * dotX[i] - A * dotY[i]);
	sort(ty.begin(), ty.end());
	unique(ty.begin(), ty.end());
	for(int i = 0; i <= N; i++) {
		int l = lower_bound(ty.begin(), ty.end(), B * dotX[i] - A * dotY[i]) - ty.begin();
		ds[l].push_back(
	}
	*/

	return 0;
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s", &N, &K, S);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 4 ms 2684 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 4 ms 2684 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2684 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 4 ms 2684 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 4 ms 2684 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2684 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 7 ms 3444 KB Output is correct
28 Correct 13 ms 4080 KB Output is correct
29 Correct 35 ms 7780 KB Output is correct
30 Correct 51 ms 12260 KB Output is correct
31 Correct 100 ms 12764 KB Output is correct
32 Correct 66 ms 12764 KB Output is correct
33 Correct 69 ms 12636 KB Output is correct
34 Correct 70 ms 12636 KB Output is correct
35 Correct 68 ms 12636 KB Output is correct
36 Correct 74 ms 12764 KB Output is correct
37 Correct 68 ms 12764 KB Output is correct
38 Correct 67 ms 12636 KB Output is correct
39 Correct 69 ms 12636 KB Output is correct
40 Correct 67 ms 12636 KB Output is correct
41 Correct 64 ms 12636 KB Output is correct
42 Correct 63 ms 12616 KB Output is correct
43 Correct 70 ms 12640 KB Output is correct
44 Correct 68 ms 12636 KB Output is correct
45 Correct 62 ms 12636 KB Output is correct
46 Correct 96 ms 12636 KB Output is correct
47 Correct 108 ms 12636 KB Output is correct
48 Correct 137 ms 12636 KB Output is correct
49 Correct 89 ms 12640 KB Output is correct
50 Correct 89 ms 12636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 4 ms 2684 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 4 ms 2684 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2684 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Incorrect 4 ms 2680 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 4 ms 2684 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 4 ms 2684 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2684 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 7 ms 3444 KB Output is correct
28 Correct 13 ms 4080 KB Output is correct
29 Correct 35 ms 7780 KB Output is correct
30 Correct 51 ms 12260 KB Output is correct
31 Correct 100 ms 12764 KB Output is correct
32 Correct 66 ms 12764 KB Output is correct
33 Correct 69 ms 12636 KB Output is correct
34 Correct 70 ms 12636 KB Output is correct
35 Correct 68 ms 12636 KB Output is correct
36 Correct 74 ms 12764 KB Output is correct
37 Correct 68 ms 12764 KB Output is correct
38 Correct 67 ms 12636 KB Output is correct
39 Correct 69 ms 12636 KB Output is correct
40 Correct 67 ms 12636 KB Output is correct
41 Correct 64 ms 12636 KB Output is correct
42 Correct 63 ms 12616 KB Output is correct
43 Correct 70 ms 12640 KB Output is correct
44 Correct 68 ms 12636 KB Output is correct
45 Correct 62 ms 12636 KB Output is correct
46 Correct 96 ms 12636 KB Output is correct
47 Correct 108 ms 12636 KB Output is correct
48 Correct 137 ms 12636 KB Output is correct
49 Correct 89 ms 12640 KB Output is correct
50 Correct 89 ms 12636 KB Output is correct
51 Incorrect 4 ms 2680 KB Output isn't correct
52 Halted 0 ms 0 KB -