Submission #1031912

#TimeUsernameProblemLanguageResultExecution timeMemory
1031912KasymKStreet Lamps (APIO19_street_lamps)C++17
20 / 100
1426 ms4592 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int MOD = 1e9+7; const int N = 1e2+5; int par[N], ans[N][N]; int main(){ // freopen("file.txt", "r", stdin); int n, q; scanf("%d%d", &n, &q); string s; cin >> s; for(int i = 0; i < n; ++i) par[i+1] = par[i]+(s[i]-'0'); for(int i = 0; i < n; ++i) for(int j = i+1; j <= n; ++j) ans[i][j] = (par[j]-par[i] == j-i); while(q--){ string t; cin >> t; if (t == "query"){ int a, b; scanf("%d%d", &a, &b), a--, b--; printf("%d\n", ans[a][b]); } else{ int i; scanf("%d", &i), i--; s[i] = (s[i] == '0' ? '1' : '0'); } par[0] = 0; for(int i = 0; i < n; ++i) par[i+1] = par[i]+(s[i]-'0'); for(int i = 0; i < n; ++i) for(int j = i+1; j <= n; ++j) ans[i][j] += (par[j]-par[i] == j-i); } return 0; }

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d%d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:31:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |    scanf("%d%d", &a, &b), a--, b--;
      |    ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:36:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |    scanf("%d", &i), i--;
      |    ~~~~~^~~~~~~~~~
#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...