제출 #510220

#제출 시각아이디문제언어결과실행 시간메모리
510220nichkeXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int query(int l,int r); void answer(int a,int b); void solve(int n){ if(n==2){ answer(1,1); answer(1,2); return; } int diff[n+1][3]; for(int i=2;i<=n;i++)diff[i-1][0]=query(i-1,i); for(int i=3;i<=n;i++)diff[i-2][1]=query(i-2,i); diff[1][2]=1; for(int i=1;i+2<=n;i++){ if(diff[i][1]==diff[i][0]+diff[i+1][0])diff[i+1][2]=diff[i][2]; else diff[i+1][2]=diff[i][2]^1; } int res[n+1]; res[1]=0; for(int i=1;i+1<=n;i++)res[i+1]=res[i]+(-1+2*diff[i][2])*diff[i][0]; int mn=1,mx=1; for(int i=2;i<=n;i++){ if(res[i]<res[mn])mn=i; if(res[i]>res[mx])mx=i; } if(mn>mx)for(int i=1;i+1<=n;i++)diff[i][2]^=1; res[1]=0; for(int i=1;i+1<=n;i++)res[i+1]=res[i]+(-1+2*diff[i][2])*diff[i][0]; int mn=1; for(int i=1;i<=n;i++)mn=min(mn,res[i]); for(int i=1;i<=n;i++)res[i]+=1+mn,answer(i,res[i]); }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:30:6: error: redeclaration of 'int mn'
   30 |  int mn=1;
      |      ^~
xylophone.cpp:22:6: note: 'int mn' previously declared here
   22 |  int mn=1,mx=1;
      |      ^~