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;
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";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |