# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442692 | Markomafko972 | Hop (COCI21_hop) | C++14 | 57 ms | 5236 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;
int n;
long long a[1005];
int kol[1005];
int sol[1005][1005];
vector< pair<int, int> > v;
int main () {
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
sol[i][j] = 3;
}
}
int z = -1;
for (int i = 0; i < n; i++) {
cin >> a[i];
int maxi = -1;
for (int j = z+1; j < i; j++) {
if (a[i] % a[j] == 0) {
maxi = max(maxi, kol[j]);
}
}
if (maxi >= 3) {
v.push_back({z+1, i-1});
z = i-1;
}
else {
for (int j = z+1; j < i; j++) sol[i][j] = 1;
kol[i] = maxi+1;
}
//cout << i << ": " << kol[i] << endl;
}
v.push_back({z+1, n-1});
for (int i = 0; i < v.size(); i += 4) {
for (int j = 0; j <= 3; j++) {
for (int k = j+1; k <= 3; k++) {
for (int l = v[i+j].first; l <= v[i+j].second; l++) {
for (int m = v[i+k].first; m <= v[i+k].second; m++) {
sol[m][l] = 2;
}
}
}
}
}
for (int i = 1; i < n; i++) {
for (int j = 0; j < i; j++) {
cout << sol[i][j] << " ";
}
cout << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |