Submission #782211

# Submission time Handle Problem Language Result Execution time Memory
782211 2023-07-13T16:25:45 Z christinelynn Naboj (COCI22_naboj) C++17
0 / 110
339 ms 16404 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
vector <ll> al[200005];
ll deg[200005];
int main(){
    cin>>n>>m;
    queue<ll> q;
    for (int i=1;i<=m;i++){
        ll a,b;
        cin>>a>>b;
        al[b].push_back(a);
        deg[a]++;
    }
    vector <pair<ll,ll>> ans;
    for (int i=1;i<=n;i++){
        if (deg[i]==0) {
            q.push(i);
            ans.push_back({i,0});
        }
    }
    while(!q.empty()){
        ll u=q.front(); q.pop();
        for (auto z:al[u]){
            deg[z]--;
            if (deg[z]==0){
                ans.push_back({z,0});
                q.push(z);
            }
        }
    }
    if (ans.size()!=n) cout<<-1;
    else{
        cout<<ans.size()<<endl;
        for (auto z:ans){
            cout<<z.first<<" "<<z.second<<endl;
        }
    }
}

Compilation message

naboj.cpp: In function 'int main()':
naboj.cpp:33:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   33 |     if (ans.size()!=n) cout<<-1;
      |         ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Incorrect 3 ms 4948 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 339 ms 16404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Incorrect 3 ms 4948 KB Output isn't correct
9 Halted 0 ms 0 KB -