제출 #1093428

#제출 시각아이디문제언어결과실행 시간메모리
1093428DeathIsAweArt Collections (BOI22_art)C++17
100 / 100
1073 ms1740 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; int ans[4001]; bool visited[4001]; void solve(int n) { for (int i=0;i<4001;i++) { ans[i] = -1; visited[i] = false; } vector<int> arr(n); for (int i=0;i<n;i++) { arr[i] = i + 1; } int refnum = publish(arr); vector<int> newarr(n); int newrefnum; for (int i=0;i<n-1;i++) { for (int j=0;j<n-1;j++) { newarr[j] = arr[j + 1]; } newarr[n - 1] = arr[0]; newrefnum = publish(newarr); ans[(refnum - newrefnum + n - 1) / 2 + 1] = arr[0]; visited[arr[0]] = true; arr = newarr; refnum = newrefnum; } int lastnum; for (int i=1;i<n+1;i++) { if (!visited[i]) { lastnum = i; break; } } vector<int> ansarr(n); for (int i=1;i<n+1;i++) { if (ans[i] == -1) { ansarr[i - 1] = lastnum; } else { ansarr[i - 1] = ans[i]; } } answer(ansarr); }

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

art.cpp: In function 'void solve(int)':
art.cpp:47:27: warning: 'lastnum' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |             ansarr[i - 1] = lastnum;
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...