Submission #1132712

#TimeUsernameProblemLanguageResultExecution timeMemory
1132712sitingfakeSailing Race (CEOI12_race)C++20
5 / 100
21 ms2376 KiB
#include<bits/stdc++.h> using namespace std; #define execute cerr << "Time elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << "s"; #define ll long long #define ii pair<int,int> #define se second #define fi first #define iii pair<int,ii> #define all(v) v.begin(),v.end() #define bit(x,i) ((x>>(i))&1) #define off(x,i) (x^(1<<(i))) #define ms(d,x) memset(d,x,sizeof(d)) #define sitingfake 1 #define orz 1 const int mod=1e9+7; const long long linf=1e18+3; const int inf=1e9; const int maxarr=1e6+5; const double pi=acos(-1); const int dx[]={0,1,-1,0}; const int dy[]={1,0,0,-1}; const int maxn=505; int n,k; vector<int>a[maxn]; namespace sub1 { int ccw[maxn][maxn],cw[maxn][maxn]; void solve() { for(int len=2;len<=n;len++) { for(int i=1;i<=n;i++) { int j=i+len-1; if(j<=n) { for(int v:a[i]) { if(i>j) { if(v<i&&v>j) { cw[i][j]=max(cw[i][j],1+max(ccw[v][i],cw[v][j])); } else if(v!=j) { ccw[i][j]=max(ccw[i][j],1+max(ccw[v][j],cw[v][i])); } } else { if(v<i||v>j) { cw[i][j]=max(cw[i][j],1+max(ccw[v][i],cw[v][j])); } else if(v!=j) { ccw[i][j]=max(ccw[i][j],1+max(ccw[v][j],cw[v][i])); } } } } j=i-len+1; if(j>=1) { for(int v:a[i]) { if(i>j) { if(v<i&&v>j) { cw[i][j]=max(cw[i][j],1+max(ccw[v][i],cw[v][j])); } else if(v!=j) { ccw[i][j]=max(ccw[i][j],1+max(ccw[v][j],cw[v][i])); } } else { if(v<i||v>j) { cw[i][j]=max(cw[i][j],1+max(ccw[v][i],cw[v][j])); } else if(v!=j) { ccw[i][j]=max(ccw[i][j],1+max(ccw[v][j],cw[v][i])); } } } } } } ii ans={0,0}; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(ccw[i][j]>ans.fi) { ans.fi=ccw[i][j]; ans.se=i; } if(cw[i][j]>ans.fi) { ans.fi=cw[i][j]; ans.se=i; } } } cout<<ans.fi<<"\n"<<ans.se; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; for(int i=1;i<=n;i++) { int x; while(cin>>x) { if(x==0) break; a[i].push_back(x); } } if(k==0) sub1::solve(); //execute; } /* 7 0 5 0 5 0 7 0 3 0 4 0 4 3 0 2 1 0 */
#Verdict Execution timeMemoryGrader output
Fetching results...