Submission #79043

# Submission time Handle Problem Language Result Execution time Memory
79043 2018-10-11T00:26:19 Z psmao Sailing Race (CEOI12_race) C++14
0 / 100
200 ms 3788 KB
#include <bits/stdc++.h>
using namespace std;

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 505;

int f[maxn][maxn], g[maxn][maxn], n, sub;
VI adj[maxn];

int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
		db mps = clock();
	#endif
	sf("%d%d",&n,&sub);
	fo(i,1,n)
	{
		int x;
		while(1)
		{
			sf("%d",&x);
			if(!x) break;
			adj[i].pb(x);
		}
	}
	fo(len,2,n)
	{
		fo(i,1,n-len+1)
		{
			int j = i+len-1;
			for(auto k : adj[i])
			{
				if(k >= i && k < j) 
					gmax(f[i][j], 1 + max(f[k][j], g[k][i]));
				if(!(k > i && k <= j))
					gmax(g[i][j], 1 + max(g[k][j], f[k][i]));
			}
			for(auto k : adj[j])
			{
				if(k >= i && k < j)
					gmax(f[j][i], 1 + max(f[k][i], g[k][j]));
				if(!(k > i && k <= j))
					gmax(g[j][i], 1 + max(g[k][i], f[k][j]));
			}
		}
	}
	int ans = 0;
	fo(s,1,n) 
		for(auto t : adj[s])
			gmax(ans, max(f[s][t], g[s][t]));
	pf("%d\n",ans);
	#ifdef MPS
		pf("Time Elapsed: %.3fms\n",clock()-mps);
	#endif
	return 0;
}

Compilation message

race.cpp: In function 'int main()':
race.cpp:45:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d%d",&n,&sub);
    ^
race.cpp:51:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    sf("%d",&x);
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 632 KB Unexpected end of file - int32 expected
3 Incorrect 2 ms 720 KB Output isn't correct
4 Incorrect 2 ms 720 KB Output isn't correct
5 Incorrect 3 ms 760 KB Output isn't correct
6 Incorrect 3 ms 1060 KB Output isn't correct
7 Incorrect 4 ms 1060 KB Output isn't correct
8 Incorrect 3 ms 1060 KB Output isn't correct
9 Incorrect 4 ms 1064 KB Output isn't correct
10 Incorrect 8 ms 1064 KB Output isn't correct
11 Incorrect 5 ms 1064 KB Output isn't correct
12 Incorrect 12 ms 1416 KB Output isn't correct
13 Incorrect 21 ms 1920 KB Output isn't correct
14 Incorrect 38 ms 2388 KB Output isn't correct
15 Incorrect 107 ms 3000 KB Output isn't correct
16 Incorrect 127 ms 3180 KB Output isn't correct
17 Incorrect 109 ms 3300 KB Output isn't correct
18 Incorrect 43 ms 3300 KB Output isn't correct
19 Incorrect 161 ms 3632 KB Output isn't correct
20 Incorrect 200 ms 3788 KB Output isn't correct