제출 #209540

#제출 시각아이디문제언어결과실행 시간메모리
209540DodgeBallManXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; const int N = 5e3 + 10; int a[N], df[N], st[N], mul = 1, mn, mx, pmn, pmx; //void answer( int pos, int va ) { printf("pos : %d va : %d\n",pos,va); } /*int query( int i, int j ) { int c; printf("%d %d\n",i,j); scanf("%d",&c); return c; }*/ int solve( int n ) { for( int i = 1 ; i < n ; i++ ) df[i+1] = query( i, i + 1 ); for( int i = 2 ; i < n ; i++ ) { int dif = query( i-1, i+1 ); if( dif == df[i] + df[i+1] ) st[i] = 1; else st[i] = -1; } pmx = 1, pmn = 1; for( int i = 2 ; i <= n ; i++ ) { a[i] = a[i-1] + ( mul * df[i] ); mul *= st[i]; if( a[i] > mx ) mx = a[i], pmx = i; if( a[i] < mn ) mn = a[i], pmn = i; } /*for( int i = 2 ; i <= n ; i++ ) printf("%d ",df[i]); printf("\n"); for( int i = 2 ; i < n ; i++ ) printf("%d ",st[i]); printf("\n"); printf("%d %d pos : %d %d\n",mn,mx,pmn,pmx);*/ if( pmn > pmx ) { for( int i = 1 ; i <= n ; i++) a[i] *= -1; swap( mn, mx ); mn *= -1, mx *= -1; } //printf("%d %d pos : %d %d\n",mn,mx,pmn,pmx); for( int i = 1 ; i <= n ; i++ ) answer( i, a[i] + -1*mn + 1 ); } /*int main() { int n; scanf("%d",&n); solve( n ); }*/

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'int solve(int)':
xylophone.cpp:18:5: error: ambiguating new declaration of 'int solve(int)'
 int solve( int n ) {
     ^~~~~
In file included from xylophone.cpp:2:0:
xylophone.h:3:6: note: old declaration 'void solve(int)'
 void solve(int N);
      ^~~~~
xylophone.cpp:44:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^