CT63559

Arjun Counts the roads

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the temple city of Sunspire; Arjun weighs the day's roads manifests and starts the calculations. 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 <= 2458; 0 <= m <= 4916; self-edges make the answer NO.

Example 1:

Input: 305 3017 34 161 201 302 56 247 54 201 27 270 266 267 42 204 115 199 127 207 251 258 269 273 32 36 218 223 94 122 74 202 144 265 155 194 86 105 56 274 27 192 68 133 160 202 37 77 181 240 94 300 81 211 7 299 65 125 187 190 216 241 139 211 112 196 205 230 13 97 137 170 273 274 58 203 74 184 29 217 180 197 114 187 53 216 12 175 19 219 4 15 125 183 152 183 43 100 21 221 242 248 16 73 217 295 23 62 18 149 1 168 115 151 173 266 190 208 1 243 154 187 119 219 31 293 128 157 167 263 214 235 9 143 24 263 28 74 63 120 218 259 127 289 17 205 56 260 83 241 10 81 212 273 174 286 20 34 58 59 141 181 196 211 49 86 164 271 37 138 231 289 250 266 149 192 81 291 17 268 132 249 118 192 11 39 8 271 182 246 226 283 6 243 16 140 130 264 105 256 120 160 263 294 236 262 149 259 41 44 78 184 77 90 33 98 197 295 42 1…
Output: NO

Example 2:

Input: 1047 2995 1 2 2 3 1 3 892 964 246 329 107 516 264 906 72 160 374 461 437 754 429 856 254 632 402 626 258 438 79 376 202 299 96 164 217 897 229 1039 13 860 880 973 242 403 25 489 202 366 97 696 626 985 120 683 555 559 381 611 219 321 424 571 229 399 92 702 14 323 337 480 285 1038 115 175 615 671 563 969 269 286 259 657 273 668 24 654 464 499 262 991 224 743 353 450 473 859 395 952 163 542 22 477 24 448 108 926 181 522 966 1016 724 766 723 728 25 892 290 402 338 353 480 490 126 132 516 785 234 602 772 856 510 1014 647 663 516 866 716 798 764 788 684 847 508 991 876 1034 357 426 185 999 45 376 767 980 54 537 113 399 885 892 489 533 858 934 901 953 267 921 176 731 4 1039 115 1020 130 306 44 159 355 453 425 965 493 708 246 847 872 935 734 919 9 305 308 813 122 863 134 667 160 387 660 945 944 98…
Output: NO

Example 3:

Input: 1362 4115 675 1231 384 881 684 952 29 481 266 396 1127 1307 443 1218 70 393 707 1196 438 824 472 1110 698 743 12 1016 232 713 125 361 82 262 309 903 573 763 937 1165 89 467 820 1070 927 1002 440 926 953 1118 208 1002 20 1017 303 743 172 554 161 1291 242 679 237 1216 697 1266 486 600 180 1229 199 735 984 1339 939 959 743 901 1063 1219 777 1186 103 719 434 536 851 1056 198 393 68 115 139 386 98 1338 831 1010 374 1283 53 317 683 1215 112 928 28 148 384 437 69 1099 818 977 14 879 1145 1156 500 883 39 933 1238 1246 925 1353 414 1259 699 1051 220 455 485 686 397 653 439 798 551 902 130 897 399 1155 170 1215 20 1136 547 580 299 1087 77 765 785 922 652 873 124 528 1030 1339 183 515 35 479 199 457 152 985 568 1247 323 994 252 858 620 858 937 946 841 990 701 1312 538 831 862 1289 455 854 716 965 68 …
Output: NO

Constraints:

1 <= n <= 2458; 0 <= m <= 4916; self-edges make the answer NO.

Loading...
Test Cases:No test cases
No test cases available.