Submission #74128

#TimeUsernameProblemLanguageResultExecution timeMemory
74128haitunElection (BOI18_election)C++14
28 / 100
3036 ms2840 KiB
#include <bits/stdc++.h> //#include "functions.h" #define FOR(x,y) for(int x = 0; x < y; x++) #define ALLR(x) x.begin(),x.end() #define con continue #define ll long long #define LINF LLONG_MAX #define INF INT_MAX #define pii pair<int,int> #define vi vector <int> #define pb push_back #define F first #define S second #define len(x) x.length() #define sz(x) x.size() #define SEE(v) for(auto x : v) cout << x << " "; cout << endl; using namespace std; int main(){ if(fopen("test.txt","r")) freopen("test.txt","r",stdin); int n; cin >> n; string s; cin >> s; int q; cin >> q; vector <pii> sc(q); FOR(j, q) cin >> sc[j].F >> sc[j].S; FOR(j, q) { int l = sc[j].F, r = sc[j].S; string ss = s.substr(l - 1, r - l + 1); //cout << ss << endl; vector <bool> nulled(ss.length(), 0); int cnt1 = 0, cnt2 = 0, ans = 0; FOR(k, ss.length()) { if(ss[k] == 'C') cnt1++; else cnt2++; if(cnt2 > cnt1) { cnt2--; nulled[k] = true; } } cnt1 = cnt2 = 0; for(int k = ss.length() - 1; k >= 0; k--) { if(nulled[k]) con; if(ss[k] == 'C') cnt1++; else cnt2++; if(cnt2 > cnt1) { cnt2--; nulled[k] = true; } } FOR(k, nulled.size()) { if(nulled[k]) ans++; } cout << ans << endl; } }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:3:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(x,y) for(int x = 0; x < y; x++)
election.cpp:42:7:
   FOR(k, ss.length())
       ~~~~~~~~~~~~~~               
election.cpp:42:3: note: in expansion of macro 'FOR'
   FOR(k, ss.length())
   ^~~
election.cpp:3:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(x,y) for(int x = 0; x < y; x++)
election.cpp:70:7:
   FOR(k, nulled.size())
       ~~~~~~~~~~~~~~~~             
election.cpp:70:3: note: in expansion of macro 'FOR'
   FOR(k, nulled.size())
   ^~~
election.cpp:21:35: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  if(fopen("test.txt","r")) freopen("test.txt","r",stdin);
                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...