제출 #1261500

#제출 시각아이디문제언어결과실행 시간메모리
1261500phtungElection (BOI18_election)C++20
0 / 100
3 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define name "IO" #define int long long const int inf = 1e18 + 7; const int maxn = 5e5 + 5; int n, q; string s; void solve() { cin >> n >> s; s = ' ' + s; cin >> q; while(q--) { int l, r; cin >> l >> r; int cntc = 0, cntt = 0, res = 0; for(int i = l; i <= r; i++) { cntc += (s[i] == 'C'); cntt += (s[i] == 'T'); if(cntt > cntc) { res++; cntt--; } } int dem = 0; cntc = cntt = 0; for(int i = r; i >= l; i--) { cntc += (s[i] == 'C'); cntt += (s[i] == 'T'); if(cntt > cntc) { dem++; cntt--; } } res = max(res, dem); cout << res << "\n"; } } signed main() { if (fopen (name".INP", "r")) { freopen (name".INP", "r", stdin); freopen (name".OUT", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); clock_t start = clock(); int t = 1; while(t--) solve(); std::cerr << "Time: " << clock() - start << "ms\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

election.cpp: In function 'int main()':
election.cpp:61:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen (name".INP", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
election.cpp:62:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen (name".OUT", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...