Submission #474647

#TimeUsernameProblemLanguageResultExecution timeMemory
474647mychecksedadHop (COCI21_hop)C++17
110 / 110
50 ms1316 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define all(x) x.begin(), x.end()
const int N = 1e3+10;

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

int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> arr[i];
    for(int i = 2; i <= n; i++){
        vector<int> x(3);
        for(int j = 1; j < i; j++){
            if(arr[i] % arr[j] == 0){
                x[ans[j]]++;
            }
        }
        int mn = min_element(all(x)) - x.begin();
        ans[i] = mn;
    }


    for(int i = 2; i <= n; i++){for(int j = 1; j < i; j++) cout << ans[j] + 1 << ' '; cout << '\n';}
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...