Submission #55416

# Submission time Handle Problem Language Result Execution time Memory
55416 2018-07-07T08:45:53 Z 김세빈(#1545) Toilets (JOI16_toilets) C++11
36 / 100
8 ms 892 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

char str[202020];
ll n, k, f, m, ans1, ans2;

int main()
{
	ll i, s, e;
	
	scanf("%lld%lld", &n, &k);
	
	if(k > 1) return 0;
	
	scanf("%s", str);
	
	for(i=0;i<n+n;i++){
		if(str[i] == 'F') f ++;
		else m ++;
	}
	
	if(f < m){
		printf("-1\n");
		return 0;
	}
	
	f = m = 0;
	
	for(i=n+n-1;i>=0;i--){
		if(str[i] == 'F') f ++;
		else m ++;
		
		if(i & 1){
			if(m - f & 1) ans1 = max(ans1, m - f);
			else ans1 = max(ans1, m - f + 1);
		}
		else{
			if(m - f & 1) ans2 = max(ans2, m - f + 1);
			else ans2 = max(ans2, m - f);
		}
	}
	
	printf("%lld\n", min(ans1, ans2));
	
	return 0;
}

Compilation message

toilets.cpp: In function 'int main()':
toilets.cpp:37:9: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    if(m - f & 1) ans1 = max(ans1, m - f);
       ~~^~~
toilets.cpp:41:9: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    if(m - f & 1) ans2 = max(ans2, m - f + 1);
       ~~^~~
toilets.cpp:12:8: warning: unused variable 's' [-Wunused-variable]
  ll i, s, e;
        ^
toilets.cpp:12:11: warning: unused variable 'e' [-Wunused-variable]
  ll i, s, e;
           ^
toilets.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
toilets.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", str);
  ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 628 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 3 ms 628 KB Output is correct
16 Correct 2 ms 628 KB Output is correct
17 Correct 3 ms 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 3 ms 628 KB Output is correct
20 Correct 2 ms 628 KB Output is correct
21 Correct 2 ms 628 KB Output is correct
22 Correct 3 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 628 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 3 ms 628 KB Output is correct
16 Correct 2 ms 628 KB Output is correct
17 Correct 3 ms 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 3 ms 628 KB Output is correct
20 Correct 2 ms 628 KB Output is correct
21 Correct 2 ms 628 KB Output is correct
22 Correct 3 ms 628 KB Output is correct
23 Correct 7 ms 764 KB Output is correct
24 Correct 6 ms 764 KB Output is correct
25 Correct 7 ms 812 KB Output is correct
26 Correct 4 ms 812 KB Output is correct
27 Correct 3 ms 812 KB Output is correct
28 Correct 7 ms 812 KB Output is correct
29 Correct 5 ms 836 KB Output is correct
30 Correct 5 ms 836 KB Output is correct
31 Correct 6 ms 836 KB Output is correct
32 Correct 6 ms 892 KB Output is correct
33 Correct 3 ms 892 KB Output is correct
34 Correct 4 ms 892 KB Output is correct
35 Correct 7 ms 892 KB Output is correct
36 Correct 8 ms 892 KB Output is correct
37 Correct 5 ms 892 KB Output is correct
38 Correct 5 ms 892 KB Output is correct
39 Correct 5 ms 892 KB Output is correct
40 Correct 6 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 628 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 3 ms 628 KB Output is correct
16 Correct 2 ms 628 KB Output is correct
17 Correct 3 ms 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 3 ms 628 KB Output is correct
20 Correct 2 ms 628 KB Output is correct
21 Correct 2 ms 628 KB Output is correct
22 Correct 3 ms 628 KB Output is correct
23 Correct 7 ms 764 KB Output is correct
24 Correct 6 ms 764 KB Output is correct
25 Correct 7 ms 812 KB Output is correct
26 Correct 4 ms 812 KB Output is correct
27 Correct 3 ms 812 KB Output is correct
28 Correct 7 ms 812 KB Output is correct
29 Correct 5 ms 836 KB Output is correct
30 Correct 5 ms 836 KB Output is correct
31 Correct 6 ms 836 KB Output is correct
32 Correct 6 ms 892 KB Output is correct
33 Correct 3 ms 892 KB Output is correct
34 Correct 4 ms 892 KB Output is correct
35 Correct 7 ms 892 KB Output is correct
36 Correct 8 ms 892 KB Output is correct
37 Correct 5 ms 892 KB Output is correct
38 Correct 5 ms 892 KB Output is correct
39 Correct 5 ms 892 KB Output is correct
40 Correct 6 ms 892 KB Output is correct
41 Incorrect 2 ms 892 KB Output isn't correct
42 Halted 0 ms 0 KB -