CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:mikkopal
Submission time:2020-09-29 12:51:40 +0300
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'bool ok(std::vector<char>)':
input/code.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=1; i<v.size()+1;i++){
                ~^~~~~~~~~~~
input/code.cpp:14:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (i<v.size() && v[i]==curr){
       ~^~~~~~~~~

Code

#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;


typedef long long ll; 

bool ok(vector<char> v){
	char curr=v[0];
	int cnt=1;
	for (int i=1; i<v.size()+1;i++){
		if (i<v.size() && v[i]==curr){
			++cnt;
		}else{
			if (cnt%2!=0){
				return false;
			}
			cnt=1;
			curr=v[i];
		}
	}

	return true;
}


int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	int n; cin >> n;
	int ans=0;

	for (int i=0; i<n; i++){

		string s; cin >> s;
		vector<char> v(s.begin(), s.end());
		sort(v.begin(),v.end());
		bool b = ok(v);
		if (b){
			ans++;
		}

	}
	cout << " "<<ans;
}

	







Test details

Test 1

Verdict: ACCEPTED

input
1000
korvata
sopimusaika
nuhatartunta
korttiautomaatti
...

correct output
15

user output
 15

Test 2

Verdict: ACCEPTED

input
1000
pub
hansikaslokero
erikoisvalmisteinen
unijukka
...

correct output
42

user output
 42

Test 3

Verdict: ACCEPTED

input
1000
haapalastu
toipumisaika
mustalaiskieli
taidelainaamo
...

correct output
70

user output
 70