답안 #782210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782210 2023-07-13T16:24:05 Z christinelynn Naboj (COCI22_naboj) C++17
0 / 110
324 ms 16308 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{
        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;
      |         ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 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 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Incorrect 3 ms 4948 KB Integer parameter [name=c] equals to 0, violates the range [1, 10]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 324 ms 16308 KB Integer parameter [name=c] equals to 0, violates the range [1, 200000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Incorrect 3 ms 4948 KB Integer parameter [name=c] equals to 0, violates the range [1, 10]
9 Halted 0 ms 0 KB -