QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#136432#186. Street LampsWawi#20 91ms4196kbC++202.4kb2023-08-08 18:58:202024-07-04 01:25:22

Judging History

This is the latest submission verdict.

  • [2024-07-04 01:25:22]
  • Judged
  • Verdict: 20
  • Time: 91ms
  • Memory: 4196kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-08 18:58:20]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct item{
    int first=1,second=0,val=0;
};

void solve(){
    int n,q; cin >> n >> q;
    if(n<=100 && q<=100){
        vector<vector<int>> arr(q+1,vector<int>(n+1));
        for(int i=1; i <= n;i++){
            char c; cin >> c;
            arr[0][i]=c-'0';
        }
        vector<bool> changes(q+1);
        for(int i=1; i <=q;i++){
            string s; cin >> s;
            arr[i]=arr[i-1];
            if(s=="query"){
                int ans=0;
                int l,r; cin >> l >> r;
                for(int j=0; j <=i-1;j++){
                    for(int k=l; k <=r-1;k++){
                        if(arr[j][k]==0) break;
                        if(k==r-1) ans++;
                    }
                }
                cout << ans << endl;
            } else{
                int curr; cin >> curr;
                arr[i][curr]=!arr[i][curr];
            }
        }
    } else{
        vector<vector<int>> nums(n+1);
        vector<item> calced(n+1);
        for(int i=1; i <= n;i++){
            char c; cin >> c;
            nums[i].push_back(0);
            calced[i].second=c-'0';
        }
        for(int i=1; i <= q;i++){
            string s; cin >> s;
            if(s=="query"){
                int l,r; cin >> l >> r;
                int it=lower_bound(nums[l].begin(),nums[l].end(),calced[l].first)-nums[l].begin();
                bool ok=calced[l].second;
                for(int j=it ; j < nums[l].size();j++){
                    if(ok){
                        calced[l].val+=nums[l][j]-calced[l].first;
                        ok=false;
                        calced[l].first=nums[l][j];
                        calced[l].second=0;
                    }
                    else ok=true,calced[l].second=1,calced[l].first=nums[l][j]+1;
                }
                if(calced[l].second){
                    calced[l].val+=i-calced[l].first;
                }
                calced[l].first=i;
                cout << calced[l].val << endl;
            } else{
                int curr; cin >> curr;
                nums[curr].push_back(i);
            }
        }

        
        
    }
    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 3724kb

input:

5 7
11011
query 1 2
query 1 2
query 1 6
query 3 4
toggle 3
query 3 4
query 1 6

output:

1
2
0
0
1
2

result:

ok 6 lines

Test #2:

score: 20
Accepted
time: 1ms
memory: 3468kb

input:

5 50
01001
query 1 6
toggle 3
toggle 3
toggle 2
toggle 3
toggle 2
toggle 4
query 2 6
query 2 3
query 1 3
query 3 5
toggle 3
query 2 6
query 1 5
query 2 3
query 3 6
toggle 5
toggle 1
toggle 2
toggle 4
query 1 6
query 4 5
toggle 3
query 5 6
toggle 2
query 4 6
toggle 5
toggle 5
toggle 2
query 4 5
query...

output:

0
1
7
0
4
5
0
13
5
0
13
17
10
13
5
5
6
24
0
10
0
5
0
5
6

result:

ok 25 lines

Test #3:

score: 20
Accepted
time: 1ms
memory: 3576kb

input:

10 50
1111010011
toggle 3
toggle 1
toggle 5
toggle 5
toggle 7
query 7 10
query 6 8
query 6 8
toggle 7
toggle 4
toggle 4
toggle 3
toggle 8
toggle 8
toggle 3
query 4 6
query 1 4
toggle 10
query 4 8
query 4 11
toggle 8
toggle 7
query 6 8
toggle 6
query 3 8
toggle 5
toggle 3
toggle 7
toggle 4
query 2 11...

output:

0
2
3
1
1
0
0
5
0
0
0
2
9
0
1
18
30
19
10
1
0
0
0
18

result:

ok 24 lines

Test #4:

score: 20
Accepted
time: 1ms
memory: 3604kb

input:

20 100
01110011111110011110
toggle 16
query 1 13
toggle 2
query 9 21
toggle 8
toggle 7
query 2 5
toggle 18
query 18 21
query 9 11
query 3 5
query 13 20
query 9 10
toggle 4
query 5 21
query 5 19
query 1 15
query 19 21
toggle 16
query 6 21
query 8 21
toggle 14
toggle 19
toggle 1
query 8 11
toggle 13
t...

output:

0
0
3
0
10
11
0
13
0
0
0
0
0
0
5
28
0
34
0
36
0
23
0
0
8
40
0
0
0
0
10
11
5
0
0
0
2
0
0
0
0
38
0
0
37
46

result:

ok 46 lines

Test #5:

score: 20
Accepted
time: 1ms
memory: 3512kb

input:

100 100
1001001110110100110110100110000100100001111010111000011101010010010001101010101001100000111110000010
toggle 43
toggle 13
toggle 19
query 73 101
toggle 65
query 13 59
toggle 1
query 26 101
query 79 83
query 19 101
query 9 94
query 41 91
toggle 55
toggle 87
toggle 37
query 10 31
toggle 26
quer...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 51 lines

Test #6:

score: 20
Accepted
time: 1ms
memory: 3572kb

input:

100 100
0111010000111110011111000001101011010000000000111101011110010111011010010110111110111011101010010010
query 9 10
query 13 14
query 69 70
query 43 44
toggle 82
toggle 92
toggle 6
toggle 63
query 91 92
query 61 62
toggle 70
query 51 52
query 14 15
toggle 16
toggle 2
toggle 40
toggle 98
toggle 5...

output:

0
2
3
0
9
0
0
13
0
24
16
15
17
0
0
41
44
49
50
52
43
56
61
0
64
65
60
0
69
0
76
42
65
80
0
0
60
7
0
52
87
0
96
78
80

result:

ok 45 lines

Test #7:

score: 20
Accepted
time: 1ms
memory: 3728kb

input:

100 100
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
query 1 47
query 42 81
query 18 29
query 31 37
query 4 58
query 46 59
query 32 100
query 12 98
query 13 29
query 40 73
query 68 100
query 28 75
query 55 72
query 53 61
query 2 54
query 25 71
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #8:

score: 20
Accepted
time: 1ms
memory: 3576kb

input:

100 100
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
query 11 25
query 64 67
query 3 63
query 14 60
query 49 64
query 45 70
query 7 33
query 32 97
query 21 84
query 57 61
query 9 22
query 43 60
query 14 34
query 69 99
query 32 69
query 11 13
qu...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

result:

ok 100 lines

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 91ms
memory: 4196kb

input:

100 300000
1100100000000101010010100111010001100010001100111101000010111110001101101110100100100110101010110010
query 13 14
query 42 43
toggle 64
query 78 79
toggle 85
query 35 36
toggle 35
query 4 5
toggle 5
query 4 5
query 42 43
query 35 36
query 13 14
query 14 15
toggle 15
toggle 31
query 20 21
q...

output:

0
0
0
5
0
0
0
6
0
13
0
17
0
0
20
0
25
0
0
35
37
14
40
43
0
46
19
49
51
0
54
51
55
0
34
30
69
72
6
3
0
0
50
82
83
89
42
0
94
96
0
69
0
102
25
7
45
19
108
121
19
108
107
0
0
27
0
134
138
111
34
141
51
145
0
150
0
152
0
0
72
0
163
0
99
0
32
172
133
149
177
179
74
132
188
44
0
196
22
0
199
0
140
205
207...

result:

wrong answer 4th lines differ - expected: '6', found: '5'

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 1ms
memory: 3756kb

input:

1000 1003
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

151
66
53

result:

wrong answer 1st lines differ - expected: '0', found: '151'

Subtask #4:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 2ms
memory: 3656kb

input:

1000 1003
10111011001010101101100010101100100010100110001000000001001100111110101100110100010001111101101100110111110100011000111101100100000110110010101011101001101110111100010100100000110001010001111101001010100101011111010000001110111110001011010111101100000001001110101110011111000101101100011010...

output:

12
13
0
0
0
17
0
19
20
21
22
23
24
25
0
0
28
0
30
0
0
33
0
35
0
0
38
39
40
41
42
43
0
0
46
47
0
0
50
0
52
53
0
55
56
0
0
59
0
61
54
63
0
65
66
67
0
69
70
0
72
0
0
0
76
77
0
79
0
81
0
83
0
0
86
87
88
0
90
91
92
93
0
0
0
97
0
99
0
101
0
0
0
105
0
0
108
109
110
111
1
113
0
0
116
0
0
0
120
0
122
123
124...

result:

wrong answer 1st lines differ - expected: '0', found: '12'

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%