Submission #940366

# Submission time Handle Problem Language Result Execution time Memory
940366 2024-03-07T08:37:35 Z vjudge1 Sequence (BOI14_sequence) C++17
0 / 100
233 ms 203024 KB
// in the name of God
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define mk make_pair
#define ppb pop_back
#define endl '\n'
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define file() freopen("input.txt", "r", stdin);
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9 + 7, maxn = 1e7 + 10, sq = 3163, inf = 1e18 + 10, lg = 25, pp = 4447, modd = 1e9 + 9;

int n;
string a;
bool b[maxn][10];

signed main(){
	fast();//file();
	for(int i = 0; i < maxn; ++i){
		string s = to_string(i);
		for(int j = 0; j < s.size(); ++j) b[i][s[j]] = true;
	}
	cin >> n;
	for(int i = 0; i < n; ++i) {int x; cin >> x; a += ((char) x + '0');}
	for(int i = 1; i <= maxn; ++i){
		bool bol = true;
		for(int j = 0; j < n; ++j){
			if(!b[i + j][a[j]]) {bol = false; break;}
		}
		if(bol){
			cout << i;
			return 0;
		}
	}
}
// Happiness can be found even in the darkest of times,
// if one only remembers to turn on the light.

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:29:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for(int j = 0; j < s.size(); ++j) b[i][s[j]] = true;
      |                  ~~^~~~~~~~~~
sequence.cpp:29:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   29 |   for(int j = 0; j < s.size(); ++j) b[i][s[j]] = true;
      |                                              ^
sequence.cpp:36:21: warning: array subscript has type 'char' [-Wchar-subscripts]
   36 |    if(!b[i + j][a[j]]) {bol = false; break;}
      |                     ^
# Verdict Execution time Memory Grader output
1 Runtime error 231 ms 199184 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 233 ms 198832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 211 ms 198992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 223 ms 203024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -