#include <bits/stdc++.h>
using std::cin, std::cout, std::vector, std::set, std::endl, std::string, std::map,std::pair,std::queue;
#ifdef LOCAL
#define file freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#else
#define file ;;
#endif
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using Tree = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include <random>
int main(){
file;
int n,q;
cin >> n >> q;
string s;
cin >> s;
vector<vector<int>> hist(n+1,vector<int>(1,0));
for(int i=1;i<=q;i++){
string ty;
cin >> ty;
if(ty[0]=='q'){
int a,b;
cin >> a >> b;
--a;
--b;
int ans = (((s[a]=='1' && hist[a].size()%2==1) || (s[a]=='0' && hist[a].size()%2==0)) ? i-hist[a].back():0);
for(int i=(s[a]=='0')+1;i<hist[a].size();i+=2){
ans+=hist[a][i]-hist[a][i-1];
}
cout << ans << endl;
}
else if(ty[0]=='t'){
int a;
cin >> a;
hist[a-1].push_back(i);
}
}
return 0;
}
Compilation message
street_lamps.cpp: In function 'int main()':
street_lamps.cpp:34:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i=(s[a]=='0')+1;i<hist[a].size();i+=2){
| ~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
245 ms |
3924 KB |
Output is correct |
2 |
Correct |
231 ms |
4180 KB |
Output is correct |
3 |
Correct |
244 ms |
4948 KB |
Output is correct |
4 |
Correct |
294 ms |
20716 KB |
Output is correct |
5 |
Correct |
326 ms |
20976 KB |
Output is correct |
6 |
Correct |
236 ms |
20452 KB |
Output is correct |
7 |
Correct |
427 ms |
21232 KB |
Output is correct |
8 |
Correct |
462 ms |
22256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |