Submission #996169

# Submission time Handle Problem Language Result Execution time Memory
996169 2024-06-10T08:25:50 Z reginox Xylophone (JOI18_xylophone) C++17
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define all(v) begin(v), end(v)
#define pi pair<int, int>
#define vi vector<int>
using namespace std;
int a[5005], n;
int p1[5005], p2[5005];

bool thu(int u, int v){
    if(v < 1 || v > n) return false;
    a[1] = u, a[2] = v;
    for(int i = 3; i <= n; i++){
        int d1 = p1[i], d2 = p2[i], d3 = abs(a[i-2] - a[i-1]);
        if(a[i-2] > a[i-1]){
            if(d3 + d1 == d2){
                a[i] = a[i-1] - d1;
            }
            else{
                a[i] = a[i-1] + d1;
            }
        }
        else{
            if(d1 == d2 || d2 == d3){
                a[i] = a[i-1] - d1;
            }
            else{
               a[i] = a[i-1] + d1; 
            }
        }
    }
    vector<bool> ch(n, false);
    for(int i = 1; i <= n; i++){
        if(ch[a[i]-1]) return false;
        ch[a[i]-1] = true;
    }
    return true;
}

void solve(int m){
    n = m;
    int d = query(1, 2);
    for(int i = 3; i <= n; i++){
        p1[i] = query(i-1, i), p2[i] = query(i-2, i);
    }
    for(int v1 = 1; v1 <= n; v1++){
        for(int z = -d; z <= d; z+=2*d){
            if(thu(v1, v1+z)){
                for(int i = 1; i <= n; i++) answer(i, a[i]);
                return ;
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 1 ms 344 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 1 ms 344 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 1 ms 344 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -