CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Sanat
Sender:OOliOO
Submission time:2015-12-21 14:04:17 +0200
Language:C++
Status:READY
Result:74
Feedback
groupverdictscore
#1ACCEPTED74
Test results
testverdicttimescore
#1ACCEPTED0.31 s74details

Compiler report

input/code.cpp: In function 'bool contains(std::string, std::string)':
input/code.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<s.size()-pattern.size()+1; i++)
                   ^
input/code.cpp: In function 'int max_k(std::string)':
input/code.cpp:41:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<s.size(); i++){
                   ^
input/code.cpp: In function 'int max_v(std::string)':
input/code.cpp:57:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<s.size(); i++){
                   ^
input/code.cpp: In function 'int main()':
input/code.cpp:138:33: warning: array subscript has type 'char' [-Wchar-subscripts]
             s+=fc*sqrt(fs[str[i]]), e+=fc*sqrt(fe[str[i]]);
                                 ^
input/code.cpp:138:57: warning: array subscript has type 'char' [-Wchar-subscripts]...

Code

#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <unordered_set>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <fstream>
#include <set>
#include <map>

#define MOD 1000000007
#define ll long long
//#define N (1<<50)
#define float double
#define str string

using namespace std;

bool vokaali(char c){
    return (c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')||(c=='y');
}

bool contains(string s, string pattern){
    if(pattern.size()>s.size())
        return false;
    for(int i=0; i<s.size()-pattern.size()+1; i++)
        if(s.substr(i,pattern.size())==pattern)
            return true;
    return false;
}

int max_k(string s){
    int M=0;
    int cur=0;

    for(int i=0; i<s.size(); i++){
        if(vokaali(s[i]))
            cur=0;
        else{
            cur++;
            M=max(M,cur);
        }
    }
    return M;
}


int max_v(string s){
    int M=0;
    int cur=0;

    for(int i=0; i<s.size(); i++){
        if(!vokaali(s[i]))
            cur=0;
        else{
            cur++;
            M=max(M,cur);
        }
    }
    return M;
}

double fs[256],fe[256];

int main(){
    fe['a']+=8.167;
    fe['b']+=1.492;
    fe['c']+=2.782;
    fe['d']+=4.253;
    fe['e']+=12.702;
    fe['f']+=2.228;
    fe['g']+=2.015;
    fe['h']+=6.094;
    fe['i']+=6.966;
    fe['j']+=0.153;
    fe['k']+=0.772;
    fe['l']+=4.025;
    fe['m']+=2.406;
    fe['n']+=6.749;
    fe['o']+=7.507;
    fe['p']+=1.929;
    fe['q']+=0.095;
    fe['r']+=5.987;
    fe['s']+=6.327;
    fe['t']+=9.056;
    fe['u']+=2.758;
    fe['v']+=0.978;
    fe['w']+=2.361;
    fe['x']+=0.150;
    fe['y']+=1.974;
    fe['z']+=0.074;

    fs['a']+=12.217;
    fs['b']+=0.281;
    fs['c']+=0.281;
    fs['d']+=1.043;
    fs['e']+=7.968;
    fs['f']+=0.194;
    fs['g']+=0.392;
    fs['h']+=1.851;
    fs['i']+=10.817;
    fs['j']+=2.042;
    fs['k']+=4.973;
    fs['l']+=5.761;
    fs['m']+=3.202;
    fs['n']+=8.826;
    fs['o']+=5.614;
    fs['p']+=1.842;
    fs['q']+=0.013;
    fs['r']+=2.872;
    fs['s']+=7.862;
    fs['t']+=8.750;
    fs['u']+=5.008;
    fs['v']+=2.250;
    fs['w']+=0.094;
    fs['x']+=0.031;
    fs['y']+=1.745;
    fs['z']+=0.051;

    cin.sync_with_stdio(false);
    int n=0;
    cin>>n;

    for(int i=0; i<n; i++){
        double fc=5.;

        double s=0,e=0;
        string str;
        cin>>str;
        int l=str.size();

        for(int i=0; i<l; i++)
            s+=fc*sqrt(fs[str[i]]), e+=fc*sqrt(fe[str[i]]);

        if(vokaali(str[l-1]))
            s+=10;
        else
            e+=10;

        if(!vokaali(str[str.size()-1])&&!vokaali(str[str.size()-2]))
            e+=1000;

        int vc=0;
        for(int i=0; i<str.size(); i++)
            if(vokaali(str[i]))
                vc++;

        if(max_v(str)>=2)
            s+=10;

        if(contains(str, "y")&&(contains(str,"a")||contains(str,"o")))
            e+=1000;

        for(int i=0; i<str.size()-1; i++){
            if(!vokaali(str[i])&&str[i+1]=='h')
                e+=10;
        }

        if(contains(str,"sp"))
            e+=10;
        if(contains(str,"ue"))
            e+=10;


        if(e>=s)
            cout<<"QAQ"<<endl;
        else
            cout<<"10-4"<<endl;
    }
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
95000
pursua
zoomata
mantelilastu
jamming
...

correct output
10-4
10-4
10-4
QAQ
QAQ
...

user output
10-4
10-4
10-4
QAQ
QAQ
...