Submission #61692

# Submission time Handle Problem Language Result Execution time Memory
61692 2018-07-26T10:42:34 Z hamzqq9 Election (BOI18_election) C++14
0 / 100
20 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000000000000000
#define umax(x,y) x=max(x,(y))
#define pw(x) (1<<(x))

char s[2234],temp[2234];
int n,q,x,y;

int main() {
  
//  freopen("in.txt","r",stdin);

  scanf("%d",&n);

  scanf("%s",s+1);

  scanf("%d",&q);

  while(q--) {

    scanf("%d %d",&x,&y);

    for(int i=x;i<=y;i++) {

      temp[i]=s[i];

    }

    int bas=x,son=y;

    int sumx=0,sumy=0;
    int ans=0;

    while(x<=son && y>=bas) {

      sumx+=(temp[x]=='T'?-1:temp[x]=='C'?1:0);

      if(sumx<0) {
        ans++;

        sumx++;

        if(x>y) sumy++;

        temp[x]='0';

      }

      sumy+=(temp[y]=='T'?-1:temp[y]=='C'?1:0);

      if(sumy<0) {
        ans++;
        sumy++;

        if(y<x) sumx++;

        temp[y]='0';

      }

      x++;
      y--;

    }

    printf("%d\n",ans);

  }


}

Compilation message

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