Submission #486742

# Submission time Handle Problem Language Result Execution time Memory
486742 2021-11-12T16:08:48 Z davi_bart Hop (COCI21_hop) C++14
10 / 110
38 ms 6688 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fi first
#define se second
#define ld long double
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int hop[1200][3];
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    vector<vector<int> > ans(N);
    for (int &i : v) cin >> i;

    for (int i = N - 1; i >= 0; i--) {
        int k = 0;
        for (int j = i + 1; j < N; j++) {
            for (; k < 3; k++) {
                if (v[j] % v[i]) {
                    ans[j].pb(k);
                    break;
                }
                if (hop[j][k] < 3) {
                    ans[j].pb(k);
                    hop[i][k] = max(hop[i][k], hop[j][k] + 1);
                    break;
                }
            }
        }
    }
    // for (int j = 0; j < N; j++) {
    //     for (int k = 0; k < 3; k++) {
    //         cout << hop[j][k] << " ";
    //     }
    //     cout << endl;
    // }
    for (int i = 0; i < N; i++) {
        reverse(ans[i].begin(), ans[i].end());
        for (int x : ans[i]) {
            cout << x + 1 << " ";
        }
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 32 ms 6580 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 31 ms 5792 KB Output is correct
12 Correct 38 ms 6688 KB Output is correct
13 Correct 30 ms 5960 KB Output is correct
14 Incorrect 2 ms 588 KB Unexpected end of file - int32 expected
15 Halted 0 ms 0 KB -