Submission #283587

# Submission time Handle Problem Language Result Execution time Memory
283587 2020-08-26T02:15:51 Z arnold518 World of Tank (innopolis2018_final_E) C++14
0 / 100
3 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 5000;
const int MAXM = 1e6;

int N, M1, M2, T;
int A[MAXM+10], B[MAXM+10];
int S[10][MAXN+10];

int bef[10][MAXN+10];

vector<int> solve(pii s, pii e)
{
	memset(bef, -1, sizeof(bef));
	queue<pii> Q;
	Q.push(s); bef[s.first][s.second]=0;
	while(!Q.empty())
	{
		pii now=Q.front(); Q.pop();
		if(!S[now.first][now.second+1] && bef[now.first][now.second+1]==-1)
		{
			bef[now.first][now.second+1]=1;
			Q.push({now.first, now.second+1});
		}
		if(!S[3-now.first][now.second] && bef[3-now.first][now.second]==-1)
		{
			bef[3-now.first][now.second]=2;
			Q.push({3-now.first, now.second});
		}
	}

	pii p;
	if(e.first!=0)
	{
		if(bef[e.first][e.second]==-1) return vector<int>(1, -1);
		p=e;
	}
	else
	{
		if(bef[1][e.second]!=-1) p={1, e.second};
		else if(bef[2][e.second]!=-1) p={2, e.second};
		else return vector<int>(1, -1);
	}

	vector<int> ans;
	while(1)
	{
		if(p==s) break;
		if(bef[p.first][p.second]==1) p.second--;
		else p.first=3-p.first, ans.push_back(p.second);
	}
	
	reverse(ans.begin(), ans.end());
	return ans;
}

int main()
{
	scanf("%d%d%d%d", &N, &M1, &M2, &T);
	for(int i=1; i<=M1; i++) scanf("%d", &A[i]), S[1][A[i]]=1;
	for(int i=1; i<=M2; i++) scanf("%d", &B[i]), S[2][B[i]]=1;

	vector<int> NO; NO.push_back(-1);
	vector<int> V1, V2;
	V1=solve({1, 0}, {0, N+1});
	if(V1!=NO)
	{
		printf("%d\n", V1.size());
		for(auto it : V1) printf("%d ", it); printf("\n");
		printf("0\n");
		return 0;
	}
	for(int i=1; i<=M1; i++)
	{
		if(A[i]<T) continue;
		S[1][A[i]]=0;

		V1=solve({1, 0}, {1, A[i]-1});
		V2=solve({1, A[i]}, {0, N+1});

		if(V1!=NO && V2!=NO)
		{
			printf("%d\n", V1.size()+V2.size());
			for(auto it : V1) printf("%d ", it); printf("\n");
			for(auto it : V2) printf("%d ", it); printf("\n");
			printf("1\n");
			printf("%d 1\n", A[i]-1);
			return 0;
		}

		S[1][A[i]]=1;
	}
	for(int i=1; i<=M2; i++)
	{
		if(B[i]<T) continue;
		S[2][B[i]]=0;

		V1=solve({1, 0}, {2, B[i]-1});
		V2=solve({2, B[i]}, {0, N+1});

		if(V1!=NO && V2!=NO)
		{
			printf("%d\n", V1.size()+V2.size());
			for(auto it : V1) printf("%d ", it); printf("\n");
			for(auto it : V2) printf("%d ", it); printf("\n");
			printf("1\n");
			printf("%d 2\n", B[i]-1);
			return 0;
		}
		S[2][B[i]]=1;
	}
	printf("No\n");
}

Compilation message

E.cpp: In function 'int main()':
E.cpp:73:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   73 |   printf("%d\n", V1.size());
      |           ~^     ~~~~~~~~~
      |            |            |
      |            int          std::vector<int>::size_type {aka long unsigned int}
      |           %ld
E.cpp:74:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   74 |   for(auto it : V1) printf("%d ", it); printf("\n");
      |   ^~~
E.cpp:74:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   74 |   for(auto it : V1) printf("%d ", it); printf("\n");
      |                                        ^~~~~~
E.cpp:88:13: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   88 |    printf("%d\n", V1.size()+V2.size());
      |            ~^     ~~~~~~~~~~~~~~~~~~~
      |             |              |
      |             int            std::vector<int>::size_type {aka long unsigned int}
      |            %ld
E.cpp:89:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   89 |    for(auto it : V1) printf("%d ", it); printf("\n");
      |    ^~~
E.cpp:89:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   89 |    for(auto it : V1) printf("%d ", it); printf("\n");
      |                                         ^~~~~~
E.cpp:90:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   90 |    for(auto it : V2) printf("%d ", it); printf("\n");
      |    ^~~
E.cpp:90:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   90 |    for(auto it : V2) printf("%d ", it); printf("\n");
      |                                         ^~~~~~
E.cpp:108:13: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
  108 |    printf("%d\n", V1.size()+V2.size());
      |            ~^     ~~~~~~~~~~~~~~~~~~~
      |             |              |
      |             int            std::vector<int>::size_type {aka long unsigned int}
      |            %ld
E.cpp:109:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  109 |    for(auto it : V1) printf("%d ", it); printf("\n");
      |    ^~~
E.cpp:109:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  109 |    for(auto it : V1) printf("%d ", it); printf("\n");
      |                                         ^~~~~~
E.cpp:110:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  110 |    for(auto it : V2) printf("%d ", it); printf("\n");
      |    ^~~
E.cpp:110:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  110 |    for(auto it : V2) printf("%d ", it); printf("\n");
      |                                         ^~~~~~
E.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   64 |  scanf("%d%d%d%d", &N, &M1, &M2, &T);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E.cpp:65:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |  for(int i=1; i<=M1; i++) scanf("%d", &A[i]), S[1][A[i]]=1;
      |                           ~~~~~^~~~~~~~~~~~~
E.cpp:66:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   66 |  for(int i=1; i<=M2; i++) scanf("%d", &B[i]), S[2][B[i]]=1;
      |                           ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Expected Yes or No but "2" was found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Expected Yes or No but "2" was found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB [No solution found] n = 20, m1 = 12, m2 = 9, t = 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Expected Yes or No but "2" was found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Expected Yes or No but "2" was found
2 Halted 0 ms 0 KB -