제출 #52650

#제출 시각아이디문제언어결과실행 시간메모리
52650SpaimaCarpatilorTeleporters (IOI08_teleporters)C++17
10 / 100
665 ms87084 KiB
#include<bits/stdc++.h> using namespace std; int N, M, nr, v[2000009], nxt[2000009], gain[2000009], ap[2000009]; const int K = 2000001; int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d", &N, &M); for (int i=1; i<K; i++) nxt[i] = i; nxt[K] = 1; for (int i=1; i<=N; i++) { int x, y; scanf ("%d %d", &x, &y); gain[x] = gain[y] = 1; swap (nxt[x], nxt[y]); } for (int i=1; i<=K; i++) if (ap[i] == 0) { int j = i, s = 0; while (ap[j] == 0) ap[j] = 1, s += gain[j], j = nxt[j]; v[++nr] = s; } sort (v + 2, v + nr + 1); while (M > 0 && nr > 1) v[1] += v[nr] + 2, nr --, M --; if (M > 0) v[1] += 2 * M - M % 2; printf ("%d\n", v[1]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

teleporters.cpp: In function 'int main()':
teleporters.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d %d", &N, &M);
 ~~~~~~^~~~~~~~~~~~~~~~~
teleporters.cpp:20:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &x, &y);
     ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...