Submission #996057

# Submission time Handle Problem Language Result Execution time Memory
996057 2024-06-10T07:39:11 Z fimh Xylophone (JOI18_xylophone) C++14
0 / 100
0 ms 344 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(int n){
     // 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();
//      }
// }
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -