답안 #364148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364148 2021-02-08T09:59:08 Z super_j6 Sailing Race (CEOI12_race) C++14
40 / 100
456 ms 8300 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];
vector<int> g[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 = l * n + x - 1, v = j * n + i;
		if(abs(u - v) < n) g[u].push_back(v);
	}
	
	int ret = 0, x = 0;
	for(int i[2] = {0}; i[1] < 2 * n; i[1]++)
	for(i[0] = i[1]; ~i[0] && i[1] - i[0] < n; i[0]--)
	for(int j = 0; j < 2; j++){
		int &dpc = dp[i[0]][i[1]][j];
		if(dpc > ret) ret = dpc, x = i[j];
		for(int k : g[i[j]])
		for(int l = 0, ii[2]; l < 2; l++) if((k > i[l]) == l){
			ii[l] = k, ii[!l] = i[!l];
			dp[ii[0]][ii[1]][l] = max(dp[ii[0]][ii[1]][l], dpc + 1);
		}
	}
	
	cout << ret << " " << (x % n + 1) << endl;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 492 KB Output isn't correct
3 Incorrect 1 ms 620 KB Output isn't correct
4 Incorrect 2 ms 896 KB Output isn't correct
5 Correct 2 ms 876 KB Output is correct
6 Incorrect 2 ms 876 KB Output isn't correct
7 Correct 6 ms 1132 KB Output is correct
8 Incorrect 3 ms 1132 KB Output isn't correct
9 Correct 7 ms 1260 KB Output is correct
10 Correct 19 ms 1516 KB Output is correct
11 Correct 10 ms 1388 KB Output is correct
12 Incorrect 34 ms 2668 KB Output isn't correct
13 Incorrect 57 ms 4248 KB Output isn't correct
14 Correct 85 ms 5868 KB Output is correct
15 Incorrect 281 ms 7788 KB Output isn't correct
16 Incorrect 355 ms 8044 KB Output isn't correct
17 Incorrect 282 ms 7788 KB Output isn't correct
18 Correct 116 ms 7548 KB Output is correct
19 Incorrect 430 ms 8200 KB Output isn't correct
20 Incorrect 456 ms 8300 KB Output isn't correct