# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538282 | jamielim | Hop (COCI21_hop) | C++14 | 64 ms | 5604 KiB |
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;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
int n;
ll arr[1005];
int ans[1005][1005];
set<int> adj[1005]; // graph of division thingy is a dag
int dist[1005];
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%lld",&arr[i]);
memset(ans,-1,sizeof(ans));
for(int i=1;i<n;i++){
for(int j=0;j<i;j++){
if(arr[i]%arr[j]!=0){
ans[j][i]=3;
}else{
adj[j].insert(i);
}
}
}
for(int i=0;i<n;i++){
for(int j:adj[i]){
dist[j]=max(dist[j],dist[i]+1);
}
}
for(int i=0;i<n;i++){
for(int j:adj[i]){
if(dist[j]/4==dist[i]/4)ans[i][j]=1;
else if(dist[j]/16==dist[i]/16)ans[i][j]=2;
else ans[i][j]=3;
}
}
for(int i=1;i<n;i++){
for(int j=0;j<i;j++){
printf("%d ",ans[j][i]);
}
printf("\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |