제출 #200184

#제출 시각아이디문제언어결과실행 시간메모리
200184nsnXylophone (JOI18_xylophone)C++14
100 / 100
107 ms632 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int r[5005], g, pr[5005]; vector <int> mp; int maxm, minm, maxn = 0, minn = 0; int n[5005]; void solve(int N) { for(int i = 1; i < N; i++) { pr[i] = query(i, i+1); } for(int i = 1; i < N-1; i++) { r[i] = query(i, i+2); if(r[i] == pr[i] || r[i] == pr[i+1]) { mp.push_back(i+1); } } mp.push_back(N); int tv = 0; int x = 0, tx = 0; for(int i = 1; i < N; i++) { if(i == mp[tx]) { tx++; } if(tx % 2 == 0) { tv += pr[i]; } else { tv -= pr[i]; } if(maxn < tv) { maxn = tv; maxm = i+1; } if(minn > tv) { minn = tv; minm = i+1; } } if(minm > maxm) { x = 1; swap(maxm, minm); } tx = 0; int tp = 0; for(int i = 1; i < N; i++) { if(i == mp[tx]) { tx++; } if(tx % 2 != x) { pr[i] = -pr[i]; } } n[minm] = 1; for(int i = minm-1; i >= 1; i--) { n[i] = n[i+1] - pr[i]; } for(int i = minm+1; i <= N; i++) { n[i] = n[i-1] + pr[i-1]; } for(int i = 1; i <= N; i++) { answer(i, n[i]); } }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:56:6: warning: unused variable 'tp' [-Wunused-variable]
  int tp = 0;
      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...