CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Omenat
Sender:
Submission time:2015-12-21 11:08:14 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.06 s0details
#20.05 s0details
#30.04 s0details
#40.06 s0details
#50.05 s0details
#60.05 s0details
#70.05 s0details
#80.05 s0details
#90.06 s0details
#100.06 s0details

Compiler report

input/code.cpp: In function 'std::string p(std::string)':
input/code.cpp:22: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:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<s.size(); ++i){
                  ^
input/code.cpp:38: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:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<s.size(); ++i){
                  ^
input/code.cpp:64:22: warning: array subscript has type 'char' [-Wchar-subscripts]
     double ss=(z[s[i]][1]+z[s[i]][0]);
                      ^
input/code.cpp:64:33: warning: array subscript has type 'char' [-Wchar-subscripts]...

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];


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];
  }
  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){
    ++z[s[i]][l];
    srk+=(char)(vwl(s[i]));
  }
  ++rk[l][srk];
}

void prpr(){
  string sana;
  stringstream sfi;
  stringstream efi;
  sfi<< "Sana Sinulle on annettu n sanaa, ja tehtäväsi on päätellä jokaisesta sanasta, onko se suomea vai englantia. Syöte Syötteen ensimmäisellä rivillä on kokonaisluku n: sanojen määrä. Sitten syötteessä on n riviä, joista jokaisella on yksi sana. Jokainen sana muodostuu kirjaimista a–z ja siinä on 4–12 kirjainta. Syötteessä ei ole sanoja, jotka olisivat sekä suomea että englantia. Omenat Uolevilla ja Maijalla on n omenaa. Tiedät jokaisen omenan painon ja haluat jakaa omenat mahdollisimman tasaisesti. Syöte Syötteen ensimmäisellä rivillä on kokonaisluku n: omenoiden määrä. Seuraavalla rivillä on n kokonaislukua p1,p2,…,pn: kunkin omenan paino. On olemassa ainakin yksi tapa jakaa omenat niin, että Uolevin ja Maijan saamien omenoiden yhteispainot ovat samat. Tuloste Ohjelmasi tulee tulostaa jokaisesta omenasta, meneekö se Uoleville (1) vai Maijalle (2). Esimerkki";
  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){
    double ss=(z[s[i]][1]+z[s[i]][0]);
    if (ss==0) ss=1;
    v+=(double)(z[s[i]][1]-z[s[i]][0])/ss;
    srk+=(char)(vwl(s[i]));
  }
  double ss=(rk[0][srk]+rk[1][srk]);
  if (ss==0) ss=1;
  v+=(double)(rk[1][srk]-rk[0][srk])/ss;
  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:

input
95
779724552 231968220 985023789 ...

correct output
(empty)

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

Test 2

Verdict:

input
85
229722261 51722691 862338862 8...

correct output
(empty)

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

Test 3

Verdict:

input
97
398995377 989444445 634573915 ...

correct output
(empty)

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

Test 4

Verdict:

input
99
843687873 164010938 51269970 4...

correct output
(empty)

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

Test 5

Verdict:

input
90
864611617 418460939 773297829 ...

correct output
(empty)

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

Test 6

Verdict:

input
92
289890246 25801423 763027596 7...

correct output
(empty)

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

Test 7

Verdict:

input
89
879039800 50522278 850785072 4...

correct output
(empty)

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

Test 8

Verdict:

input
96
27192469 222283781 681532515 1...

correct output
(empty)

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

Test 9

Verdict:

input
100
186459081 254674429 394007236 ...

correct output
(empty)

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

Test 10

Verdict:

input
98
612168861 979831717 671087051 ...

correct output
(empty)

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