Submission #537989

# Submission time Handle Problem Language Result Execution time Memory
537989 2022-03-16T02:06:53 Z thegrimbee Martian DNA (BOI18_dna) C++14
0 / 100
50 ms 6208 KB
	#include<bits/stdc++.h>
	using namespace std;
	#define int long long
	bool debug = false;
	signed main(){
		cin.tie(0);
		ios_base::sync_with_stdio(0);
		int n, k, r, temp; cin >> n >> k >> r;
		bool found = false;
		vector<int> v(n);
		for (int i = 0 ;i < n; ++i){
			cin >> v[i];
		}
		vector<int> val(k, 1e9+7);
		for (int i = 0;i < r; ++i){
			cin >> temp;
			cin >> val[temp];
		}
		int lo = 1, hi = n+1, mid = (lo + hi)/2;
		temp = 0;
		while (lo < hi-1){
			if(debug) cout << lo << ' ' << mid << ' ' << hi << "    ";
			temp = 0;
			found = false;
			vector<int> cur(n, 0);
			for (int i = 0; i < mid; ++i){
				cur[v[i]]++;
				if(cur[v[i]] == val[v[i]])temp++;
			}
			if(debug)cout << temp << ' ';
			if(temp == r){
				hi = mid;
				mid = (lo + hi)/2;
				if(debug)cout <<'\n';
				continue;
			}
			for (int i = mid; i < n && !found; ++i){
				cur[v[i]]++;
				cur[v[i-mid]]--;
				if (v[i] != v[i-mid]){
					if(cur[v[i]] == val[v[i]])temp++;
					if (cur[v[i-mid]] == val[v[i-mid]]-1)temp--;
				}
				if(debug)cout << temp << ' ' ;
				if(temp == r){
					hi = mid;
					mid = (lo + hi)/2;
					if(debug)cout<<'\n';
					found = true;
					continue;
				}
			}
			if(found)continue;
			if(debug)cout<<'\n';
			lo = mid;
			mid = (lo + hi)/2;
		}
		if(debug)cout << temp << ' ';
		if (temp != r && hi == n+1)cout << "impossible";
		else cout << hi;

	}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Incorrect 1 ms 316 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3432 KB Output is correct
2 Correct 37 ms 3412 KB Output is correct
3 Correct 24 ms 3412 KB Output is correct
4 Correct 29 ms 3456 KB Output is correct
5 Correct 37 ms 4076 KB Output is correct
6 Correct 22 ms 3432 KB Output is correct
7 Correct 23 ms 3412 KB Output is correct
8 Correct 46 ms 6208 KB Output is correct
9 Correct 35 ms 4444 KB Output is correct
10 Correct 35 ms 3832 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 372 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Incorrect 0 ms 212 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 4052 KB Output is correct
2 Correct 45 ms 3924 KB Output is correct
3 Correct 50 ms 3916 KB Output is correct
4 Incorrect 11 ms 3412 KB Output isn't correct
5 Halted 0 ms 0 KB -