This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |