Submission #117662

# Submission time Handle Problem Language Result Execution time Memory
117662 2019-06-17T05:00:56 Z 이온조(#2879) Izlet (COI19_izlet) C++14
18 / 100
680 ms 39532 KB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int N;
int A[3009][3009], C[3009];
vector<pii> ed;
void go(int n, int c) {
    C[n] = c;
    for(int i=1; i<=N; i++) {
        if(!C[i] && A[n][i] == 1) {
            go(i, c);
            ed.push_back({n, i});
        }
    }
}

int main() {
    int sub; scanf("%d",&sub);
    scanf("%d",&N);
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) {
            scanf("%d",&A[i][j]);
        }
    }
    if(sub == 1) {
        int c = 1, p = -1;
        for(int i=1; i<=N; i++) if(!C[i]) {
            if(p != -1) ed.push_back({i, p});
            go(i, c);
            c = 3 - c;
            p = i;
        }
        for(int i=1; i<=N; i++) printf("%d ", C[i]);
        for(auto& it: ed) printf("\n%d %d", it.first, it.second);
    }
    return 0;
}

Compilation message

izlet.cpp: In function 'int main()':
izlet.cpp:19:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int sub; scanf("%d",&sub);
              ~~~~~^~~~~~~~~~~
izlet.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
izlet.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&A[i][j]);
             ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 667 ms 37496 KB Output is correct
3 Correct 666 ms 37496 KB Output is correct
4 Correct 680 ms 39136 KB Output is correct
5 Correct 674 ms 39532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 666 ms 35832 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 667 ms 37496 KB Output is correct
3 Correct 666 ms 37496 KB Output is correct
4 Correct 680 ms 39136 KB Output is correct
5 Correct 674 ms 39532 KB Output is correct
6 Incorrect 666 ms 35832 KB Unexpected end of file - int32 expected
7 Halted 0 ms 0 KB -