Submission #00032


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
stack<P> sta;
int n;
cin >> n;
int ret = 0;
for(int i=1;i<=n;i++){
int a; cin >> a;
if(i == 1) {
sta.push(P(1,a));
if(a == 0) ret++;
}
else {
P p = sta.top(); sta.pop();
int cnt = p.first;
int num = p.second;
if(i%2 == 1){
if(a == num){
if(a == 0) ret++;
sta.push(P(cnt+1,num));
}
else {
if(a == 0) ret++;
sta.push(P(cnt,num));
sta.push(P(1,a));
}
}
else {
if(a == 1 && num == 0){
ret -= cnt;
}
if(a == 0 && num == 1){
ret += cnt;
}
if(a == 0) ret++;
sta.push(P(cnt+1,a));
}
}
}
cout << ret << endl;
}

ステータス

項目 データ
問題 0001 - 碁石ならべ
ユーザー名 ei1428
投稿日時 2016-02-09 17:21:40
言語 C++11
状態 Wrong Answer
得点 20
ソースコード長 748 Byte
最大実行時間 26 ms
最大メモリ使用量 680 KB

セット

セット 得点 Cases
1 INPUT1 0 / 10 *in01
2 INPUT2 0 / 10 *in02
3 INPUT3 0 / 10 *in03
4 INPUT4 0 / 10 *in04
5 INPUT5 10 / 10 *in05
6 INPUT6 10 / 10 *in06
7 INPUT7 0 / 10 *in07
8 INPUT8 0 / 10 *in08
9 INPUT9 0 / 10 *in09
10 INPUT10 0 / 10 *in10

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
2008-ho-t1-in01 WA 17 ms 476 KB
1
2008-ho-t1-in02 WA 10 ms 452 KB
2
2008-ho-t1-in03 WA 13 ms 424 KB
3
2008-ho-t1-in04 WA 12 ms 396 KB
4
2008-ho-t1-in05 AC 12 ms 472 KB
5
2008-ho-t1-in06 AC 17 ms 452 KB
6
2008-ho-t1-in07 WA 24 ms 680 KB
7
2008-ho-t1-in08 WA 22 ms 576 KB
8
2008-ho-t1-in09 WA 26 ms 548 KB
9
2008-ho-t1-in10 WA 25 ms 636 KB
10