제출 #804510

#제출 시각아이디문제언어결과실행 시간메모리
804510Tunglam07Naboj (COCI22_naboj)C++17
110 / 110
402 ms23920 KiB
#include <bits/stdc++.h> using namespace std; vector<long long> vec[200005], ans; long long m ,n ,dp[200005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> m >> n; queue<long long> q; for(int i=1;i<=n;i++) { 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 nx:vec[id]) { dp[nx]--; if(dp[nx]==0) { q.push(nx); } } } if(ans.size()!=m) { cout << -1; } else { cout << ans.size() <<endl; for(long long nx:ans) { cout << nx << " " << 0 << endl; } } }

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

naboj.cpp: In function 'int main()':
naboj.cpp:42: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]
   42 |  if(ans.size()!=m)
      |     ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...