Submission #38271
ソースコード
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 | #include <bits/stdc++.h> using namespace std; void setUp ( int row, int op, bool mas[][4] ) { mas[row][op] = true ; mas[row][op + 1] = true ; mas[row + 1][op] = true ; mas[row + 1][op + 1] = true ; return ; } int main() { int H, N; bool mas[10005][4] = {}; int space[10005]; cin >> H >> N; for ( int i = 0; i < N; i++ ) { int x, y; cin >> x >> y; mas[H - y - 1][x] = true ; } space[H - 1] = 0; for ( int i = H - 1; i > 0; i-- ) { if ( !mas[i][0] && !mas[i][1] && !mas[i][2] && !mas[i][3] ) { space[i - 1] = space[i] + 1; } else { space[i - 1] = 0; } } int cnt = 0; for ( int i = 0; i < H - 1; i++ ) { bool d[4] = {}; for ( int j = 0; j < 4; j++ ) { d[j] = mas[i][j] | mas[i + 1][j]; } bool a, b, c; a = !d[0] && !d[1], b = !d[1] && !d[2], c = !d[2] && !d[3]; if ( !a && b && !c ) { if ( space[i] == 0 || space[i] % 2 == 1 ) { cnt++; //cout << i << " " << 1 << endl; setUp(i, 1, mas); } } else { if ( a ) { cnt++; //cout << i << " " << 0 << endl; setUp(i, 0, mas); } if ( c ) { cnt++; //cout << i << " " << 2 << endl; setUp(i, 2, mas); } } } cout << cnt << endl; return ( 0 ); } |
ステータス
項目 | データ |
---|---|
問題 | 0961 - 積み荷の配置 |
ユーザー名 | レインボーナウマン象 |
投稿日時 | 2018-07-05 18:42:02 |
言語 | C++ |
状態 | Accepted |
得点 | 11 |
ソースコード長 | 1577 Byte |
最大実行時間 | 35 ms |
最大メモリ使用量 | 852 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 11 / 11 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 24 ms | 604 KB |
1
|
in2.txt | AC | 23 ms | 524 KB |
1
|
in3.txt | AC | 23 ms | 660 KB |
1
|
in4.txt | AC | 31 ms | 596 KB |
1
|
in5.txt | AC | 19 ms | 656 KB |
1
|
in6.txt | AC | 17 ms | 712 KB |
1
|
in7.txt | AC | 17 ms | 768 KB |
1
|
in8.txt | AC | 20 ms | 696 KB |
1
|
in9.txt | AC | 20 ms | 744 KB |
1
|
in10.txt | AC | 21 ms | 400 KB |
1
|
in11.txt | AC | 26 ms | 448 KB |
1
|
in12.txt | AC | 21 ms | 500 KB |
1
|
in13.txt | AC | 22 ms | 680 KB |
1
|
in14.txt | AC | 22 ms | 604 KB |
1
|
in15.txt | AC | 21 ms | 504 KB |
1
|
in16.txt | AC | 16 ms | 532 KB |
1
|
in17.txt | AC | 30 ms | 556 KB |
1
|
in18.txt | AC | 20 ms | 448 KB |
1
|
in19.txt | AC | 23 ms | 496 KB |
1
|
in20.txt | AC | 15 ms | 576 KB |
1
|
in21.txt | AC | 26 ms | 624 KB |
1
|
in22.txt | AC | 26 ms | 648 KB |
1
|
in23.txt | AC | 22 ms | 676 KB |
1
|
in24.txt | AC | 20 ms | 704 KB |
1
|
in25.txt | AC | 14 ms | 724 KB |
1
|
in26.txt | AC | 20 ms | 772 KB |
1
|
in27.txt | AC | 18 ms | 824 KB |
1
|
in28.txt | AC | 35 ms | 852 KB |
1
|
in29.txt | AC | 29 ms | 628 KB |
1
|
in30.txt | AC | 32 ms | 588 KB |
1
|
in31.txt | AC | 24 ms | 488 KB |
1
|
in32.txt | AC | 21 ms | 544 KB |
1
|