Submission #267100

# Submission time Handle Problem Language Result Execution time Memory
267100 2020-08-15T20:03:35 Z kimbj0709 Street Lamps (APIO19_street_lamps) C++14
20 / 100
2 ms 640 KB
#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

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 time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Runtime error 1 ms 640 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -