제출 #913186

#제출 시각아이디문제언어결과실행 시간메모리
913186Faisal_Saqib마상시합 토너먼트 (IOI12_tournament)C++17
49 / 100
60 ms1624 KiB
#pragma once #include <iostream> #include <vector> using namespace std; const int NPA=5201; int cs[NPA],ce[NPA],a[NPA],mi[NPA],mx[NPA]; int GetBestPosition(int n, int c, int r, int k[], int s[], int e[]) { // Lets change the queries from the changed array to the original array for(int i=0;i<n;i++) a[i]=mi[i]=mx[i]=i; int len=n; for(int ro=0;ro<c;ro++) { int ns=a[s[ro]]; int ne=a[e[ro]]; for(int l=s[ro];l<=e[ro];l++) { ns=min(ns,mi[a[l]]); ne=max(ne,mx[a[l]]); } for(int l=s[ro];l<=e[ro];l++) { mi[a[l]]=min(ns,mi[a[l]]); mx[a[l]]=max(ne,mx[a[l]]); } for(int j=e[ro];j<len;j++) a[j+s[ro]-e[ro]]=a[j]; len=len-e[ro]+s[ro]; cs[ro]=ns; ce[ro]=ne; } int wins=0; int poss=0; a[0]=r; for(int j=0;j<(n-1);j++) a[j+1]=k[j]; for(int p=0;p<(n-1);p++) { int win=0; if(p>0) swap(a[p-1],a[p]); int back_mx=-n-1,front_mx=n+1; for(int i=0;i<p;i++) if(a[i]>a[p]) back_mx=i; for(int i=n-1;i>p;i--) if(a[i]>a[p]) front_mx=i; for(int ro=0;ro<c;ro++) { if(cs[ro]<=p and p<=ce[ro] and back_mx<cs[ro] and ce[ro]<front_mx) { win++; } } if(win>wins) { wins=win; poss=p; } } return poss; }

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

tournament.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...