Submission #394980

# Submission time Handle Problem Language Result Execution time Memory
394980 2021-04-27T14:53:02 Z Victor Xylophone (JOI18_xylophone) C++17
0 / 100
1 ms 200 KB
#include "xylophone.h"

#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

const int INF = 1000000007;

void solve(int n) {
    int diff[5001], ans[5001], dir[5001];
    rep(i, 0, n - 1) diff[i] = query(i + 1, i + 2);
    rep(i, 1, n - 1) {
        int val = query(i, i + 2);
        dir[i] = val != diff[i - 1] + diff[i];
    }

    rep(i, 0, n) {
        ans[0] = i + 1;
        ans[1] = ans[0] + diff[0];
        int cd = 1;
        bool works = 1, lo = 0, rev = 0;

        rep(i, 1, n - 1) {
            if (ans[i] < 1 || n < ans[i]) {
                works = 0;
                break;
            }
            if (ans[i] == n && !lo) rev = 1;
            if (ans[i] == 1) lo = 1;

            cd ^= dir[i];
            ans[i + 1] = ans[i] + (cd ? diff[i] : -diff[i]);
        }
        if (ans[n - 1] < 1 || n < ans[n - 1]) works = 0;

        if(works){
            if(rev)rep(i,0,n)ans[i]=n-ans[i]+1;
            break;
        }
    }

    rep(i, 0, n) answer(i + 1, ans[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -