제출 #804363

#제출 시각아이디문제언어결과실행 시간메모리
804363Tunglam07Naboj (COCI22_naboj)C++17
0 / 110
233 ms11580 KiB
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> vec[200005], ans; long long m ,n ,dp[200005]; cin >> m >> n; queue<long long> q; while(n--); { long long a ,b; cin >> a >> b; vec[a].push_back(b); dp[b]++; } for(int i=1;i<=m;i++) { if(dp[i]==0) { q.push(i); } } while(!q.empty()) { long long id = q.front(); q.pop(); ans.push_back(id); for(long long x:vec[id]) { dp[x]--; if(dp[x]==0) { q.push(x); } } } if(ans.size()!=m) { cout << -1; } else { cout << ans.size() <<endl; for(long long x:ans) { cout << x << " " << 0 << endl; } } }

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

naboj.cpp: In function 'int main()':
naboj.cpp:10:2: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   10 |  while(n--);
      |  ^~~~~
naboj.cpp:11:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   11 |  {
      |  ^
naboj.cpp:38:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   38 |  if(ans.size()!=m)
      |     ~~~~~~~~~~^~~
naboj.cpp:15:7: warning: 'dp[<unknown>]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |   dp[b]++;
      |   ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...