Submission #1114442

# Submission time Handle Problem Language Result Execution time Memory
1114442 2024-11-18T21:58:27 Z sunboi Xylophone (JOI18_xylophone) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#include "xylophone.h"
 
using namespace std;
 
void solve(int n){
    int pos = 0;
    int i = 1;
    while(query(i, n) == n - 1){
        i++;
    }
    i--;
    int reference = i;
    vector<int> a(n);
    int x = query(i, i + 1) + 1;
    
    a[i] = 1;
    a[i + 1] = x;
    i += 2;
    for (i; i <= n; i++){
        int mn = min(a[i - 1], a[i - 2]);
        int mx = max(a[i - 1], a[i - 2]);
        int uno = query(i - 1, i);
        int dos = query(i - 2, i);
        
        if (dos > uno){
            if (a[i - 1] + uno == a[i - 2] + dos){
                a[i] = a[i - 1] + uno;
            }else{
                a[i] = a[i - 1] - uno;
            }
        }else{
            if (a[i - 1] == mn) a[i] = a[i - 1] + uno;
            else a[i] = a[i - 1] - uno;
        }
    }
    
    i = reference;
    x = query(i - 1, i);
    a[i - 1] = 1 + x;
    i -= 2;
    for (i; i >= 1; i--){
        int mn = min(a[i + 1], a[i + 2]);
        int mx = max(a[i + 1], a[i + 2]);
        int uno = query(i + 1, i);
        int dos = query(i + 2, i);
        
        if (dos > uno){
            if (a[i + 1] + uno == a[i + 2] + dos){
                a[i] = a[i + 1] + uno;
            }else{
                a[i] = a[i + 1] - uno;
            }
        }else{
            if (a[i + 1] == mn) a[i] = a[i + 1] + uno;
            else a[i] = a[i + 1] - uno;
        }
    }
    for (int i = 1; i <= n; i++) answer(i, a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:10: warning: statement has no effect [-Wunused-value]
   20 |     for (i; i <= n; i++){
      |          ^
xylophone.cpp:22:13: warning: unused variable 'mx' [-Wunused-variable]
   22 |         int mx = max(a[i - 1], a[i - 2]);
      |             ^~
xylophone.cpp:42:10: warning: statement has no effect [-Wunused-value]
   42 |     for (i; i >= 1; i--){
      |          ^
xylophone.cpp:44:13: warning: unused variable 'mx' [-Wunused-variable]
   44 |         int mx = max(a[i + 1], a[i + 2]);
      |             ^~
xylophone.cpp:7:9: warning: unused variable 'pos' [-Wunused-variable]
    7 |     int pos = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -