제출 #789396

#제출 시각아이디문제언어결과실행 시간메모리
789396PoonYaPatMonster Game (JOI21_monster)C++17
0 / 100
64 ms4240 KiB
#include "monster.h" #include <bits/stdc++.h> using namespace std; int val[1005][1005]; vector<int> v; void rev(int l, int r) { while (l<r) { swap(v[l],v[r]); ++l; --r; } } int Q(int a, int b) { if (val[a][b]==-1) { int k=Query(a,b); val[a][b]=k; val[b][a]=1-k; } return val[a][b]; } vector<int> merge_sort(int l, int r) { if (l==r) return {l}; int mid=(l+r)/2; vector<int> L=merge_sort(l,mid), R=merge_sort(mid+1,r), res; int idL=0, idR=0; while (idL<L.size() && idR<R.size()) { if (!Q(L[idL],R[idR])) res.push_back(L[idL++]); else res.push_back(R[idR++]); } while (idL<L.size()) res.push_back(L[idL++]); while (idR<R.size()) res.push_back(R[idR++]); return res; } vector<int> Solve(int N) { memset(val,-1,sizeof(val)); int n=N; v=merge_sort(0,n-1); int cnt=0,st=0,pos=-1; for (int i=1; i<n; ++i) if (Q(v[0],v[i])) { ++cnt; if (cnt==1) pos=i; else { pos=-1; break; } } if (pos!=-1) { if (!Q(v[st],v[pos])) swap(pos,st); } else { for (int i=2; i<n; ++i) { if (!Q(v[0],v[i])) { if (Q(v[i-1],v[i-3])) st=i-2; else st=i-1; } } } rev(0,st); int idx=st+1; while (idx<n) { int x=idx-1; while (!Q(v[x],v[idx]) && idx<n) ++idx; rev(x+1,idx); ++idx; } vector<int> ans(n); for (int i=0; i<n; ++i) ans[v[i]]=i; return ans; }

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

monster.cpp: In function 'std::vector<int> merge_sort(int, int)':
monster.cpp:31:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   while (idL<L.size() && idR<R.size()) {
      |          ~~~^~~~~~~~~
monster.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   while (idL<L.size() && idR<R.size()) {
      |                          ~~~^~~~~~~~~
monster.cpp:36:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   while (idL<L.size()) res.push_back(L[idL++]);
      |          ~~~^~~~~~~~~
monster.cpp:37:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   while (idR<R.size()) res.push_back(R[idR++]);
      |          ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...