Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 883 | 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) | FINISHED | False | 18000 | 267832523 | Oct. 21, 2017, 8:05 a.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 421 ) | B | Berland Army | PROGRAMMING | constructive algorithms graphs greedy | 2800 |
There are n military men in the Berland army. Some of them have given orders to other military men by now. Given m pairs ( x i , y i ), meaning that the military man x i gave the i -th order to another military man y i . It is time for reform! The Berland Ministry of Defence plans to introduce ranks in the Berland army. Each military man should be assigned a rank — integer number between 1 and k , inclusive. Some of them have been already assigned a rank, but the rest of them should get a rank soon. Help the ministry to assign ranks to the rest of the army so that: for each of m orders it is true that the rank of a person giving the order (military man x i ) is strictly greater than the rank of a person receiving the order (military man y i ); for each rank from 1 to k there is at least one military man with this rank. The first line contains three integers n , m and k ( 1 ≤ n ≤ 2·10 5 , 0 ≤ m ≤ 2·10 5 , 1 ≤ k ≤ 2·10 5 ) — number of military men in the Berland army, number of orders and number of ranks. The second line contains n integers r 1 , r 2 , ..., r n , where r i > 0 (in this case 1 ≤ r i ≤ k ) means that the i -th military man has been already assigned the rank r i ; r i = 0 means the i -th military man doesn't have a rank yet. The following m lines contain orders one per line. Each order is described with a line containing two integers x i , y i ( 1 ≤ x i , y i ≤ n , x i ≠ y i ). This line means that the i -th order was given by the military man x i to the military man y i . For each pair ( x , y ) of military men there could be several orders from x to y . Print n integers, where the i -th number is the rank of the i -th military man. If there are many solutions, print any of them. If there is no solution, print the only number -1 . |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 31858635 | samjia2000 | B | Oct. 29, 2017, 7:14 a.m. | OK | GNU C++ | TESTS | 279 | 156 | 15462400 | 2800 | |
| 32702529 | __stdcall | B | Nov. 27, 2017, 7:10 a.m. | OK | GNU C++ | TESTS | 279 | 171 | 14745600 | 2800 | |
| 41386923 | luogu_bot2 | B | Aug. 9, 2018, 6:28 a.m. | OK | GNU C++ | TESTS | 279 | 171 | 16179200 | 2800 | |
| 35798257 | Als123 | B | Feb. 28, 2018, 11:17 p.m. | OK | GNU C++ | TESTS | 279 | 187 | 18944000 | 2800 | |
| 41386246 | djqtxdy | B | Aug. 9, 2018, 6:05 a.m. | OK | GNU C++ | TESTS | 279 | 217 | 24473600 | 2800 | |
| 31571223 | cxmsqjh wxy_z Oxer11 | B | Oct. 21, 2017, 11:59 a.m. | OK | GNU C++ | TESTS | 279 | 234 | 18227200 | 2800 | |
| 33473189 | suchang | B | Dec. 21, 2017, 7:50 a.m. | OK | GNU C++ | TESTS | 279 | 249 | 17510400 | 2800 | |
| 31575258 | zhangzy | B | Oct. 21, 2017, 1:09 p.m. | OK | GNU C++ | TESTS | 279 | 249 | 20582400 | 2800 | |
| 31862284 | Magolor | B | Oct. 29, 2017, 9:45 a.m. | OK | GNU C++ | TESTS | 279 | 249 | 22732800 | 2800 | |
| 31601571 | _SHENZHEBEI_ | B | Oct. 22, 2017, 11:12 a.m. | OK | GNU C++ | TESTS | 279 | 249 | 26624000 | 2800 | |
| 33366338 | CQzhangyu | B | Dec. 18, 2017, 1:40 a.m. | OK | GNU C++11 | TESTS | 279 | 124 | 18227200 | 2800 | |
| 44424201 | emoairx | B | Oct. 17, 2018, 2:43 a.m. | OK | GNU C++11 | TESTS | 279 | 124 | 24473600 | 2800 | |
| 33474424 | Durant_Lee | B | Dec. 21, 2017, 8:53 a.m. | OK | GNU C++11 | TESTS | 279 | 171 | 11468800 | 2800 | |
| 67767004 | Coming | B | Dec. 28, 2019, 4:40 a.m. | OK | GNU C++11 | TESTS | 279 | 171 | 15872000 | 2800 | |
| 31893346 | hzy9819 | B | Oct. 30, 2017, 12:34 p.m. | OK | GNU C++11 | TESTS | 279 | 171 | 16691200 | 2800 | |
| 40979375 | ReaLNero1 | B | July 30, 2018, 5:02 p.m. | OK | GNU C++11 | TESTS | 279 | 187 | 16179200 | 2800 | |
| 31603995 | laofudasuan | B | Oct. 22, 2017, 12:44 p.m. | OK | GNU C++11 | TESTS | 279 | 187 | 27852800 | 2800 | |
| 48660820 | Panole233 | B | Jan. 21, 2019, 5:57 a.m. | OK | GNU C++11 | TESTS | 279 | 202 | 15052800 | 2800 | |
| 33596771 | jslijin | B | Dec. 24, 2017, 3:48 p.m. | OK | GNU C++11 | TESTS | 279 | 202 | 20377600 | 2800 | |
| 37134472 | RNS_KSB | B | April 10, 2018, 2:34 a.m. | OK | GNU C++11 | TESTS | 279 | 202 | 21913600 | 2800 | |
| 31665474 | chinaboy | B | Oct. 24, 2017, 12:47 a.m. | OK | GNU C++14 | TESTS | 279 | 249 | 18739200 | 2800 | |
| 31601229 | AFO_OFA | B | Oct. 22, 2017, 10:59 a.m. | OK | GNU C++14 | TESTS | 279 | 280 | 20582400 | 2800 | |
| 31732538 | molamola. | B | Oct. 26, 2017, 8:37 a.m. | OK | GNU C++14 | TESTS | 279 | 295 | 28569600 | 2800 | |
| 32040149 | sz1231 | B | Nov. 4, 2017, 1:43 a.m. | OK | GNU C++14 | TESTS | 279 | 296 | 19968000 | 2800 | |
| 45463473 | vjudge2 | B | Nov. 9, 2018, 3:35 a.m. | OK | GNU C++14 | TESTS | 279 | 296 | 20992000 | 2800 | |
| 41451385 | fengyecong | B | Aug. 11, 2018, 4 a.m. | OK | GNU C++14 | TESTS | 279 | 311 | 17920000 | 2800 | |
| 31734002 | mengrao | B | Oct. 26, 2017, 9:44 a.m. | OK | GNU C++14 | TESTS | 279 | 311 | 22323200 | 2800 | |
| 32010241 | MicGor yarek Anadi | B | Nov. 3, 2017, 2:26 p.m. | OK | GNU C++14 | TESTS | 279 | 311 | 26931200 | 2800 | |
| 31569631 | JohnPaulII JKS_PL xman1024 | B | Oct. 21, 2017, 11:33 a.m. | OK | GNU C++14 | TESTS | 279 | 311 | 37273600 | 2800 | |
| 32156858 | Krydom_Yuudachi | B | Nov. 9, 2017, 11:57 a.m. | OK | GNU C++14 | TESTS | 279 | 312 | 19251200 | 2800 | |
| 58200934 | vjudge2 | B | Aug. 3, 2019, 4:11 a.m. | OK | GNU C++17 | TESTS | 279 | 202 | 17100800 | 2800 | |
| 56874847 | hjk1030 | B | July 12, 2019, 7:54 a.m. | OK | GNU C++17 | TESTS | 279 | 296 | 23142400 | 2800 | |
| 47854489 | Benq | B | Jan. 2, 2019, 8:18 p.m. | OK | GNU C++17 | TESTS | 279 | 311 | 24268800 | 2800 | |
| 67968681 | hjk1030 | B | Dec. 30, 2019, 2:13 p.m. | OK | GNU C++17 | TESTS | 279 | 327 | 23142400 | 2800 | |
| 41387200 | the_silliest | B | Aug. 9, 2018, 6:37 a.m. | OK | GNU C++17 | TESTS | 279 | 327 | 24473600 | 2800 | |
| 53744722 | StarCuriosity | B | May 4, 2019, 3:58 p.m. | OK | GNU C++17 | TESTS | 279 | 327 | 33587200 | 2800 | |
| 41387249 | Haru_ | B | Aug. 9, 2018, 6:38 a.m. | OK | GNU C++17 | TESTS | 279 | 343 | 29388800 | 2800 | |
| 41390452 | charlieshu | B | Aug. 9, 2018, 8:11 a.m. | OK | GNU C++17 | TESTS | 279 | 358 | 25292800 | 2800 | |
| 41958602 | BackOnTrack | B | Aug. 22, 2018, 8:08 a.m. | OK | GNU C++17 | TESTS | 279 | 373 | 31334400 | 2800 | |
| 41390513 | vjudge3 | B | Aug. 9, 2018, 8:13 a.m. | OK | GNU C++17 | TESTS | 279 | 374 | 25497600 | 2800 | |
| 31577934 | kessido | B | Oct. 21, 2017, 2:42 p.m. | OK | Java 8 | TESTS | 279 | 2027 | 157696000 | 2800 | |
| 31573816 | lucyanna2018 | B | Oct. 21, 2017, 12:45 p.m. | OK | MS C++ | TESTS | 279 | 373 | 21504000 | 2800 |
Back to search problems