CSES - Datatähti 2021 alku - Results
Submission details
Task:Sanalista
Sender:mikkopal
Submission time:2020-09-29 12:14:44 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.01 sdetails
#20.01 sdetails
#30.01 sdetails

Compiler report

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

Code

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


typedef long long ll; 

const int mx = 1e5;

bool ok(vector<char> v){
	char curr=v[0];
	int cnt=1;
	for (int i=1; i<v.size();i++){
		if (v[i]==curr){
			++cnt;
		}else{
			if (cnt%2){
				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+=1;
		}
	}
	cout << ans;
}

	







Test details

Test 1

Verdict:

input
1000
korvata
sopimusaika
nuhatartunta
korttiautomaatti
...

correct output
15

user output
396

Test 2

Verdict:

input
1000
pub
hansikaslokero
erikoisvalmisteinen
unijukka
...

correct output
42

user output
379

Test 3

Verdict:

input
1000
haapalastu
toipumisaika
mustalaiskieli
taidelainaamo
...

correct output
70

user output
402