Submission #797040

# Submission time Handle Problem Language Result Execution time Memory
797040 2023-07-29T05:10:42 Z Tunglam07 Kamenčići (COCI21_kamencici) C++17
70 / 70
1 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
    int n, k; 
	cin >> n >> k;
	vector<char> a(n+1);
	for(int i=1;i<=n;i++) 
	{
		cin >> a[i];
	}
	vector<int> fi(n+1), se(n+2);
	fi[0]=0;
	se[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='C') 
		{
			fi[i]=fi[i-1]+1;
		}
		else 
		{
			fi[i]=0;
		}
	}
	for(int i=n;i>=1;i--)
	{
		if(a[i]=='C') 
		{
			se[i]=se[i+1]+1;
		}
		else 
		{
			se[i]=0;
		}
	}
 
	int temp=0, l=1, r=n, ka=0, kb=0;
	while(l<=r)
	{
		temp++;
		if(a[l]=='P')
		{
			l++;
			continue;
		}
		else if(a[r]=='P')
		{
			r--;
			continue;
		}
		if(temp%2==1) 
		{
			ka++;
		}
		else 
		{
			kb++;
		}	
		if(ka>=k)
		{
			cout << "NE" << "\n";
			return 0;
		}
		else if(kb>=k)
		{
			cout << "DA" << "\n";
			return 0;
		}
		if(se[l]>=fi[r]) 
		{
			l++;
		}
		else 
		{
			r--;
		}
	}
	cout << "DA" << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 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 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 316 KB Output is correct