CT61253

Last routes of Wren

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the salmon ladder of Rushing Falls, Wren records each routes in a worn leather ledger. The guild wants answers, not guesses. Task: Print YES if the undirected graph's nodes can be split into two groups with no edge inside a group, otherwise NO. Input format: First line: n and m. Next m lines: u v. Output format: Print YES or NO. Constraints: 1 <= n <= 1591; 0 <= m <= 3182; self-edges make the answer NO.

Example 1:

Input: 1305 1322 1 2 2 3 1 3 435 1203 1138 1294 127 1076 11 1159 281 627 480 1282 37 944 943 1176 7 181 548 864 952 1204 978 1182 34 754 1192 1224 969 1042 514 953 308 508 991 1081 482 1286 676 919 558 1118 371 1177 717 1110 264 286 776 845 129 811 297 1193 165 323 370 1210 1182 1291 810 900 317 346 175 553 1096 1115 518 1043 375 930 451 1060 761 971 268 1105 569 1072 267 789 894 1224 533 753 965 977 577 786 1052 1287 184 1013 217 785 137 974 507 1165 974 1189 424 1052 218 368 1029 1101 252 551 1262 1274 460 935 398 1109 340 1096 203 355 46 652 163 712 148 415 1067 1226 794 1053 268 1166 243 604 838 1214 139 685 68 1013 763 1182 194 465 420 560 385 820 126 1275 614 1117 216 561 21 1049 129 1077 305 1070 307 400 26 262 899 1221 345 365 567 1221 558 713 25 941 262 449 16 1049 434 581 912 1084 203 8…
Output: NO

Example 2:

Input: 1398 1063 60 373 31 503 392 1139 216 290 656 823 44 975 24 416 1005 1232 51 805 695 778 909 1125 1305 1392 1187 1323 601 1217 45 981 503 532 221 566 605 735 795 1192 162 1295 744 961 627 676 632 781 548 1161 880 1004 168 441 389 1057 430 1131 656 827 79 535 65 160 689 1167 490 1214 149 1254 580 1143 490 531 806 1187 918 1074 608 1188 26 705 376 1326 309 759 238 1227 187 1050 306 1034 363 912 632 1196 529 757 679 920 679 696 301 1109 317 620 587 1243 1015 1250 622 1127 614 1255 36 867 796 1221 236 447 180 917 585 701 1076 1132 802 1287 643 1101 735 923 308 894 239 1153 1067 1105 232 1274 221 1083 1287 1347 250 489 416 1267 26 733 226 1381 161 311 2 276 59 1219 215 260 254 1352 166 1097 30 1319 537 1149 270 297 296 791 591 751 227 847 208 695 719 834 703 1333 717 738 561 963 211 1157 765 773…
Output: NO

Example 3:

Input: 357 308 100 291 111 219 262 278 198 312 257 274 225 312 81 220 15 352 144 335 39 201 74 250 114 158 177 189 53 204 288 302 97 162 342 351 19 296 111 132 130 167 47 168 118 200 98 354 148 250 238 254 127 298 61 208 64 70 255 279 266 336 306 354 97 119 113 337 120 281 164 181 187 316 107 292 119 283 67 335 153 194 68 332 253 283 108 348 4 299 45 319 102 115 78 153 245 246 140 314 17 289 322 350 182 253 241 343 76 94 2 54 86 351 73 327 34 318 194 301 80 217 110 344 31 234 48 347 211 219 162 236 25 311 66 123 128 340 3 176 35 49 128 164 19 305 71 285 89 271 236 324 3 72 165 225 132 263 171 190 31 129 111 261 235 250 2 189 69 348 298 308 29 46 221 265 212 295 118 354 274 290 96 143 74 137 257 343 69 235 320 338 214 338 248 266 37 212 30 197 22 287 28 198 11 53 325 354 44 48 46 67 213 254 52 150…
Output: NO

Constraints:

1 <= n <= 1591; 0 <= m <= 3182; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.
Last routes of Wren - MEDIUM Coding Problem | CodeTikki