Submission #00008
ソースコード
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 | #include<bits/stdc++.h> using namespace std; typedef pair< int , int > P; typedef pair<P, int > Pii; typedef pair<P,P> Pi; int n,m,k; vector< int > S[2][100010]; map<Pii, bool > used; int main(){ cin >> n >> m >> k; int flg = 0; for ( int i=0;i<k;i++){ int a,b; cin >> a >> b; a--; b--; if (a == 0 && b == 0) flg = 1; S[0][a].push_back(b); S[1][b].push_back(a); } priority_queue<Pi,vector<Pi>,greater<Pi> > que; que.push(Pi(P(0,0),P(0,0))); if (flg) que.push(Pi(P(1,1),P(0,0))); while (!que.empty()){ Pi p = que.top(); que.pop(); int cnt = p.first.first; int vec = p.first.second; int x = p.second.first; int y = p.second.second; if (used[Pii(P(x,y),vec)] != 0) continue ; used[Pii(P(x,y),vec)] = 1; if (vec == 0 && x == n-1) { cout << cnt+ abs ((m-1)-y) << endl; exit (0); } if (vec == 1 && y == m-1){ cout << cnt+ abs ((n-1)-x) << endl; exit (0); } if (vec){ for ( int i=0;i<S[vec][y].size();i++){ int next = S[vec][y][i]; que.push(Pi(P(cnt+ abs (next-x)+1,0),P(next,y))); } } else { for ( int i=0;i<S[vec][x].size();i++){ int next = S[vec][x][i]; que.push(Pi(P(cnt+ abs (next-y)+1,1),P(x,next))); } } } cout << "-1" << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 現代的な屋敷 |
ユーザー名 | ei1428 |
投稿日時 | 2015-12-22 13:56:09 |
言語 | C++11 |
状態 | Memory Limit Exceeded |
得点 | 20 |
ソースコード長 | 1302 Byte |
最大実行時間 | 1000 ms |
最大メモリ使用量 | 262144 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | INPUT1 | 0 / 20 | 01-* |
2 | INPUT2 | 0 / 10 | 02-* |
3 | INPUT3 | 20 / 20 | 03-* |
4 | INPUT4 | 0 / 30 | 04-* |
5 | INPUT5 | 0 / 20 | 05-* |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||||
---|---|---|---|---|---|---|---|---|
01-01.txt | MLE | 1000 ms | 262144 KB |
1
|
||||
01-02.txt | AC | 100 ms | 8784 KB |
1
|
||||
01-03.txt | AC | 181 ms | 13088 KB |
1
|
||||
01-04.txt | WA | 30 ms | 8828 KB |
1
|
||||
01-05.txt | AC | 85 ms | 12680 KB |
1
|
||||
02-01.txt | AC | 27 ms | 10028 KB |
2
|
||||
02-02.txt | AC | 23 ms | 10052 KB |
2
|
||||
02-03.txt | WA | 23 ms | 10060 KB |
2
|
||||
02-04.txt | AC | 28 ms | 10192 KB |
2
|
||||
02-05.txt | AC | 28 ms | 10184 KB |
2
|
||||
03-01.txt | AC | 28 ms | 9932 KB |
3
|
||||
03-02.txt | AC | 26 ms | 10304 KB |
3
|
||||
03-03.txt | AC | 20 ms | 10360 KB |
3
|
||||
03-04.txt | AC | 22 ms | 10372 KB |
3
|
||||
03-05.txt | AC | 33 ms | 10412 KB |
3
|
||||
04-01.txt | AC | 134 ms | 14400 KB |
4
|
||||
04-02.txt | AC | 138 ms | 18208 KB |
4
|
||||
04-03.txt | AC | 139 ms | 21448 KB |
4
|
||||
04-04.txt | TLE | 1000 ms | 69240 KB |
4
|
||||
04-05.txt | AC | 483 ms | 46660 KB |
4
|
||||
04-06.txt | AC | 219 ms | 33608 KB |
4
|
||||
04-07.txt | WA | 733 ms | 55908 KB |
4
|
||||
04-08.txt | AC | 542 ms | 56196 KB |
4
|
||||
05-01.txt | WA | 378 ms | 61968 KB |
5
|
||||
05-02.txt | WA | 519 ms | 64280 KB |
5
|
||||
05-03.txt | TLE | 1000 ms | 86660 KB |
5
|
||||
05-04.txt | AC | 200 ms | 45896 KB |
5
|
||||
05-05.txt | AC | 383 ms | 62212 KB |
5
|
||||
05-06.txt | AC | 199 ms | 52144 KB |
5
|
||||
05-07.txt | AC | 417 ms | 65412 KB |
5
|
||||
05-08.txt | AC | 166 ms | 51940 KB |
5
|