답안 #364005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364005 2021-02-08T00:22:17 Z super_j6 Sailing Race (CEOI12_race) C++14
5 / 100
594 ms 15468 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, k;
int dp[mxn][mxn][2], f[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], &ff = f[i[0]][i[1]][j];
		if(i[0] != i[1]) ff = max(dpc, f[i[0] + j][i[1] - !j][j]);
		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);
			}
		}
		ff = max(ff, dpc);
	}
	
	cout << ret << " " << (x % n + 1) << endl;
	
	return 0;
}
# 결과 실행 시간 메모리 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 2 ms 1004 KB Output isn't correct
5 Incorrect 3 ms 1260 KB Output isn't correct
6 Incorrect 3 ms 1388 KB Output isn't correct
7 Incorrect 7 ms 1604 KB Output isn't correct
8 Incorrect 4 ms 1900 KB Output isn't correct
9 Incorrect 9 ms 2156 KB Output isn't correct
10 Correct 27 ms 2540 KB Output is correct
11 Incorrect 14 ms 2412 KB Output isn't correct
12 Incorrect 40 ms 4844 KB Output isn't correct
13 Incorrect 72 ms 7788 KB Output isn't correct
14 Incorrect 114 ms 10988 KB Output isn't correct
15 Incorrect 391 ms 14956 KB Output isn't correct
16 Incorrect 488 ms 15468 KB Output isn't correct
17 Incorrect 387 ms 14956 KB Output isn't correct
18 Incorrect 156 ms 14444 KB Output isn't correct
19 Incorrect 593 ms 15468 KB Output isn't correct
20 Incorrect 594 ms 15468 KB Output isn't correct