# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442691 | 2021-07-08T15:31:14 Z | Markomafko972 | Hop (COCI21_hop) | C++14 | 1 ms | 588 KB |
#include <bits/stdc++.h> using namespace std; int n; int 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Runtime error | 1 ms | 588 KB | Execution killed with signal 8 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Runtime error | 1 ms | 588 KB | Execution killed with signal 8 |
3 | Halted | 0 ms | 0 KB | - |