Submission #594187

# Submission time Handle Problem Language Result Execution time Memory
594187 2022-07-12T08:00:31 Z 장태환(#8433) None (JOI16_ho_t4) C++17
38 / 100
1000 ms 132024 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<pair<int, int>, int>t;
int ge(string inp)
{
	int x = 0;
	int y = 0;
	int i;
	t.clear();
	t[{x, y}] = 1;
	int ans = 0;
	for (i = 0; i < inp.size(); i++)
	{
		if (inp[i] == 'E')
			x++;
		else if (inp[i] == 'W')
			x--;
		else if (inp[i] == 'N')
			y++;
		else
			y--;
		if (t[{x, y}])
			continue;
		t[{x, y}] = 1;
		ans += t[{x - 1, y}] && t[{x, y - 1}] && t[{x - 1, y - 1}];
		ans += t[{x - 1, y}] && t[{x, y + 1}] && t[{x - 1, y + 1}];
		ans += t[{x + 1, y}] && t[{x, y - 1}] && t[{x + 1, y - 1}];
		ans += t[{x + 1, y}] && t[{x, y + 1}] && t[{x + 1, y + 1}];
	}
	return ans;

}
signed main()
{
	int N, M;
	cin >> N >> M;
	string s;
	cin >> s;
	if (N * M < 1000000)
	{
		string v;
		int i;
		for (i = 0; i < M; i++)
		{
			v.append(s);
		}
		cout << ge(v);
	}
	else
	{
		string v;
		int i;
		for (i = 0; i < 100; i++)
		{
			v.append(s);
		}
		int a1 = ge(v);
		v.append(s);
		int a2 = ge(v);
		cout << (a2 - a1) * (M - 100) + a1;
	}
}

Compilation message

2016_ho_t4.cpp: In function 'long long int ge(std::string)':
2016_ho_t4.cpp:13:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for (i = 0; i < inp.size(); i++)
      |              ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 224 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 224 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 16 ms 1620 KB Output is correct
30 Correct 25 ms 1564 KB Output is correct
31 Correct 78 ms 15904 KB Output is correct
32 Correct 26 ms 2144 KB Output is correct
33 Correct 31 ms 2508 KB Output is correct
34 Correct 31 ms 3180 KB Output is correct
35 Correct 30 ms 2416 KB Output is correct
36 Correct 28 ms 2260 KB Output is correct
37 Correct 29 ms 2372 KB Output is correct
38 Correct 31 ms 2552 KB Output is correct
39 Correct 31 ms 2420 KB Output is correct
40 Correct 28 ms 2208 KB Output is correct
41 Correct 25 ms 2144 KB Output is correct
42 Correct 21 ms 1820 KB Output is correct
43 Correct 32 ms 2644 KB Output is correct
44 Correct 29 ms 2292 KB Output is correct
45 Correct 24 ms 2004 KB Output is correct
46 Correct 56 ms 9964 KB Output is correct
47 Correct 45 ms 9964 KB Output is correct
48 Correct 74 ms 16164 KB Output is correct
49 Correct 113 ms 19392 KB Output is correct
50 Correct 134 ms 19348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 224 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 260 ms 27324 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 83 ms 6264 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 288 ms 31668 KB Output is correct
35 Correct 4 ms 596 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 4 ms 596 KB Output is correct
38 Correct 3 ms 340 KB Output is correct
39 Correct 2 ms 468 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 3 ms 468 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 3 ms 484 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 4 ms 468 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 5 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 224 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 16 ms 1620 KB Output is correct
30 Correct 25 ms 1564 KB Output is correct
31 Correct 78 ms 15904 KB Output is correct
32 Correct 26 ms 2144 KB Output is correct
33 Correct 31 ms 2508 KB Output is correct
34 Correct 31 ms 3180 KB Output is correct
35 Correct 30 ms 2416 KB Output is correct
36 Correct 28 ms 2260 KB Output is correct
37 Correct 29 ms 2372 KB Output is correct
38 Correct 31 ms 2552 KB Output is correct
39 Correct 31 ms 2420 KB Output is correct
40 Correct 28 ms 2208 KB Output is correct
41 Correct 25 ms 2144 KB Output is correct
42 Correct 21 ms 1820 KB Output is correct
43 Correct 32 ms 2644 KB Output is correct
44 Correct 29 ms 2292 KB Output is correct
45 Correct 24 ms 2004 KB Output is correct
46 Correct 56 ms 9964 KB Output is correct
47 Correct 45 ms 9964 KB Output is correct
48 Correct 74 ms 16164 KB Output is correct
49 Correct 113 ms 19392 KB Output is correct
50 Correct 134 ms 19348 KB Output is correct
51 Correct 260 ms 27324 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 4 ms 596 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 2 ms 340 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 83 ms 6264 KB Output is correct
58 Correct 3 ms 468 KB Output is correct
59 Correct 288 ms 31668 KB Output is correct
60 Correct 4 ms 596 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 4 ms 596 KB Output is correct
63 Correct 3 ms 340 KB Output is correct
64 Correct 2 ms 468 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 2 ms 340 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 3 ms 468 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 3 ms 484 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 2 ms 340 KB Output is correct
73 Correct 4 ms 468 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 5 ms 1112 KB Output is correct
76 Correct 303 ms 7160 KB Output is correct
77 Correct 94 ms 2040 KB Output is correct
78 Execution timed out 1101 ms 132024 KB Time limit exceeded
79 Halted 0 ms 0 KB -