Submission #720653

# Submission time Handle Problem Language Result Execution time Memory
720653 2023-04-08T19:55:07 Z Lalic Kamenčići (COCI21_kamencici) C++17
70 / 70
1 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5+10;

int main(){
  	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    // freopen("shuffle.in","r",stdin);
    // freopen("shuffle.out","w",stdout);

    int n, k; cin >> n >> k;

	vector<char> arr(n+1);
	for(int i=1;i<=n;i++) cin >> arr[i];

	vector<int> qntR(n+1), qntL(n+2);
	qntR[0]=qntL[n+1]=0;

	for(int i=1;i<=n;i++){
		if(arr[i]=='C') qntR[i]=qntR[i-1]+1;
		else qntR[i]=0;
	}
	for(int i=n;i>=1;i--){
		if(arr[i]=='C') qntL[i]=qntL[i+1]+1;
		else qntL[i]=0;
	}

	int temp=0, l=1, r=n, antun=0, branka=0;
	while(l<=r){
		temp++;

		if(arr[l]=='P'){
			l++;
			continue;
		}
		else if(arr[r]=='P'){
			r--;
			continue;
		}

		if(temp%2==1) antun++;
		else branka++;

		if(antun>=k){
			cout << "NE\n";
			return 0;
		}
		else if(branka>=k){
			cout << "DA\n";
			return 0;
		}

		if(qntL[l]>=qntR[r]) l++;
		else r--;
	}

	cout << "DA\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct