Submission #683267

# Submission time Handle Problem Language Result Execution time Memory
683267 2023-01-18T05:19:34 Z Nursik Street Lamps (APIO19_street_lamps) C++14
40 / 100
138 ms 75124 KB
#include <stdio.h>
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
 
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ld long double
#define bug cout << "bug\n";

const ll maxn = 1e6 + 1, maxm = 2e2 + 1;
const ll mod = 1e9 + 7, inf = 1e9, block = 550, hb = 126067, base = 1000050017,
         biginf = 5e18;
const ld eps = 1e-15;
using namespace std;

int subtask1 = 1;
int subtask2 = 1;
int n, q;
string s[maxn], query[maxn];
int l[maxn], r[maxn], x[maxn];
int last[maxn], answ[maxn];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> q;
    cin >> s[0];
    for (int i = 1; i <= q; ++i){
        cin >> query[i];
        if (query[i] == "query"){
            cin >> l[i] >> r[i];
            subtask2 &= (r[i] - l[i] == 1);
        }
        else{
            cin >> x[i];
        }
    }
    subtask1 &= (n <= 100 && q <= 100);
    if (subtask1){
    s[1] = s[0];
    for (int i = 1; i <= q; ++i){
       // cout << i << " " << s[i] << '\n';
        if (query[i] == "query"){
            int ans = 0;
            for (int j = i; j >= 1; --j){
                int ok = 1;
                for (int k = l[i]; k <= r[i] - 1; ++k){
                    ok &= (s[j][k - 1] == '1');
                }
                if (ok){
                    ans += 1;
                }
            }
            cout << ans << '\n';
            s[i + 1] = s[i];
        }
        else{
            s[i + 1] = s[i];
            if (s[i + 1][x[i] - 1] == '1'){
                s[i + 1][x[i] - 1] = '0';
            }
            else{
                s[i + 1][x[i] - 1] = '1';
            }
        }
    }
    exit(0);
    }
    if (subtask2){
        for (int i = 0; i < n; ++i){
            last[i] = -1;
            if (s[0][i] == '1'){
                last[i] = 0;
            }
        }
        for (int i = 1; i <= q; ++i){
            if (query[i] == "query"){
                if (s[0][l[i] - 1] == '0'){
                    cout << answ[l[i] - 1] << '\n';
                }
                else{
                    cout << answ[l[i] - 1] + i - last[l[i] - 1] << '\n';
                }
            }
            else{
                if (s[0][x[i] - 1] == '0'){
                    last[x[i] - 1] = i;
                    s[0][x[i] - 1] = '1';
                }
                else{
                    answ[x[i] - 1] += i - last[x[i] - 1];
                    s[0][x[i] - 1] = '0';
                }
            }
        }
    }
}
/*
 */



# Verdict Execution time Memory Grader output
1 Correct 28 ms 62968 KB Output is correct
2 Correct 32 ms 62904 KB Output is correct
3 Correct 28 ms 62876 KB Output is correct
4 Correct 31 ms 62932 KB Output is correct
5 Correct 27 ms 62888 KB Output is correct
6 Correct 29 ms 62860 KB Output is correct
7 Correct 29 ms 62876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 70528 KB Output is correct
2 Correct 100 ms 70844 KB Output is correct
3 Correct 106 ms 71360 KB Output is correct
4 Correct 138 ms 75124 KB Output is correct
5 Correct 118 ms 74336 KB Output is correct
6 Correct 135 ms 72896 KB Output is correct
7 Correct 122 ms 73452 KB Output is correct
8 Correct 135 ms 74824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 62932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 62964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 62968 KB Output is correct
2 Correct 32 ms 62904 KB Output is correct
3 Correct 28 ms 62876 KB Output is correct
4 Correct 31 ms 62932 KB Output is correct
5 Correct 27 ms 62888 KB Output is correct
6 Correct 29 ms 62860 KB Output is correct
7 Correct 29 ms 62876 KB Output is correct
8 Correct 95 ms 70528 KB Output is correct
9 Correct 100 ms 70844 KB Output is correct
10 Correct 106 ms 71360 KB Output is correct
11 Correct 138 ms 75124 KB Output is correct
12 Correct 118 ms 74336 KB Output is correct
13 Correct 135 ms 72896 KB Output is correct
14 Correct 122 ms 73452 KB Output is correct
15 Correct 135 ms 74824 KB Output is correct
16 Incorrect 31 ms 62932 KB Output isn't correct
17 Halted 0 ms 0 KB -