CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Sanat
Sender:
Submission time:2015-12-21 11:35:32 +0200
Language:C++
Status:READY
Result:54
Feedback
groupverdictscore
#1ACCEPTED54
Test results
testverdicttimescore
#1ACCEPTED0.28 s54details

Compiler report

input/code.cpp: In function 'std::string p(std::string)':
input/code.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<s.size(); ++i){
                  ^
input/code.cpp: In function 'void pr(std::string, int)':
input/code.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<s.size(); ++i){
                  ^
input/code.cpp:41:13: warning: array subscript has type 'char' [-Wchar-subscripts]
     ++z[s[i]][l];
             ^
input/code.cpp: In function 'bool ien(std::string)':
input/code.cpp:67:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<s.size(); ++i){ srk+=(vwl(s[i]))?'1':'0';
                  ^
input/code.cpp:68:29: warning: array subscript has type 'char' [-Wchar-subscripts]
     double s0=(double)z[s[i]][0]/ltr[0];
                             ^
input/code.cpp:69:29: warning: array subscript...

Code

#include <iostream>
#include <sstream>
#include <map>
#include <set>
using namespace std;
int n;


int z[255][2];

map<string, int> rk[2];
set<string> u[2];
int ltr[2];
int snt[2];

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


string p(string s){
  string o;
  for (int i=0; i<s.size(); ++i){
    if ('A'<=s[i] && s[i]<='Z') o+=s[i]+('a'-'A');
    else if ('a'<=s[i] && s[i]<='z') o+=s[i];
    if (s[i]<0) return "";
  }
  return o;
}

void pr(string s, int l){
  s=p(s);
  if (s.size()<4 || s.size()>12) return;
  
  if (u[l].count(s)) return;
  u[l].insert(s);
  
  string srk="";
  for (int i=0; i<s.size(); ++i){
    ++ltr[l];
    ++z[s[i]][l];
    srk+=(vwl(s[i]))?'1':'0';
  }
  ++snt[l];
  ++rk[l][srk];
}

void prpr(){
  string sana;
  stringstream sfi;
  stringstream efi;
  sfi<< "Ohjeet   Tehtävät  Jokaisessa tehtävässä on tarkoituksena laatia ohjelma, joka lukee syötteen, ratkaisee ongelman tehokkaasti ja tulostaa vastauksen.  Tehtävän yhteydessä on ilmoitettu, paljonko aikaa ja muistia ohjelma saa käyttää yhden syötteen käsittelyyn.  Kun lähetät koodin palvelimelle, sitä testataan joukolla testitapauksia. Saat pisteitä koodin toimivuuden ja tehokkuuden perusteella.  Voit lähettää samaan tehtävään useita koodeja. Kokonaispisteisiin vaikuttaa koodi, joka tuottaa korkeimman pistemäärän.  Sallitut ohjelmointikielet ovat C++, Java, Python (versiot 2 ja 3) sekä Haskell. Lisäksi yleensä C-koodin voi kääntää C++:na.  Esimerkkitehtävä  Tarkastellaan esimerkkinä seuraavaa tehtävää:  Tehtäväsi on laskea kahden kokonaisluvun summa. Syötteen ainoalla rivillä on kaksi kokonaislukua a ja b. Ohjelmasi tulee tulostaa lukujen summa a+b.  Esimerkkisyöte: 4 7  Esimerkkituloste: 11  Tehtävän voi ratkaista seuraavilla koodeilla:";
  efi<< "Check whether eofbit is set Returns true if the eofbit error state flag is set for the stream.  This flag is set by all standard input operations when the End-of-File is reached in the sequence associated with the stream.  Note that the value returned by this function depends on the last operation performed on the stream (and not on the next).  Operations that attempt to read at the End-of-File fail, and thus both the eofbit and the failbit end up set. This function can be used to check whether the failure is due to reaching the End-of-File or to some other reason.  Parameters none  Return Value true if the stream's eofbit error state flag is set (which signals that the End-of-File has been reached by the last input operation). false otherwise. ";
  while (sfi.eof()==0){
    sfi >> sana;
    pr(sana, 1);
  }
  while (efi.eof()==0){
    efi >> sana;
    pr(sana, 0);
  }
}

bool ien(string s){
  double v=0;
  string srk="";
  for (int i=0; i<s.size(); ++i){ srk+=(vwl(s[i]))?'1':'0';
    double s0=(double)z[s[i]][0]/ltr[0];
    double s1=(double)z[s[i]][1]/ltr[1];
    if (s0 || s1) v+=(s1-s0)/(s0+s1);
  }
  double rk0=(double)rk[0][srk]/snt[0];
  double rk1=(double)rk[1][srk]/snt[1];
  if (rk0 || rk1) v+=10*(double)(rk1-rk0)/(rk0+rk1);
  return v<0;
}


int main(){
  prpr();
  cin >> n;
  for (int i=0; i<n; ++i){
    string s;
    cin >> s;
    if (ien(s)) cout << "QAQ\n";
    else cout << "10-4\n";
  }
}

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
10-4
10-4
...