제출 #56750

#제출 시각아이디문제언어결과실행 시간메모리
56750win11905Teleporters (IOI08_teleporters)C++11
90 / 100
1059 ms66252 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 2e6+5; int n, m, V[N], val[N], neibour[N], Com[N], psz, pz1; bool Check[N]; int main() { scanf("%d %d", &n, &m); for(int i = 0, u, v; i < n; ++i) { scanf("%d %d", &u, &v); neibour[u] = v, neibour[v] = u; V[u]++, V[v]++; } for(int i = 1; i < N; ++i) { V[i] += V[i-1]; if(V[i] != V[i-1]) Com[pz1++] = i; } int cnt = 0, p = 0; Check[0] = true; while(p != (n<<1)) Check[p = V[neibour[Com[p]]]] = true, cnt++; for(int i = 1; i <= (n<<1); ++i) if(!Check[i]) { int u = i, sz = 0; Check[u] = true; do Check[u = V[neibour[Com[u]]]] = true, sz++; while(u != i); val[++psz] = sz; } sort(val+1, val + psz + 1, greater<int>()); for(int i = 1; i <= psz; ++i) val[i] += val[i-1]; cnt += val[min(psz, m)] + 2 * min(psz, m); if(m > psz) m -= psz, cnt += ((m>>1)<<2) + (m & 1); printf("%d\n", cnt); }

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

teleporters.cpp: In function 'int main()':
teleporters.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
teleporters.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~~
#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...