Submission #983129

# Submission time Handle Problem Language Result Execution time Memory
983129 2024-05-15T08:32:10 Z vjudge1 Street Lamps (APIO19_street_lamps) C++17
40 / 100
80 ms 11132 KB
#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

int tt = 1, n;
string s;
int k[1001][1001];
int last[300005], kol[300005];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> tt;
    cin >> s;
    if(n <= 100 && tt <= 100){
        while(tt--){
            string type;
            cin >> type;
            for(int i = 1; i <= n; i++){
                for(int j = i + 1; j <= n + 1; j++){
                    if(s[j - 2] == '1') k[i][j]++;
                    else break;
                }
            }
            if(type[0] == 'q'){
                int a, b;
                cin >> a >> b;
                cout << k[a][b] << "\n";
            }
            else{
                int p;
                cin >> p;
                if(s[p - 1] == '0') s[p - 1] = '1';
                else s[p - 1] = '0';

            }
        }
        return 0;
    }
    for(int i = 1; i <= tt; i++){
        string type;
        cin >> type;
        if(type[0] == 'q'){
            int a, b;
            cin >> a >> b;
            int num = kol[a];
            if(s[a - 1] == '1') num += (i - last[a]);
            cout << num << "\n";
        }
        else{
            int p;
            cin >> p;
            if(s[p - 1] == '1'){
                kol[p] += (i - last[p]);
                last[p] = i;
                s[p - 1] = '0';
            }
            else{
                last[p] = i;
                s[p - 1] = '1';
            }
        }
    }
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2512 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 5184 KB Output is correct
2 Correct 66 ms 3492 KB Output is correct
3 Correct 56 ms 5200 KB Output is correct
4 Correct 63 ms 10832 KB Output is correct
5 Correct 67 ms 11132 KB Output is correct
6 Correct 69 ms 8784 KB Output is correct
7 Correct 77 ms 7396 KB Output is correct
8 Correct 80 ms 8640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2512 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 50 ms 5184 KB Output is correct
9 Correct 66 ms 3492 KB Output is correct
10 Correct 56 ms 5200 KB Output is correct
11 Correct 63 ms 10832 KB Output is correct
12 Correct 67 ms 11132 KB Output is correct
13 Correct 69 ms 8784 KB Output is correct
14 Correct 77 ms 7396 KB Output is correct
15 Correct 80 ms 8640 KB Output is correct
16 Incorrect 1 ms 2396 KB Output isn't correct
17 Halted 0 ms 0 KB -