| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 769641 | raysh07 | Xylophone (JOI18_xylophone) | C++17 | 1 ms | 208 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
static int ans[5001], pos[5001];
static int a[5001], b[5001];
static int n;
void print(){
    for (int i = 1; i <= n; i++){
        cout << ans[i] << " ";
        answer(i, ans[i]);
    }
    cout << "\n";
}
void solve(int nn) {
    n = nn;
// 	int value = query(1, N);
// 	for(int i = 1; i <= N; i++) {
// 		answer(i, i);
// 	}
    
    for (int i = 1; i < n; i++){
        a[i] = query(i, i + 1);
    }
    for (int i = 1; i < n - 1; i++){
        b[i] = query(i, i + 2);
    }
    
    for (int i = 1; i <= n; i++){
        ans[1] = i;
        if (i + a[1] <= n){
            ans[2] = i + a[1];
            
            bool seen = false;
            bool good = true;
            
            for (int j = 3; j <= n; j++){
                if (a[j - 2] + a[j - 1] == b[j - 2]) {
                    if (ans[j - 1] > ans[j - 2]){
                        ans[j] = ans[j - 1] + a[j - 1];
                    } else {
                        ans[j] = ans[j - 1] - a[j - 1];
                    }
                } else {
                    if (ans[j - 1] > ans[j - 2]){
                        ans[j] = ans[j - 1] - a[j - 1];
                    } else {
                        ans[j] = ans[j - 1] + a[j - 1];
                    }
                }
                
                if (ans[j] < 1 || ans[j] > n){
                    good = false;
                }
            }
            
            for (int j = 1; j <= n; j++){
                if (ans[j] == 1) seen = true;
                if (ans[j] == n && !seen) good = false;
            }
            
            set <int> st;
            for (int j = 1; j <= n; j++) st.insert(ans[j]);
            
            if (st.size() != n) good = false;
            
            if (good){
                print();
                return;
            }
        }
        
        if (i - a[1] >= 1){
            ans[2] = i - a[1];
            
            bool seen = false;
            bool good = true;
            
            for (int j = 3; j <= n; j++){
                if (a[j - 2] + a[j - 1] == b[j - 2]) {
                    if (ans[j - 1] > ans[j - 2]){
                        ans[j] = ans[j - 1] + a[j - 1];
                    } else {
                        ans[j] = ans[j - 1] - a[j - 1];
                    }
                } else {
                    if (ans[j - 1] > ans[j - 2]){
                        ans[j] = ans[j - 1] - a[j - 1];
                    } else {
                        ans[j] = ans[j - 1] + a[j - 1];
                    }
                }
                
                if (ans[j] < 1 || ans[j] > n){
                    good = false;
                }
            }
            
            for (int j = 1; j <= n; j++){
                if (ans[j] == 1) seen = true;
                if (ans[j] == n && !seen) good = false;
            }
            
            set <int> st;
            for (int j = 1; j <= n; j++) st.insert(ans[j]);
            
            if (st.size() != n) good = false;
            
            if (good){
                print();
                return;
            }
        }
    }
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
