답안 #476412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476412 2021-09-26T12:51:51 Z Iwanttobreakfree Xylophone (JOI18_xylophone) C++
0 / 100
0 ms 200 KB
#include "xylophone.h"

static int A[5000];

void solve(int N) {
    int maxi=0,sol,ans;
    for(int i=2;i<=N;i++){
        int val=query(1,i);
        if(val>maxi){
            maxi=val;
            sol=i;
        }
    }
    maxi=0;
    for(int i=sol+1;i<=N;i++){
        int val=query(sol,i);
        if(val>maxi){
            maxi=val;
            ans=i;
        }
    }
    for(int i=sol-1;i>=1;i--){
        int val=query(i,sol);
        if(val>maxi){
            maxi=val;
            ans=i;
        }
    }
    answer(sol,ans);
}

Compilation message

xylophone.cpp:3:12: warning: 'A' defined but not used [-Wunused-variable]
    3 | static int A[5000];
      |            ^
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:29:11: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |     answer(sol,ans);
      |     ~~~~~~^~~~~~~~~
xylophone.cpp:29:11: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -