제출 #123422

#제출 시각아이디문제언어결과실행 시간메모리
123422arnold518Xylophone (JOI18_xylophone)C++14
100 / 100
112 ms536 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5000; int N, A[MAXN+10], Q1[MAXN+10], Q2[MAXN+10], D[MAXN+10], P1[MAXN+10], P2[MAXN+10]; void ans(int* P) { int i, j; for(i=1; i<=N; i++) { answer(i, P[i]); } } void solve(int n) { int i, j; N=n; for(i=1; i<N; i++) Q1[i]=query(i, i+1); for(i=1; i+1<N; i++) Q2[i]=query(i, i+2); D[1]=1; for(i=1; i+1<N; i++) { int a=Q1[i]+Q1[i+1]; int b=max(Q1[i], Q1[i+1]); if(a==Q2[i]) D[i+1]=D[i]; else D[i+1]=-D[i]; } P1[1]=P2[1]=0; int min1=0, min2=0; for(i=2; i<=N; i++) { P1[i]=P1[i-1]+D[i-1]*Q1[i-1]; P2[i]=P2[i-1]-D[i-1]*Q1[i-1]; min1=min(min1, P1[i]); min2=min(min2, P2[i]); } for(i=1; i<=N; i++) P1[i]-=min1-1, P2[i]-=min2-1; int a, b; for(i=1; i<=N; i++) { if(P1[i]==1) a=i; if(P1[i]==N) b=i; } if(a<b) ans(P1); else ans(P2); }

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

xylophone.cpp: In function 'void ans(int*)':
xylophone.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:34:13: warning: unused variable 'b' [-Wunused-variable]
         int b=max(Q1[i], Q1[i+1]);
             ^
xylophone.cpp:24:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
xylophone.cpp:58:5: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(a<b) ans(P1);
     ^~
xylophone.cpp:58:5: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...