Submission #364009

# Submission time Handle Problem Language Result Execution time Memory
364009 2021-02-08T02:30:42 Z super_j6 Sailing Race (CEOI12_race) C++14
0 / 100
2942 ms 22308 KB
#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, m;
int dp[mxn][mxn][2][2], f[mxn][mxn][2][2];
vector<int> g[2][mxn];
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	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++){
		int u = j * n + i, v = l * n + x - 1;
		g[0][u].push_back(v);
		g[1][v].push_back(u);
	}
	
	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++)
	for(int k = 0; k < 2; k++){
		int &dpc = dp[i[0]][i[1]][j][k];
		if(i[0] != i[1]){
			f[i[0]][i[1]][j][k] = max(dpc, f[i[0] + j][i[1] - !j][j][k]);
		} 
		
		for(int l : g[k][i[j]])
		for(int p = 0; p < 2; p++){
			if((l > i[p]) == p){
				int ii[2];
				ii[!p] = i[!p], ii[p] = l;
				if(ii[1] - ii[0] < n){
					dp[ii[0]][ii[1]][p][k] = max(dp[ii[0]][ii[1]][p][k], dpc + 1);
					ii[!p] = i[p];
					ret = max(ret, dpc + 1 + f[ii[0] + p][ii[1] - !p][p][!k]);
				}
			}
		}
	}
	
	cout << ret << " " << (x % n + 1) << endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Incorrect 1 ms 748 KB Output isn't correct
3 Incorrect 1 ms 876 KB Output isn't correct
4 Incorrect 3 ms 1152 KB Output isn't correct
5 Incorrect 6 ms 1388 KB Output isn't correct
6 Incorrect 8 ms 1516 KB Output isn't correct
7 Incorrect 25 ms 1900 KB Output isn't correct
8 Incorrect 11 ms 2028 KB Output isn't correct
9 Incorrect 33 ms 2412 KB Output isn't correct
10 Incorrect 108 ms 3052 KB Output isn't correct
11 Incorrect 51 ms 2668 KB Output isn't correct
12 Incorrect 166 ms 5740 KB Output isn't correct
13 Incorrect 285 ms 9796 KB Output isn't correct
14 Incorrect 522 ms 14700 KB Output isn't correct
15 Incorrect 1921 ms 21324 KB Output isn't correct
16 Incorrect 2533 ms 22308 KB Output isn't correct
17 Incorrect 1903 ms 21356 KB Output isn't correct
18 Incorrect 708 ms 20536 KB Output isn't correct
19 Incorrect 2901 ms 22244 KB Output isn't correct
20 Incorrect 2942 ms 22252 KB Output isn't correct