제출 #1230978

#제출 시각아이디문제언어결과실행 시간메모리
1230978salmonPovjerenstvo (COI22_povjerenstvo)C++20
13 / 100
378 ms65268 KiB
#include <bits/stdc++.h> using namespace std; int N; int M; int u,v; int parent[500100]; vector<int> adjlst[500100]; vector<int> badjlst[500100]; int d[500100]; bool used[500100]; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; int main(){ scanf(" %d",&N); scanf(" %d",&M); for(int i = 0; i < M; i++){ scanf(" %d",&u); scanf(" %d",&v); adjlst[u].push_back(v); badjlst[v].push_back(u); d[u]++; } for(int i = 1; i <= N; i++){ parent[i] = 1; used[i] = false; pq.push({d[i],i}); } vector<int> bosen; int cont = 0; while(cont != N){ if(used[pq.top().second]){ pq.pop(); continue; } cont++; int i = pq.top().second; pq.pop(); bosen.push_back(i); for(int j : badjlst[i]){ if(!used[j]){ used[j] = true; cont++; for(int k : badjlst[j]){ d[k]--; pq.push({d[k],k}); } } } } printf("%d\n",bosen.size()); for(int i : bosen) printf("%d ",i); printf("\n"); }

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

Main.cpp: In function 'int main()':
Main.cpp:62:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   62 |         printf("%d\n",bosen.size());
      |                 ~^    ~~~~~~~~~~~~
      |                  |              |
      |                  int            std::vector<int>::size_type {aka long unsigned int}
      |                 %ld
Main.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf(" %d",&N);
      |         ~~~~~^~~~~~~~~~
Main.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf(" %d",&M);
      |         ~~~~~^~~~~~~~~~
Main.cpp:20:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |                 scanf(" %d",&u);
      |                 ~~~~~^~~~~~~~~~
Main.cpp:21:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |                 scanf(" %d",&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...