Submission #00109
ソースコード
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | #include<bits/stdc++.h> using namespace std; #define int long long typedef pair< long long , long long > P; vector< long long > x,y; queue<P>que; main(){ ios_base::sync_with_stdio( false ); int h,w,q; long long n; int dx[]={0,1,-1,0}; int dy[]={1,0,0,-1}; cin >> h >> w >> n >> q; int xs[2][n+1],ys[2][n+1]; for ( int i=0;i<n;i++){ cin >> xs[0][i] >>ys[0][i] >> xs[1][i] >> ys[1][i]; x.push_back(xs[0][i]); y.push_back(ys[0][i]); for ( int j=0;j<4;j++){ int nx = xs[0][i]+dx[j]; int ny = ys[0][i]+dy[j]; if (nx >= 0 && nx < w && ny >= 0 && ny < h){ x.push_back(nx); y.push_back(ny); } } x.push_back(xs[1][i]); y.push_back(ys[1][i]); for ( int j=0;j<4;j++){ int nx = xs[1][i]+dx[j]; int ny = ys[1][i]+dy[j]; if (nx >= 0 && nx < w && ny >= 0 && ny < h){ x.push_back(nx); y.push_back(ny); } } } sort(x.begin(),x.end()); x.erase( unique(x.begin(),x.end()), x.end() ); sort(y.begin(),y.end()); y.erase( unique(y.begin(),y.end()), y.end() ); long long maze[y.size()+5][x.size()+5]; for ( int i=0;i<=y.size();i++){ for ( int j=0;j<=x.size();j++){ maze[i][j] = 0; } } for ( int i=0;i<n;i++){ if (xs[0][i] == xs[1][i]){ int first = find(y.begin(),y.end(), ys[0][i])-y.begin(); int end = find(y.begin(),y.end(), ys[1][i])-y.begin(); int rock = find(x.begin(),x.end(), xs[0][i])-x.begin(); for ( int j=first;j < y.size() && j<=end;j++){ maze[j][rock] = -1; } } else { int first = find(x.begin(),x.end(), xs[0][i])-x.begin(); int end = find(x.begin(),x.end(), xs[1][i])-x.begin(); int rock = find(y.begin(),y.end(), ys[0][i])-y.begin(); for ( int j=first;j < x.size() && j<=end;j++){ maze[rock][j] = -1; } } } //幅 long long color = 0; for ( int i=0;i<y.size();i++){ for ( int j=0;j<x.size();j++){ if (maze[i][j] == 0){ color++; que.push(P(i,j)); //y x maze[i][j] = color; while (!que.empty()){ P now = que.front(); que.pop(); int xx = now.second; int yy = now.first; for ( int k=0;k<4;k++){ int nx = xx+dx[k]; int ny = yy+dy[k]; if (nx >= 0 && nx < x.size() && ny >= 0 && ny < y.size() && maze[ny][nx] == 0){ maze[ny][nx] = color; que.push(P(ny,nx)); } } } } } } for ( int cas=0;cas<q;cas++){ int a,b,c,d; int temp[4]; for ( int i=0;i<4;i++){ temp[i] = -1; } P sx,sy,gx,gy; sx.second = gx.second = x.size()-1; sy.second = gy.second = y.size()-1; cin >> a >> b >> c >> d; for ( int j=0;j<x.size();j++){ if (x[j] <= a){ sx.first = j; if (x[j] == a){ temp[0] = j; } } else if (sx.second == x.size()-1){ sx.second = j; } if (x[j] <= c){ gx.first = j; if (x[j] == c){ temp[2] = j; } } else if (gx.second == x.size()-1){ gx.second = j; } } for ( int j=0;j<y.size();j++){ if (y[j] <= b){ sy.first = j; if (y[j] == b){ temp[1] = j; } } else if (sy.second == y.size()-1){ sy.second = j; } if (y[j] <= d){ gy.first = j; if (y[j] == d){ temp[3] = j; } } else if (gy.second == y.size()-1){ gy.second = j; } } int data[2][2]={}; bool flag = false ; if (temp[0] != -1){ sx.second = sx.first; } if (temp[1] != -1){ sy.second = sy.first; } if (temp[2] != -1){ gx.second = gx.first; } if (temp[3] != -1){ gy.second = gy.first; } if (maze[sy.first][sx.first] != -1){ data[0][0] = sx.first; data[0][1] = sy.first; } else if (maze[sy.first][sx.second] != -1){ data[0][0] = sx.second; data[0][1] = sy.first; } else if (maze[sy.second][sx.first] != -1){ data[0][0] = sx.first; data[0][1] = sy.second; } else if (maze[sy.second][sx.second] != -1){ data[0][0] = sx.second; data[0][1] = sy.second; } else { flag = true ; } if (maze[gy.first][gx.first] != -1){ data[1][0] = gx.first; data[1][1] = gy.first; } else if (maze[gy.first][gx.second] != -1){ data[1][0] = gx.second; data[1][1] = gy.first; } else if (maze[gy.second][gx.first] != -1){ data[1][0] = gx.first; data[1][1] = gy.second; } else if (maze[gy.second][gx.second] != -1){ data[1][0] = gx.second; data[1][1] = gy.second; } else { flag = true ; } if (flag) cout << "Broadcasting accident" << endl; else if (maze[data[0][1]][data[0][0]] == maze[data[1][1]][data[1][0]]) cout << "Success" << endl; else cout << "Broadcasting accident" << endl; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0005 - 回れ雛月花 -Lunatic |
ユーザー名 | ei1612 |
投稿日時 | 2017-12-22 16:14:48 |
言語 | C++11 |
状態 | Runtime Error |
得点 | 35 |
ソースコード長 | 4887 Byte |
最大実行時間 | 144 ms |
最大メモリ使用量 | 14088 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | Burn | 35 / 35 | Input0* , Input10 |
2 | Out | 0 / 140 | Input[0-2]* , Input30 |
3 | Misfortune | 0 / 175 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||
---|---|---|---|---|---|---|
Input01 | AC | 17 ms | 480 KB |
1
|
2
|
3
|
Input02 | AC | 16 ms | 684 KB |
1
|
2
|
3
|
Input03 | AC | 20 ms | 500 KB |
1
|
2
|
3
|
Input04 | AC | 17 ms | 576 KB |
1
|
2
|
3
|
Input05 | AC | 22 ms | 580 KB |
1
|
2
|
3
|
Input06 | AC | 17 ms | 664 KB |
1
|
2
|
3
|
Input07 | AC | 17 ms | 728 KB |
1
|
2
|
3
|
Input08 | AC | 27 ms | 652 KB |
1
|
2
|
3
|
Input09 | AC | 28 ms | 604 KB |
1
|
2
|
3
|
Input10 | AC | 22 ms | 644 KB |
1
|
2
|
3
|
Input11 | RE | 128 ms | 692 KB |
2
|
3
|
|
Input12 | AC | 21 ms | 2100 KB |
2
|
3
|
|
Input13 | AC | 37 ms | 11816 KB |
2
|
3
|
|
Input14 | AC | 30 ms | 1260 KB |
2
|
3
|
|
Input15 | AC | 46 ms | 11808 KB |
2
|
3
|
|
Input16 | AC | 24 ms | 5860 KB |
2
|
3
|
|
Input17 | AC | 48 ms | 12656 KB |
2
|
3
|
|
Input18 | AC | 16 ms | 888 KB |
2
|
3
|
|
Input19 | AC | 41 ms | 10064 KB |
2
|
3
|
|
Input20 | AC | 18 ms | 968 KB |
2
|
3
|
|
Input21 | AC | 23 ms | 2604 KB |
2
|
3
|
|
Input22 | AC | 17 ms | 704 KB |
2
|
3
|
|
Input23 | AC | 27 ms | 3828 KB |
2
|
3
|
|
Input24 | AC | 22 ms | 704 KB |
2
|
3
|
|
Input25 | AC | 22 ms | 1732 KB |
2
|
3
|
|
Input26 | AC | 32 ms | 6524 KB |
2
|
3
|
|
Input27 | RE | 24 ms | 748 KB |
2
|
3
|
|
Input28 | AC | 25 ms | 2276 KB |
2
|
3
|
|
Input29 | AC | 38 ms | 11696 KB |
2
|
3
|
|
Input30 | AC | 33 ms | 6104 KB |
2
|
3
|
|
Input31 | AC | 44 ms | 2148 KB |
3
|
||
Input32 | AC | 100 ms | 7596 KB |
3
|
||
Input33 | AC | 48 ms | 12424 KB |
3
|
||
Input34 | AC | 144 ms | 14088 KB |
3
|
||
Input35 | AC | 31 ms | 1444 KB |
3
|
||
Input36 | AC | 66 ms | 5236 KB |
3
|
||
Input37 | AC | 122 ms | 12216 KB |
3
|
||
Input38 | AC | 25 ms | 1616 KB |
3
|
||
Input39 | AC | 65 ms | 3972 KB |
3
|
||
Input40 | AC | 61 ms | 5056 KB |
3
|
||
Input41 | RE | 24 ms | 2000 KB |
3
|
||
Input42 | RE | 25 ms | 2124 KB |
3
|
||
Input43 | RE | 22 ms | 1992 KB |
3
|
||
Input44 | RE | 30 ms | 1860 KB |
3
|
||
Input45 | RE | 25 ms | 1860 KB |
3
|
||
Input46 | RE | 25 ms | 1856 KB |
3
|
||
Input47 | RE | 26 ms | 1860 KB |
3
|
||
Input48 | RE | 26 ms | 1988 KB |
3
|
||
Input49 | RE | 32 ms | 1860 KB |
3
|
||
Input50 | RE | 27 ms | 1984 KB |
3
|