제출 #502350

#제출 시각아이디문제언어결과실행 시간메모리
502350vrohakXylophone (JOI18_xylophone)C++14
0 / 100
0 ms200 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; /*int query (int a,int b){ cout<<a<<" "<<b<<endl; int pes; cin>>pes; return pes; }*/ void solve(int n) { // ako je x pozitivan //ako je x pozitivan //ako je x pozitivan //ako je x // pozitivan //ako je x pozitivan //ako je x pozitivan //ako je x pozitivan // //ako je x pozitivan int rj1[n], stg1 = 0, rj2[n]; int od1[n], od2[n], od3[n]; rj1[1] = 0; int odg1; odg1 = query(1, 2); od1[0] = odg1; int odg2; odg2 = query(2, 3); od2[0] = odg2; int odg3; odg3 = query(1, 3); od3[0] = odg3; rj1[2] = odg1; if (odg3 == odg2 + odg1) { rj1[3] = rj1[2] + odg2; } else { stg1 = 1; rj1[3] = rj1[2] - odg2; } for (int i = 4; i < n + 1; i++) { odg1 = odg2; odg2 = query(i - 1, i); odg3 = query(i - 2, i); od1[i] = odg1; od2[i] = odg2; od3[i] = odg3; if (stg1 == 0) { if (odg3 == odg2 + odg1) { rj1[i] = rj1[i - 1] + odg2; } else { stg1 = 1; rj1[i] = rj1[i - 1] - odg2; } } else { if (odg3 == odg2 + odg1) { rj1[i] = rj1[i - 1] - odg2; } else { stg1 = 0; rj1[i] = rj1[i - 1] + odg2; } } } int mn = 0, mx=0, idx1=0, idxn=0; for (int i = 1; i < n + 1; i++) { if(rj1[i] < mn) idx1 = i; if(rj1[i] > mx) idxn = i; mn = min(mn, rj1[i]); mx = max(mx, rj1[i]); } mn = abs(mn) + 1; for (int i = 1; i < n + 1; i++) { rj2[i] = mx-rj1[i]+1; rj1[i] = rj1[i] + mn; } if (idx1 < idxn) { for (int i = 1; i < n + 1; i++) { answer(i, rj1[i]); } } else { for (int i = 1; i < n + 1; i++) { answer(i, rj2[i]); } } return; }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:21:8: warning: variable 'od1' set but not used [-Wunused-but-set-variable]
   21 |    int od1[n], od2[n], od3[n];
      |        ^~~
xylophone.cpp:21:16: warning: variable 'od2' set but not used [-Wunused-but-set-variable]
   21 |    int od1[n], od2[n], od3[n];
      |                ^~~
xylophone.cpp:21:24: warning: variable 'od3' set but not used [-Wunused-but-set-variable]
   21 |    int od1[n], od2[n], od3[n];
      |                        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...