제출 #739148

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

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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:14:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:15:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         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...