답안 #541536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541536 2022-03-23T18:06:12 Z AlperenT Hop (COCI21_hop) C++17
0 / 110
1 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1000 + 5;

int n, arr[N], ans[N][N], dist[N];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n;

    for(int i = 1; i <= n; i++) cin >> arr[i];

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(arr[j] % arr[i] == 0){
                dist[j] = max(dist[j], dist[i] + 1);
            }
            else ans[i][j] = 3;
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(ans[i][j] == 0){
                if(dist[i] / 4 == dist[j] / 4) ans[i][j] = 1;
                else if(dist[i] / 16 == dist[j] / 16) ans[i][j] = 2;
                else ans[i][j] = 3;
            }
        }
    }

    for(int i = 2; i <= n; i++){
        for(int j = 1; j < i; j++){
            cout << ans[j][i] << " ";
        }
        cout << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 8
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 1 ms 468 KB Execution killed with signal 8
3 Halted 0 ms 0 KB -