답안 #139665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139665 2019-08-01T08:39:17 Z rzbt Xylophone (JOI18_xylophone) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include "xylophone.h"
using namespace std;
#define MAXN 5003
int niz[MAXN];
bool znak[MAXN];
int delta[MAXN];
void solve(int n)
{
    niz[1]=1;
    delta[2]=query(1,2);
    niz[2]=1+delta[2]

    for(int i=3;i<=n;i++){
        int x=query(i-2,i);
        delta[i]=query(i-1,i);
        int y=delta[i];

        if(x==abs(niz[i-1]-niz[i-2])){
            if(niz[i-2]<niz[i-1])niz[i]=niz[i-1]-y;
            else{
                niz[i]=niz[i-1]+y;
                znak[i]=true;
            }
        }else{
            if(niz[i-2]<niz[i-1]){
                if(x==y+abs(niz[i-1]-niz[i-2])){
                    niz[i]=niz[i-1]+y;
                    znak[i]=true;
                }
                else niz[i]=niz[i-1]-y;
            }else{
                if(x==y+abs(niz[i-1]-niz[i-2]))niz[i]=niz[i-1]-y;
                else {
                    niz[i]=niz[i-1]+y;
                    znak[i]=true;
                }
            }

        }
    }
    int mi=1;
    for(int i=1;i<=n;i++)
        if(niz[i]<niz[mi])
            mi=i;

    int ma=1;
    for(int i=1;i<=n;i++)
        if(niz[i]<niz[ma])
            ma=i;
    if(ma>mi){
        for(int i=2;i<=n;i++){
            if(znak[i])niz[i]=niz[i-1]-delta[i];
            else niz[i]=niz[i-1]+delta[i];
        }
    }
    int mi=1;
    for(int i=1;i<=n;i++)
        mi=min(mi,niz[i]);
    for(int i=1;i<=n;i++)answer(i,niz[i]-m+1);

}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:15:5: error: expected ';' before 'for'
     for(int i=3;i<=n;i++){
     ^~~
xylophone.cpp:15:17: error: 'i' was not declared in this scope
     for(int i=3;i<=n;i++){
                 ^
xylophone.cpp:58:9: error: redeclaration of 'int mi'
     int mi=1;
         ^~
xylophone.cpp:43:9: note: 'int mi' previously declared here
     int mi=1;
         ^~
xylophone.cpp:61:42: error: 'm' was not declared in this scope
     for(int i=1;i<=n;i++)answer(i,niz[i]-m+1);
                                          ^