Submission #267101

# Submission time Handle Problem Language Result Execution time Memory
267101 2020-08-15T20:03:48 Z kimbj0709 Street Lamps (APIO19_street_lamps) C++14
20 / 100
147 ms 15756 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 300050
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);
    vector<int> sum(maxn,0);
    vector<int> last(maxn,-1);
    for(int i=0;i<input.length();i++){
        if(input.at(i)=='1'){
            currpos[i+1] = 1;
            last[i+1] = 0;
        }
    }
    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;
                //last[input2] = i;
                sum[input2] += i-last[input2];
            }
            else{
                currpos[input2] = 1;
                last[input2] = i;
            }
        }
        else{
            cin >> input2 >> input3;
            input3--;
            int ans = sum[input2];
            if(currpos[input2]==1){
                ans += i-last[input2];
            }
            cout << ans << "\n";
        }
    }

}

Compilation message

street_lamps.cpp: In function 'int32_t main()':
street_lamps.cpp:15: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]
   15 |     for(int i=0;i<input.length();i++){
      |                 ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 83 ms 11512 KB Output is correct
2 Correct 88 ms 11896 KB Output is correct
3 Correct 96 ms 12412 KB Output is correct
4 Correct 126 ms 13704 KB Output is correct
5 Correct 130 ms 14220 KB Output is correct
6 Correct 119 ms 13452 KB Output is correct
7 Correct 135 ms 14348 KB Output is correct
8 Correct 147 ms 15756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -