제출 #932904

#제출 시각아이디문제언어결과실행 시간메모리
932904Amirreza_FakhriZemljište (COCI22_zemljiste)C++17
0 / 70
1 ms600 KiB
// In the name of the God #include <bits/stdc++.h> #define ll long long // #define int long long #define pb push_back #define F first #define S second #define mp make_pair #define pii pair <int, int> #define smin(x, y) (x) = min((x), (y)) #define smax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(), (x).end() using namespace std; const int inf = 1e9+7; const int mod = 998244353; const int maxn = 5e2+5; int n, m, cnt[maxn]; vector <int> adj[maxn], vec; queue <int> q; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; adj[--b].pb(--a); cnt[a]++; } for (int i = 0; i < n; i++) { if (!cnt[i]) q.push(i); } while (q.size()) { int v = q.front(); q.pop(); vec.pb(v); for (int u : adj[v]) { cnt[u]--; if (!cnt[u]) q.push(u); } } if (vec.size() != n) cout << -1 << '\n'; else { cout << n << '\n'; for (int v : vec) cout << v << ' ' << 1 << '\n'; } return 0; }

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

Main.cpp: In function 'int32_t main()':
Main.cpp:42:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |     if (vec.size() != n) cout << -1 << '\n';
      |         ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...