Submission #541539

#TimeUsernameProblemLanguageResultExecution timeMemory
541539AlperenTHop (COCI21_hop)C++17
110 / 110
35 ms8244 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 1000 + 5;

long long 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";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...