답안 #78566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
78566 2018-10-06T12:10:30 Z hamzqq9 Sailing Race (CEOI12_race) C++14
5 / 100
1696 ms 9784 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 1000000007
#define N 505
#define MAX 5000000
#define LOG 100
#define KOK 333
using namespace std;

int n,k,x;
int ar[2*N],a[N][N],dp[2*N][2*N][2];

void f_1() {

}

void f_0() {

	int ans=-1,tut;

	/*for(int i=1;i<=2*n;i++,puts("")) {

		for(int j=1;j<=2*n;j++) {

			printf("%d ",dp[i][j]);

		}

	}*/

	for(int i=1;i<=n;i++) {

		if(dp[i][i+n-1][0]>ans) {

			ans=dp[i][i+n-1][0];
			tut=i;

		}

	}

	printf("%d\n%d\n",ans,tut);

}

void do_1() {

}

void do_0() {

	for(int len=2;len<=n;len++) {

		for(int fr=0;fr<2;fr++) {

			for(int i=1;i<=2*n;i++) {

				int beg=i-len+1;
				int en=i+len-1;

				if(beg>=1) {

					for(int j=beg+1;j<i;j++) {

						if(a[ar[i]][ar[j]]) umax(dp[i][beg][fr],max(dp[j][beg][0],dp[j][i][1])+1);

					}

					if(a[ar[i]][ar[beg]] && !fr) {

						umax(dp[i][beg][0],1);

						for(int j=beg+1;j<i;j++) {

							if(a[ar[beg]][ar[j]]) umax(dp[i][beg][0],max(dp[j][beg][1],dp[j][i][0])+2);

						}

					}

				}

				if(en<=2*n) {

					for(int j=i+1;j<en;j++) {

						if(a[ar[i]][ar[j]]) umax(dp[i][en][fr],max(dp[j][en][0],dp[j][i][1])+1);

					}

					if(a[ar[i]][ar[en]] && !fr) {

						umax(dp[i][en][0],1);

						for(int j=i+1;j<en;j++) {

							if(a[ar[en]][ar[j]]) umax(dp[i][en][0],max(dp[j][en][1],dp[j][i][0])+2);

						}

					}

				}

			}
		}

	}

}

int main() {
	
	//freopen("input.txt","r",stdin);

	scanf("%d %d",&n,&k);

	for(int i=1;i<=n;i++) {

		do {

			scanf("%d",&x);

			if(x==0) break ;

			a[i][x]=1;

		} while(1);

	}

	for(int i=1;i<=n;i++) ar[i]=ar[i+n]=i;

	do_0();
	do_1();

	if(k==0) f_0();
	else f_1();

}

Compilation message

race.cpp: In function 'int main()':
race.cpp:132:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
race.cpp:138:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&x);
    ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 4 ms 628 KB Unexpected end of file - int32 expected
3 Incorrect 3 ms 692 KB Unexpected end of file - int32 expected
4 Incorrect 3 ms 844 KB Unexpected end of file - int32 expected
5 Incorrect 5 ms 1140 KB Output isn't correct
6 Incorrect 5 ms 1236 KB Unexpected end of file - int32 expected
7 Incorrect 12 ms 1360 KB Output isn't correct
8 Incorrect 8 ms 1488 KB Unexpected end of file - int32 expected
9 Incorrect 19 ms 1636 KB Output isn't correct
10 Incorrect 18 ms 1760 KB Output isn't correct
11 Incorrect 27 ms 1760 KB Output isn't correct
12 Incorrect 96 ms 3552 KB Unexpected end of file - int32 expected
13 Incorrect 240 ms 5620 KB Unexpected end of file - int32 expected
14 Incorrect 456 ms 7720 KB Output isn't correct
15 Incorrect 1186 ms 9672 KB Unexpected end of file - int32 expected
16 Incorrect 1396 ms 9672 KB Unexpected end of file - int32 expected
17 Incorrect 1116 ms 9784 KB Unexpected end of file - int32 expected
18 Incorrect 810 ms 9784 KB Output isn't correct
19 Incorrect 1696 ms 9784 KB Unexpected end of file - int32 expected
20 Incorrect 1604 ms 9784 KB Unexpected end of file - int32 expected