Submission #00102
ソースコード
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 | #include<bits/stdc++.h> using namespace std; long long int n,x[1000],p[1000]; set< int > w; int dfs1( int now); int dfs2( int now); int main(){ long long int i; scanf ( "%lld" ,&n); for (i=0;i<n;i++){ scanf ( "%lld %lld" ,&p[i],&x[i]); } for (i=0;i<n;i++){ int ans=0; if (i==0)ans=1; if (i==n-1)ans=10; if (i>0){ w.insert(i); ans+=dfs1(i); w.clear(); } if (i<n-1){ w.insert(i); ans+=dfs2(i)*10; w.clear(); } if (ans==0) printf ( "X" ); if (ans==1) printf ( "L" ); if (ans==10) printf ( "R" ); if (ans==11) printf ( "O" ); } printf ( "\n" ); return (0); } int dfs1( int now){ int i; if (now==0) return (1); for (i=0;i<n;i++){ if ( abs (( int )(x[now]-x[i]))<=p[now]&&w.find(i)==w.end()){ w.insert(i); if (dfs1(i)) return (1); w.erase(i); } } return (0); } int dfs2( int now){ int i; if (now==n-1) return (1); for (i=n-1;i>=0;i--){ if ( abs (( int )(x[i]-x[now]))<=p[now]&&w.find(i)==w.end()){ w.insert(i); if (dfs2(i)) return (1); w.insert(i); } } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 想起「貪欲だった六番目」 |
ユーザー名 | ei1620 |
投稿日時 | 2017-12-22 16:01:53 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1127 Byte |
最大実行時間 | 70 ms |
最大メモリ使用量 | 816 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 250 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
Input01 | WA | 20 ms | 480 KB |
1
|
Input02 | WA | 25 ms | 444 KB |
1
|
Input03 | WA | 14 ms | 536 KB |
1
|
Input04 | WA | 18 ms | 496 KB |
1
|
Input05 | WA | 21 ms | 584 KB |
1
|
Input06 | WA | 15 ms | 416 KB |
1
|
Input07 | WA | 14 ms | 508 KB |
1
|
Input08 | WA | 15 ms | 468 KB |
1
|
Input09 | WA | 17 ms | 560 KB |
1
|
Input10 | WA | 18 ms | 640 KB |
1
|
Input11 | WA | 16 ms | 472 KB |
1
|
Input12 | WA | 16 ms | 680 KB |
1
|
Input13 | WA | 30 ms | 632 KB |
1
|
Input14 | WA | 23 ms | 456 KB |
1
|
Input15 | WA | 16 ms | 536 KB |
1
|
Input16 | WA | 20 ms | 624 KB |
1
|
Input17 | WA | 17 ms | 580 KB |
1
|
Input18 | WA | 16 ms | 668 KB |
1
|
Input19 | WA | 19 ms | 624 KB |
1
|
Input20 | WA | 66 ms | 584 KB |
1
|
Input21 | WA | 31 ms | 660 KB |
1
|
Input22 | WA | 18 ms | 616 KB |
1
|
Input23 | WA | 70 ms | 576 KB |
1
|
Input24 | WA | 31 ms | 780 KB |
1
|
Input25 | WA | 22 ms | 732 KB |
1
|
Input26 | WA | 18 ms | 816 KB |
1
|
Input27 | WA | 23 ms | 772 KB |
1
|
Input28 | WA | 26 ms | 596 KB |
1
|
Input29 | WA | 37 ms | 680 KB |
1
|
Input30 | WA | 26 ms | 640 KB |
1
|