제출 #568856

#제출 시각아이디문제언어결과실행 시간메모리
568856almothana05가로등 (APIO19_street_lamps)C++14
40 / 100
748 ms13268 KiB
#include<bits/stdc++.h> #define mod 1000000007 #define inf 10000000000000000 using namespace std; vector<int>num[200] , comp[3]; int main(){ // ios_base::sync_with_stdio(false); // cin.tie(NULL); string s; int menge , numm , nummer , ed , cmp , que ;; cin >> menge >> que; cin >> s; num[0].push_back(0); for(int i = 0 ; i < menge ; i++){ num[0].push_back(num[0][i] + s[i] - '0'); } if(menge <= 100 && que <= 100){ for(int k = 0 ; k < que ; k++){ string t; cin >> t >> numm; if(t == "query"){ cin >> nummer; numm--; nummer--; int erg = 0; for(int i = k ; i >= 0 ; i--){ erg += (num[i][nummer] - num[i][numm]) / (nummer - numm); // cout << erg << ' '; } cout << erg << "\n"; for(int i = 0 ; i <= menge ; i++){ num[k + 1].push_back(num[k][i]); } } else{ // cout << s[numm - 1] << "\n"; if(s[numm - 1] == '0'){ s[numm - 1] = '1'; } else{ s[numm - 1] = '0'; } // cout << s[numm - 1]<< "\n"; num[k + 1].push_back(0); for(int i = 0 ; i < menge ; i++){ num[k + 1].push_back(num[k + 1][i] + s[i] - '0'); // cout << num[k + 1][i]<< ' '; } // cout << "\n"; } } return 0; } for(int i = 0 ; i < menge; i++){ comp[0].push_back(0); comp[1].push_back(s[i] - '0'); comp[2].push_back(0); } for(int k = 1 ; k <= que ; k++){ string t; cin >> t >> numm; if(t == "query"){ cin >> nummer; nummer--; numm--; if(comp[1][numm] == 1){ cout << comp[0][numm] + (k - comp[2][numm]) << "\n"; } else{ cout << comp[0][numm] << "\n"; } } else{ numm--; if(comp[1][numm] == 1){ comp[0][numm] += k - comp[2][numm] ; comp[1][numm] ^= 1; } else{ comp[1][numm] ^= 1; comp[2][numm] = k; } // cout << comp[0][numm] << ' ' << comp[1][numm] << ' '<< comp[2][numm] << "\n"; } } }

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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:10:32: warning: unused variable 'ed' [-Wunused-variable]
   10 |    int menge , numm , nummer , ed , cmp , que ;;
      |                                ^~
street_lamps.cpp:10:37: warning: unused variable 'cmp' [-Wunused-variable]
   10 |    int menge , numm , nummer , ed , cmp , que ;;
      |                                     ^~~
#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...