제출 #739147

#제출 시각아이디문제언어결과실행 시간메모리
739147nguyentunglam가로등 (APIO19_street_lamps)C++17
20 / 100
2 ms468 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; bool a[110][110]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.ans", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n, q; cin >> n >> q; string s; cin >> s; s = " " + s; for(int i = 1; i <= n; i++) a[0][i] = s[i] - '0'; for(int timer = 1; timer <= q; timer++) { for(int i = 1; i <= n; i++) a[timer][i] = a[timer - 1][i]; string ask; cin >> ask; if (ask[0] == 't') { int i; cin >> i; a[timer][i] ^= 1; } else { int l, r; cin >> l >> r; r--; int ans = 0; for(int j = 0; j < timer; j++) { bool ok = 1; for(int k = l; k <= r; k++) ok &= a[j][k]; ans += ok; } cout << ans << endl; } } }

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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:12:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:13:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen ("task.ans", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:16:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:17:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...