답안 #117659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
117659 2019-06-17T04:44:42 Z 이온조(#2879) Izlet (COI19_izlet) C++14
0 / 100
1326 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

int A[3009][3009], C[3009];

void solve(int s, int e, int st, int d) {
    if(s == e) return;
    vector<int> S = {s};
    C[s] = st; st += d;
    for(int i=s+1; i<=e; i++) {
        if(A[s][i-1] != A[s][i]) {
            S.push_back(i);
            C[i] = st;
            st += d;
        }
    }
    S.push_back(e+1);
    for(int i=1; i<S.size(); i++) solve(S[i-1], S[i] - 1, C[S[i-1]], -d);
}

int main() {
    int sub; scanf("%d",&sub);
    int N; scanf("%d",&N);
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) {
            scanf("%d",&A[i][j]);
        }
    }
    if(sub == 2) {
        solve(1, N, 1, +1);
        for(int i=1; i<=N; i++) printf("%d ", C[i]);
        for(int i=1; i<N; i++) printf("\n%d %d", i, i+1);
    }
    return 0;
}

Compilation message

izlet.cpp: In function 'void solve(int, int, int, int)':
izlet.cpp:18:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1; i<S.size(); i++) solve(S[i-1], S[i] - 1, C[S[i-1]], -d);
                  ~^~~~~~~~~
izlet.cpp: In function 'int main()':
izlet.cpp:22: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:23:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N; scanf("%d",&N);
            ~~~~~^~~~~~~~~
izlet.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&A[i][j]);
             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1326 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -