Submission #716528

#TimeUsernameProblemLanguageResultExecution timeMemory
7165281zaid1Street Lamps (APIO19_street_lamps)C++17
20 / 100
109 ms3956 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' const signed M = 1e4, MOD = 998244353; bitset<101> bt[M]; signed main() { cin.tie(0)->sync_with_stdio(0); int n, q; cin >> n >> q; string s; cin >> s; for (int i = 0; i < s.size(); i++) bt[i+1][0] = s[i] == '1'; for (int i = 0; i < q; i++) { string s; cin >> s; if (s == "query") { int l, r; cin >> l >> r; bitset<101> b = bt[l]; for (int j = l; j < r; j++) b &= bt[j]; cout << b.count() << endl; // cout << b << endl; } for (int j = 1; j <= n; j++) bt[j][i+1] = bt[j][i]; if (s == "toggle") { int x; cin >> x; bt[x][i+1] = !bt[x][i+1]; } } // for (int i = 1; i <= n; i++){ // for (int j = 0; j < q; j++) cout << bt[i][j]; cout << endl; // } return 0; } /* 5 7 11011 query 1 2 query 1 2 query 1 6 query 3 4 toggle 3 query 3 4 query 1 6 */

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:18:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < s.size(); i++) bt[i+1][0] = s[i] == '1';
      |                     ~~^~~~~~~~~~
#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...