Submission #423625

#TimeUsernameProblemLanguageResultExecution timeMemory
423625lycTable Tennis (info1cup20_tabletennis)C++14
0 / 100
3073 ms59076 KiB
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(),(x).end() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for(int i=(a);i>=(b);--i) const int mxN = 150001; const int mxK = 401; int N, K; int A[mxN]; map<int,int> dpL[mxN], dpR[mxN]; map<int,int> paL[mxN], paR[mxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; N += K; FOR(i,1,N){ cin >> A[i]; } if (N-K == 1) { cout << A[1] << '\n'; return 0; } else if (N-K == 2) { cout << A[1] _ A[2] << '\n'; return 0; } FOR(i,2,N){ FOR(j,max(1,i-K-1),i-1){ int diff = A[i]-A[j]; int r = dpL[j].count(diff) ? dpL[j][diff]+1 : 2; if (!dpL[i].count(diff) || dpL[i][diff] < r) { dpL[i][diff] = r; paL[i][diff] = j; } } } RFOR(i,N-1,1){ FOR(j,i+1,min(N,i+K+1)){ int diff = A[j]-A[i]; int r = dpR[j].count(diff) ? dpR[j][diff]+1 : 2; if (!dpR[i].count(diff) || dpR[i][diff] < r) { dpR[i][diff] = r; paR[i][diff] = j; } } } map<int,int> slide; FOR(i,1,N){ for (auto& x : dpR[i]) { if (slide.count(x.first) && min(dpL[slide[x.first]][x.first], x.second)*2 >= N-K) { //cout << "YES" _ x.first _ slide[x.first] _ i << endl; int a = slide[x.first], b = i; vector<int> ans; while (SZ(ans) < (N-K)/2) ans.push_back(a), a = paL[a][x.first]; reverse(ALL(ans)); while (SZ(ans) < N-K) ans.push_back(b), b = paR[b][x.first]; for (int& x : ans) { cout << x << ' '; } cout << endl; return 0; } } for (auto& x : dpL[i]) { if (!slide.count(x.first) || dpL[slide[x.first]][x.first] < x.second) { slide[x.first] = i; } } } assert(false); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...