Submission #103535

# Submission time Handle Problem Language Result Execution time Memory
103535 2019-03-31T10:52:50 Z ekrem Election (BOI18_election) C++
0 / 100
12 ms 384 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

int n, q, bas, son, say, ans, u[N];
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %s %d",&n ,s + 1 ,&q);
	while(q--){
		scanf("%d %d",&bas, &son);
		ans = say = 0;
		for(int i = bas; i <= son; i++){
			if(s[i] == 'C')
				say++;
			else
				say--;
			if(say < 0){
				ans++;
				say = 0;
				u[i] = 1;
			} else
				u[i] = 0;
		}
		say = 0;
		for(int i = son; i >= 1; i--){
			if(u[i])
				continue;
			if(s[i] == 'C')
				say++;
			else
				say--;
			if(say < 0){
				say = 0;
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %s %d",&n ,s + 1 ,&q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
election.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&bas, &son);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -