Submission #362396

#TimeUsernameProblemLanguageResultExecution timeMemory
362396super_j6Sailing Race (CEOI12_race)C++14
5 / 100
582 ms8692 KiB
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; #define endl '\n' #define ll long long #define pi pair<int, int> #define f first #define s second const int mxn = 1000; int n, k; int dp[mxn][mxn][2]; vector<int> g[mxn]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i = 0, x; i < n; i++) for(cin >> x; x; cin >> x) for(int j = 0; j < 2; j++) for(int l = 0; l < 2; l++){ g[l * n + x - 1].push_back(j * n + i); } int ret = 0, x = 0; for(int i[2] = {0}; i[0] < 2 * n; i[0]++) for(i[1] = i[0]; i[1] < 2 * n && i[1] - i[0] < n; i[1]++) for(int j = 0; j < 2; j++){ int &dpc = dp[i[0]][i[1]][j]; if(i[0] == i[1]) dpc = 1; if(dpc > ret) ret = dpc, x = i[j]; for(int l : g[i[j]]) for(int p = 0; p < 2; p++){ if((l > i[p]) == p){ int ii[2]; ii[!p] = i[!p], ii[p] = l; dp[ii[0]][ii[1]][p] = max(dp[ii[0]][ii[1]][p], dpc + 1); } } } cout << (ret - 1) << " " << (x % n + 1) << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...