답안 #241780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241780 2020-06-25T13:14:54 Z dsjong 영역 (JOI16_ho_t4) C++14
38 / 100
71 ms 9848 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	string s;
	cin>>n>>k>>s;
	assert(k==1 || n<=60);
	int x=0, y=0;
	set<pair<int, int>>v;
	v.insert({0, 0});
	for(int i=0;i<n;i++){
		if(s[i]=='E') x++;
		if(s[i]=='W') x--;
		if(s[i]=='N') y--;
		if(s[i]=='S') y++;
		v.insert({x, y});
	}
	int dy=y, dx=x;
	set<pair<int, int>>v2;
	long long cnt=0;
	if(k<=60){
		for(int i=0;i<k;i++){
			for(auto [x, y]:v){
				v2.insert({x+i*dx, y+i*dy});
			}
		}
		for(auto i:v2){
			int x=i.first, y=i.second;
			if(v2.find({x+1, y})!=v2.end() && v2.find({x, y+1})!=v2.end() && v2.find({x+1, y+1})!=v2.end()){
				cnt++;
			}
		}
	}
	else{
		for(int i=0;i<60;i++){
			for(auto [x, y]:v){
				v2.insert({x+i*dx, y+i*dy});
			}
		}
		long long A=0;
		for(auto i:v2){
			int x=i.first, y=i.second;
			if(v2.find({x+1, y})!=v2.end() && v2.find({x, y+1})!=v2.end() && v2.find({x+1, y+1})!=v2.end()){
				A++;
			}
		}
		for(auto [x, y]:v){
			v2.insert({x+60*dx, y+60*dy});
		}
		long long B=0;
		for(auto i:v2){
			int x=i.first, y=i.second;
			if(v2.find({x+1, y})!=v2.end() && v2.find({x, y+1})!=v2.end() && v2.find({x+1, y+1})!=v2.end()){
				B++;
			}
		}
		B-=A;
		//cout<<A<<" "<<B<<endl;
		cnt=A+B*(k-60ll);
	}
	cout<<cnt;
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:26:13: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
    for(auto [x, y]:v){
             ^
2016_ho_t4.cpp:39:13: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
    for(auto [x, y]:v){
             ^
2016_ho_t4.cpp:50:12: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
   for(auto [x, y]:v){
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 8 ms 640 KB Output is correct
29 Correct 17 ms 1656 KB Output is correct
30 Correct 19 ms 1792 KB Output is correct
31 Correct 56 ms 8312 KB Output is correct
32 Correct 25 ms 2304 KB Output is correct
33 Correct 29 ms 2816 KB Output is correct
34 Correct 29 ms 2944 KB Output is correct
35 Correct 27 ms 2688 KB Output is correct
36 Correct 27 ms 2432 KB Output is correct
37 Correct 27 ms 2688 KB Output is correct
38 Correct 29 ms 2560 KB Output is correct
39 Correct 28 ms 2688 KB Output is correct
40 Correct 26 ms 2432 KB Output is correct
41 Correct 24 ms 2304 KB Output is correct
42 Correct 23 ms 1920 KB Output is correct
43 Correct 29 ms 2944 KB Output is correct
44 Correct 27 ms 2560 KB Output is correct
45 Correct 24 ms 2176 KB Output is correct
46 Correct 38 ms 5112 KB Output is correct
47 Correct 40 ms 5120 KB Output is correct
48 Correct 71 ms 9848 KB Output is correct
49 Correct 70 ms 9848 KB Output is correct
50 Correct 69 ms 9848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 512 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 6 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 6 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 6 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 8 ms 640 KB Output is correct
29 Correct 17 ms 1656 KB Output is correct
30 Correct 19 ms 1792 KB Output is correct
31 Correct 56 ms 8312 KB Output is correct
32 Correct 25 ms 2304 KB Output is correct
33 Correct 29 ms 2816 KB Output is correct
34 Correct 29 ms 2944 KB Output is correct
35 Correct 27 ms 2688 KB Output is correct
36 Correct 27 ms 2432 KB Output is correct
37 Correct 27 ms 2688 KB Output is correct
38 Correct 29 ms 2560 KB Output is correct
39 Correct 28 ms 2688 KB Output is correct
40 Correct 26 ms 2432 KB Output is correct
41 Correct 24 ms 2304 KB Output is correct
42 Correct 23 ms 1920 KB Output is correct
43 Correct 29 ms 2944 KB Output is correct
44 Correct 27 ms 2560 KB Output is correct
45 Correct 24 ms 2176 KB Output is correct
46 Correct 38 ms 5112 KB Output is correct
47 Correct 40 ms 5120 KB Output is correct
48 Correct 71 ms 9848 KB Output is correct
49 Correct 70 ms 9848 KB Output is correct
50 Correct 69 ms 9848 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 5 ms 384 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 5 ms 512 KB Output is correct
63 Correct 6 ms 384 KB Output is correct
64 Correct 5 ms 384 KB Output is correct
65 Correct 5 ms 384 KB Output is correct
66 Correct 5 ms 384 KB Output is correct
67 Correct 6 ms 384 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 6 ms 384 KB Output is correct
71 Correct 5 ms 384 KB Output is correct
72 Correct 6 ms 384 KB Output is correct
73 Correct 5 ms 384 KB Output is correct
74 Correct 5 ms 384 KB Output is correct
75 Correct 6 ms 512 KB Output is correct
76 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
77 Halted 0 ms 0 KB -