답안 #82995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82995 2018-11-03T14:36:30 Z Vasiljko Xylophone (JOI18_xylophone) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;



int a[5000];

void solve(int n) {
    int diff=n-1;
    int ind;
    int val=query(2,n);
    for(int i=1;i<n;i++){
        int val=query(i+1,n);
        if(val!=diff){
            ind=i;
            break;
        }
    }

    a[ind]=1;
    a[ind+1]=1+query(ind,ind+1);

    for(int i=ind+2;i<=n;i++){
        int p=query(i-2,i);
        int q=query(i-1,i);

        int val=a[i-1]+q;
        if(max(val,max(a[i-1],a[i-2]))-min(val,min(a[i-1],a[i-2]))==p){
            a[i]=val;
        }else{
            a[i]=a[i-1]-q;
        }
    }

    if(ind>1){
        a[ind-1]=1+query(ind-1,ind);

        for(int i=ind-2;i>=1;i--){
            int p=query(i,i+2);
            int q=query(i,i+1);

            int val=a[i+1]+q;
            if(max(val,max(a[i+1],a[i+2]))-min(val,min(a[i+1],a[i+2]))==p){
                a[i]=val;
            }else{
                a[i]=a[i+1]-q;
            }
        }
    }
    for(int i=1;i<=n;i++)answer(i,a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:11:13: error: 'query' was not declared in this scope
     int val=query(2,n);
             ^~~~~
xylophone.cpp:50:26: error: 'answer' was not declared in this scope
     for(int i=1;i<=n;i++)answer(i,a[i]);
                          ^~~~~~
xylophone.cpp:50:26: note: suggested alternative: 'assert'
     for(int i=1;i<=n;i++)answer(i,a[i]);
                          ^~~~~~
                          assert
xylophone.cpp:11:9: warning: unused variable 'val' [-Wunused-variable]
     int val=query(2,n);
         ^~~