Submission #421790

# Submission time Handle Problem Language Result Execution time Memory
421790 2021-06-09T12:05:53 Z JvThunder Sequence (BOI14_sequence) C++14
34 / 100
1000 ms 884 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
typedef long long ll;

using namespace std;

int n;
int arr[100005] = {0};

bool check(int x,int d)
{
	while(x>0)
	{
		if(x%10==d) return true;
		x/=10;
	}
	return false;
}

bool tryposs(int curr)
{
	for(int i=0;i<n;i++)
	{
		if(check(curr+i,arr[i])==false) return false;
	}
	return true;
}

void dosub3()
{
	string ans = "";
	int len = 0;
	
	if(1<=arr[0] && arr[0]<=8)
	{
		n--;
		while(n>0)
		{
			n/=10;
			len++;
		}
		char c = arr[0]+'0';
		ans += c;
		for(int i=1;i<=len;i++) ans += '0';
	}
	if(arr[0]==0)
	{
		ll pow = 1;
		while(true)
		{
			if(n>pow)
			{
				n -= pow;
				pow *= 10;
				len++;
			}
			else break;
		}
		ans += "10";
		for(int i=1;i<=len;i++) ans += '0';
	}
	if(arr[0]==9)
	{
		ll pow = 1;
		while(true)
		{
			if(n>pow)
			{
				n -= pow;
				pow *= 10;
				len++;
			}
			else break;
		}

		char c = '8';
		for(int i=1;i<=len;i++) ans += c;
		ans += '9';
	}
	cout << ans << endl;
	return;
}

void solve()
{
    cin >> n;
	for(int i=0;i<n;i++) cin >> arr[i];

	bool sub3 = true;
	for(int i=0;i<n;i++)
	{
		if(arr[i]!=arr[0]) sub3 = false;
	}

	if(sub3)
	{
		dosub3();
		return;
	}

	int i = 1;
	while(true)
	{
		if(tryposs(i))
		{
			cout << i << endl;
			return;
		}
		i++;
	}
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int tc=1;
	//cin>>tc;
	for(int i=1;i<=tc;i++) solve();
 	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Execution timed out 1084 ms 204 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 5 ms 716 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 8 ms 792 KB Output is correct
10 Correct 8 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 249 ms 460 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Execution timed out 1002 ms 884 KB Time limit exceeded
12 Halted 0 ms 0 KB -