ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#144162 | #10. 小x的城池 | loouwiit | 0 | 1422ms | 1272kb | C++ | 1.2kb | 2021-12-12 16:48:02 | 2021-12-12 16:48:04 |
answer
#include <iostream>
using namespace std;
int n, Q, i = 0, j = 0, end, Map[100000], Danger; //nQ:数量 Map人口
bool Road[100000], Level[100000], Save; //路的方向和等级;
int main() {
char P[10];
cin >> n >> Q;
for (i = 0; i < n; i++) {
cin >> Map[i] >> P;
if (P[0] == 'A') {
Level[i] = true;
} else {
Level[i] = false;
}
Road[i] = true;
}
for (; Q > 0; Q--) {
cin >> P;
if (P[0] == 'U') {
cin >> i ;
i--;
cin >> Map[i];
} else {
cin >> i >> end;
i--;
end--;
while (i < end) {
Road[i] = !Road[i];
i++;
}
}
//输出
for (i = 0, Danger = 0; i < n; i++) {
if (Level[i]) {
Save = true; //假定安全
for ( j = i - 1; j > 0; j--) { //左
if (Road[j] == true) {
break;
}
if (Level[j] == false && Map[j] > Map[i]) {
Save = false;
break;
}
}//左
for (j = i + 1; j < n - 1; j++) { //右
if (Road[j - 1] == false) {
break;
}
if (Level[j] == false && Map[j] > Map[i]) {
Save = false;
break;
}
}//右
if (!Save) {
Danger++;
}
}//B不判断
}
cout << Danger << endl;
}
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
7 5 0 A 32 B 10 B 27 B 25 A 30 B 10 A UPDATE 1 1 UPDATE 6 22 UPDATE 1 50 UPDATE 6 62 UPDATE 5 67
output:
2 1 0 2 1
result:
ok 5 number(s): "2 1 0 2 1"
Test #2:
score: -10
Wrong Answer
time: 0ms
memory: 1212kb
input:
10 20 38 A 0 B 2 A 20 A 2 B 31 A 0 B 68 A 53 A 74 B UPDATE 7 63 UPDATE 7 0 UPDATE 7 66 UPDATE 7 7 UP...
output:
4 0 4 1 4 4 4 4 4 4 1 4 1 1 4 4 4 1 4 4
result:
wrong answer 1st numbers differ - expected: '6', found: '4'
Subtask #2:
score: 0
Time Limit Exceeded
Test #16:
score: 35
Accepted
time: 1422ms
memory: 1272kb
input:
10000 10000 38 A 49 A 67 A 60 A 62 A 74 A 31 A 6 A 18 A 23 A 45 A 25 A 37 A 62 A 59 A 70 A 71 A 4 A ...
output:
8481 6987 5555 4171 3408 2277 3351 3046 2441 1321 1328 2040 1303 932 1371 1087 1094 1548 1548 925 15...
result:
ok 10000 numbers
Test #17:
score: -35
Time Limit Exceeded
input:
30000 30000 38 A 49 A 67 A 60 A 62 A 74 A 31 A 6 A 18 A 23 A 45 A 25 A 37 A 62 A 59 A 70 A 71 A 4 A ...
output:
26871 24611 15656 11163 15669 13968 12964 11293 11339 10586 10586 9096 10933 9996 8370 6666 4011 399...
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #26:
score: 0
Time Limit Exceeded
input:
30000 30000 38 A 49 A 67 A 60 A 62 A 74 A 31 A 6 A 18 A 23 A 45 A 25 A 37 A 62 A 59 A 70 A 71 A 4 A ...
output:
23611 23608 23608 23608 23343 23343 23343 23343 23343 23343 23608 23608 23608 23608 23608 23608 2172...
result:
Subtask #4:
score: 0
Skipped