QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#136442#186. Street LampsWawi#20 156ms24344kbC++201.5kb2023-08-08 19:27:592024-07-04 01:25:23

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:25:23]
  • 评测
  • 测评结果:20
  • 用时:156ms
  • 内存:24344kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-08 19:27:59]
  • 提交

answer

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

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

void solve(){
    int n,q; cin >> n >> q;
    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;
            bool ok=calced[l].second;
            // if(calced[l].first==nums[l][calced[l].last]) calced[l].last++;
            for(int j=calced[l].last+1; 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;
                    calced[l].last=j;
                }
                else ok=true,calced[l].second=1,calced[l].first=nums[l][j],calced[l].last=j;
            }
            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: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3776kb

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
3
0
1
7

result:

wrong answer 3rd lines differ - expected: '0', found: '3'

Subtask #2:

score: 20
Accepted

Test #9:

score: 20
Accepted
time: 76ms
memory: 4264kb

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
6
0
0
0
7
0
14
0
18
0
0
21
0
26
0
0
36
38
15
41
44
0
47
20
50
52
0
55
52
56
0
35
31
70
73
7
4
0
0
51
83
84
90
44
0
95
97
0
70
0
103
26
8
46
20
109
122
20
109
108
0
0
28
0
135
139
112
35
142
53
146
0
151
0
153
0
0
73
0
164
0
100
0
33
173
135
151
178
180
75
133
189
46
0
197
23
0
200
0
141
206
20...

result:

ok 150010 lines

Test #10:

score: 0
Accepted
time: 91ms
memory: 4352kb

input:

300 300000
0000110011011101000000010110111010000011000110111111110000110101001100010001010111101111110101100110101111100110110110100000101000001001010110001111100110101100011101011010100111011100111100001011010011000101011101000101010010011001100101000011110000000101000001001101001011110101000100110...

output:

0
0
0
10
0
0
14
0
0
0
22
29
31
0
35
31
0
40
41
0
44
0
0
0
51
20
61
62
37
65
0
0
73
76
63
0
81
5
0
85
87
89
0
0
0
0
0
0
0
100
0
0
21
68
0
111
0
0
117
0
68
0
123
68
125
0
128
0
130
131
0
0
0
137
139
140
142
143
0
147
0
152
154
0
163
0
0
167
0
82
172
174
0
0
177
0
0
0
146
189
0
71
144
0
205
192
154
59
...

result:

ok 149998 lines

Test #11:

score: 0
Accepted
time: 100ms
memory: 4828kb

input:

5000 300000
011100011011111101000001011111000101101001000111000101111010100100000100000000000100000100011100001101011000000000000010110011101101011011100100010001011001101101000000111000011101100010001001011000010001101111000001011110110010111001100100111001011101001010101011011110110110111011000100...

output:

0
0
3
0
0
6
7
0
10
18
19
24
0
0
28
0
30
0
33
0
0
41
0
47
0
0
0
0
56
0
62
63
64
65
66
0
71
0
76
80
0
87
0
90
95
0
0
0
102
103
104
108
111
113
0
0
0
121
0
125
0
0
0
130
131
0
0
0
0
144
0
146
0
149
150
152
153
0
0
0
0
162
0
0
169
0
0
0
180
181
182
183
0
185
187
0
0
0
0
0
202
0
0
0
0
0
217
132
0
0
223
2...

result:

ok 149970 lines

Test #12:

score: 0
Accepted
time: 111ms
memory: 24276kb

input:

300000 300000
0111110110110011001010010000010111110110100110011000001000101101101101111111010001011100000110100100001111011001011010000010001110000000111010111000111101011010011001100100011010011001011010011110101011101110101111001100000101100111001001000111001010100110110000111110101101110110101000...

output:

0
0
4
5
6
0
8
0
0
0
0
0
0
20
22
0
25
0
27
29
32
0
38
39
40
42
45
0
0
0
54
56
0
0
0
0
0
0
0
0
0
71
72
0
0
75
76
77
78
0
87
0
93
95
97
101
106
107
0
0
0
116
0
119
0
122
123
128
0
0
0
134
137
138
0
0
151
0
0
156
0
0
166
0
170
172
174
175
0
0
179
0
185
187
0
0
200
0
202
203
209
0
220
223
224
225
0
227
2...

result:

ok 150040 lines

Test #13:

score: 0
Accepted
time: 156ms
memory: 24196kb

input:

300000 300000
0001011000111110101111101011010010111100001111001001100111101011101111100100110100001011111101111001000101101010010100101111111000110010111110100011111111000110101001101111110011111110111010111000111111101101111011100110110010011101101011001000011001101101111001110011001111110000100101...

output:

0
0
6
7
10
11
12
14
16
18
21
22
24
27
29
0
0
0
0
0
40
42
43
0
0
0
49
51
52
53
0
56
58
0
0
65
66
0
0
0
71
73
0
0
0
80
81
82
83
85
0
88
0
90
92
0
0
96
0
102
103
104
106
0
0
0
112
115
116
117
0
0
0
0
0
0
0
0
0
0
132
0
134
0
0
0
139
140
0
0
143
0
147
148
149
152
0
0
155
156
0
158
0
161
163
0
0
173
174
0...

result:

ok 180163 lines

Test #14:

score: 0
Accepted
time: 104ms
memory: 24344kb

input:

300000 300000
1110000101000110011100101101100010001011100111010011000101100010011010001011011101100100111001000010110110111110110000001001111111101111101111111101000010010111011110101001011001100110100010010010011011000110100001101011001111011111110101001011110100111101101000001100101101001110100100...

output:

0
179731
123392
179733
179734
0
14836
179737
100879
179739
179740
0
123220
892
18836
0
179746
0
146118
179749
179750
35814
0
163124
0
0
51586
179757
144293
179759
2250
179761
128614
134845
179764
81056
19864
75349
0
0
0
128365
112124
179773
179774
0
179776
71581
103861
179779
179780
73519
161720
179...

result:

ok 120271 lines

Test #15:

score: 0
Accepted
time: 146ms
memory: 24256kb

input:

300000 300000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

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
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 300000 lines

Test #16:

score: 0
Accepted
time: 135ms
memory: 24148kb

input:

300000 300000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

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
101
102
...

result:

ok 300000 lines

Subtask #3:

score: 0
Wrong Answer

Test #17:

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

input:

1000 1003
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

152
67
54

result:

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

Subtask #4:

score: 0
Wrong Answer

Test #30:

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

input:

1000 1003
10111011001010101101100010101100100010100110001000000001001100111110101100110100010001111101101100110111110100011000111101100100000110110010101011101001101110111100010100100000110001010001111101001010100101011111010000001110111110001011010111101100000001001110101110011111000101101100011010...

output:

13
14
0
0
0
18
0
20
21
22
23
24
25
26
0
0
29
0
31
0
0
34
0
36
0
0
39
40
41
42
43
44
0
0
47
48
0
0
51
0
53
54
0
56
57
0
0
60
0
62
55
64
0
66
67
68
0
70
71
0
73
0
0
0
77
78
0
80
0
82
0
84
0
0
87
88
89
0
91
92
93
94
0
0
0
98
0
100
0
102
0
0
0
106
0
0
109
110
111
112
2
114
0
0
117
0
0
0
121
0
123
124
12...

result:

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

Subtask #5:

score: 0
Skipped

Dependency #1:

0%