Submission #996054

# Submission time Handle Problem Language Result Execution time Memory
996054 2024-06-10T07:37:32 Z fimh Xylophone (JOI18_xylophone) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std; 

using ll = long long;
using pll = pair<ll, ll>;

#define fi first
#define se second

const ll N = 5e3 + 5;
const ll blocksz = 320;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll rep, n;
ll a[N];
bool f[N];

bool check(){
     for (int i = 1; i <= n; ++i){
          if (a[i] == n) return 0;
          if (a[i] == 1) break;
     }
     if (*min_element(a + 1, a + n + 1) != 1) return 0;
     if (*max_element(a + 1, a + n + 1) != n) return 0;
     for (int i = 1; i <= n; ++i) f[i] = 0;
     for (int i = 1; i <= n; ++i) f[a[i]] = 1;
     for (int i = 1; i <= n; ++i) if (!f[i]) return 0;
     return 1;
}

// ll query(ll l, ll r){
//      cout << l << " " << r << endl;
//      cin >> rep;
//      return rep;
// }

// void answer(ll i, ll x){
//      a[i] = x;
// }

void solve(){
     cin >> n;
     ll d = query(1, 2);
     for (int i = 1; i < n; ++i){
          a[1] = i;
          if (a[1] - d >= 1){
               a[2] = a[1] - d;
               for (int i = 3; i <= n; ++i){
                    ll t1 = query(i - 1, i);
                    ll t2 = query(i - 2, i);
                    if (a[i - 2] > a[i - 1]){
                         if (t2 >= t1) a[i] = a[i - 1] + t1;
                         else a[i] = a[i - 1] - t1;
                    }else{
                         if (t2 < t1) a[i] = a[i - 1] + t1;
                         else a[i] = a[i - 1] - t1; 
                    }
               }
               // for (int i = 1; i <= n; ++i) cout << a[i] << " ";
               if (check()){
                    for (int i = 1; i <= n; ++i){
                         answer(i, a[i]);
                    }
                    return;
               }
          }
          if (a[1] + d <= n){
               a[2] = a[1] + d;
               for (int i = 3; i <= n; ++i){
                    ll t1 = query(i - 1, i);
                    ll t2 = query(i - 2, i);
                    if (a[i - 2] > a[i - 1]){
                         if (t2 >= t1) a[i] = a[i - 1] + t1;
                         else a[i] = a[i - 1] - t1;
                    }else{
                         if (t2 < t1) a[i] = a[i - 1] + t1;
                         else a[i] = a[i - 1] - t1; 
                    }
               }
               // for (int i = 1; i <= n; ++i) cout << a[i] << " ";
               if (check()){
                    for (int i = 1; i <= n; ++i){
                         answer(i, a[i]);
                    }
                    return;
               }
          }
     }
}         
     
signed main(){
     // ios_base::sync_with_stdio(0); 
     // cin.tie(0); cout.tie(0);
     ll TC = 1; // cin >> TC;
     while (TC--){
          solve();
     }
}

Compilation message

/usr/bin/ld: /tmp/ccOBn33a.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccxCTBhd.o:xylophone.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccOBn33a.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status