제출 #733053

#제출 시각아이디문제언어결과실행 시간메모리
733053boyliguanhan가로등 (APIO19_street_lamps)C++17
20 / 100
870 ms211656 KiB
#include<bits/stdc++.h> using namespace std; char opposite(char c) { if(c=='0') return '1'; return '0'; } bool ok(string str, int a, int b) { for(int i = a-1; i < b-1; i++) { if(str[i]=='0') return 0; } return 1; } int main() { int n, q; cin >> n >> q; int prev[n]; queue<pair<int, int>> operations[n]; memset(prev, 0, sizeof prev); string str; cin >> str; for(int i = 0; i < n; i++) { if(str[i]=='1') operations[i].push({1, 0}); } for(int i = 1; i <= q; i++) { string Str; int a, b; cin >> Str >> a; a--; if(Str=="toggle") { if(str[a]=='0') str[a] = '1'; else str[a] = '0'; operations[a].push({str[a]-48, i}); } else { int pos = 0; if(str[a]=='1') operations[a].push({0, i}); while(operations[a].size()) { int x, b; tie(x, b) = operations[a].front(); operations[a].pop(); if(x) { pos = b; } else { prev[a]+=b-pos; pos = i; } } if(str[a]=='1') operations[a].push({1, i}); cout << prev[a] << '\n'; cin >> a; } } }

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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:29:16: warning: unused variable 'b' [-Wunused-variable]
   29 |         int a, b;
      |                ^
#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...