Submission #267099

#TimeUsernameProblemLanguageResultExecution timeMemory
267099kimbj0709Street Lamps (APIO19_street_lamps)C++14
20 / 100
1 ms640 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define maxn 105 int32_t main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,q; cin >> n >> q; string input; cin >> input; vector<int> currpos(maxn,0); for(int i=0;i<input.length();i++){ if(input.at(i)=='1'){ currpos[i+1] = 1; } } int arr[maxn][maxn]; for(int i=1;i<=n;i++){ arr[0][i] = currpos[i]; arr[0][i] += arr[0][i-1]; //cout << arr[0][i] << " "; } //cout << endl; string input1; int input2,input3; for(int i=1;i<=q;i++){ cin >> input1; if(input1=="toggle"){ cin >> input2; if(currpos[input2]==1){ currpos[input2] = 0; } else{ currpos[input2] = 1; } for(int j=1;j<=n;j++){ arr[i][j] = currpos[j]; arr[i][j] += arr[i][j-1]; } } else{ cin >> input2 >> input3; input3--; int ans = 0; for(int j=0;j<i;j++){ ans += (arr[j][input3]-arr[j][input2-1]==input3-input2+1); } for(int j=1;j<=n;j++){ arr[i][j] = currpos[j]; arr[i][j] += arr[i][j-1]; } cout << ans << "\n"; } } }

Compilation message (stderr)

street_lamps.cpp: In function 'int32_t main()':
street_lamps.cpp:13:18: 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]
   13 |     for(int i=0;i<input.length();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...