# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
497970 |
2021-12-24T06:58:42 Z |
abc864197532 |
Hop (COCI21_hop) |
C++17 |
|
52 ms |
5336 KB |
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
return o << '(' << a.X << ", " << a.Y << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
if (a.empty())
return o << "{}";
bool is = false;
for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
return o << '}';
}
template <typename T> struct vv : vector <vector <T>> {
vv(int n, int m, T v) : vector <vector <T>> (n, vector <T>(m, v)) {}
vv() {}
};
template <typename T> struct vvv : vector <vv <T>> {
vvv(int n, int m, int k, T v) : vector <vv <T>> (n, vv <T>(m, k, v)) {}
vvv() {}
};
#ifdef Doludu
#define test(args...) abc("[" + string(#args) + "]", args)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(args...) void(0)
#define owo ios::sync_with_stdio(false); cin.tie(0)
#endif
const int mod = 1e9 + 7, N = 100010, logN = 17, K = 350, M = N * 40;
int main () {
owo;
int n;
cin >> n;
vector <lli> a(n);
vv <int> dis(n, 3, 0);
for (int i = 0; i < n; ++i)
cin >> a[i];
vv <int> ans(n, n, 0);
for (int i = 1; i < n; ++i) {
for (int j = 0; j < i; ++j) if (a[i] % a[j] == 0) {
int pt = 0;
for (int k = 1; k <= 2; ++k) {
if (dis[j][pt] > dis[j][k])
pt = k;
}
ans[j][i] = pt;
dis[i][pt] = max(dis[i][pt], dis[j][pt] + 1);
}
}
for (int j = 1; j < n; ++j) {
for (int i = 0; i < j; ++i)
cout << ans[i][j] + 1 << ' ';
cout << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Correct |
48 ms |
5240 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
32 ms |
4536 KB |
Output is correct |
12 |
Correct |
52 ms |
5288 KB |
Output is correct |
13 |
Correct |
38 ms |
4700 KB |
Output is correct |
14 |
Correct |
2 ms |
464 KB |
Output is correct |
15 |
Correct |
34 ms |
4632 KB |
Output is correct |
16 |
Correct |
41 ms |
4756 KB |
Output is correct |
17 |
Correct |
41 ms |
4684 KB |
Output is correct |
18 |
Correct |
34 ms |
4620 KB |
Output is correct |
19 |
Correct |
34 ms |
4632 KB |
Output is correct |
20 |
Correct |
41 ms |
4808 KB |
Output is correct |
21 |
Correct |
37 ms |
4680 KB |
Output is correct |
22 |
Correct |
35 ms |
4580 KB |
Output is correct |
23 |
Correct |
40 ms |
5336 KB |
Output is correct |