Task: | Nimionese |
Sender: | wavelets |
Submission time: | 2015-11-25 18:52:44 +0200 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.07 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.05 s | details |
#7 | ACCEPTED | 0.05 s | details |
#8 | ACCEPTED | 0.05 s | details |
#9 | ACCEPTED | 0.06 s | details |
#10 | ACCEPTED | 0.07 s | details |
#11 | ACCEPTED | 0.04 s | details |
#12 | ACCEPTED | 0.05 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:87:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < word.length(); ++i) ^ input/code.cpp:97:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 1; i < syb.size(); ++i) ^ input/code.cpp:99:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int a = 0; a < syb[i].length(); ++a) ^
Code
#include <iostream> #include <string> #include <vector> #include <set> #include <unordered_set> using namespace std; unordered_set<char> hard = {'b','c','d','g','k','n','p','t'}; unordered_set<char> hard_up = {'B','C','D','G','K','N','P','T'}; bool iscap(char c){return c < 'a';} bool ishard(char c){return hard.count(c) || hard_up.count(c); } char nearest_hard(char c) { int mind = 1000; bool tie = false; char tiechar = 127; char minchar = 127; const auto& vec = iscap(c) ? hard_up : hard; for (char t: vec) { int d = abs(int(c)-int(t)); if (d == mind) { tie = true; tiechar = min(t, tiechar); } else if (d < mind) { tie = false; mind = d; minchar = t; tiechar = 127; } } if (tie) return tiechar; else return minchar; } string nearest_end(char c) { int mind = 1000; bool tie = false; char tiechar = 127; char minchar = 127; vector<char> vec = {'a','o','u'}; for (char t: vec) { int d = abs(int(c)-int(t)); if (d == mind) { tie = true; tiechar = min(t, tiechar); } else if (d < mind) { tie = false; mind = d; minchar = t; tiechar = 127; } } if (tie) return string() + tiechar + "h"; else return string() + minchar + "h"; } int main() { string word; while(cin>>word) { if (!cin)break; // word[0] = nearest_hard(word[0]); // loop syllables vector<string> syb(1); for (int i = 0; i < word.length(); ++i) { char c = word[i]; if (c == '-') syb.push_back(string()); else syb.back() += c; } word = syb[0]; for (int i = 1; i < syb.size(); ++i) { for (int a = 0; a < syb[i].length(); ++a) { if (ishard(syb[i][a])) { bool cap = iscap(syb[i][a]); syb[i][a] = std::tolower(syb[0][0]); if (cap) syb[i][a] = std::toupper(syb[0][0]); } } word += syb[i]; } // if (ishard(word[word.length()-1])) { word += nearest_end(word[word.length()-1]); } cout << word << " "; } cout << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
Each hip-po dog hip hip Hooray |
correct output |
---|
Dach gipgo dogah gipoh gipoh G... |
user output |
---|
Dach gipgo dogah gipoh gipoh G... |
Test 2
Verdict: ACCEPTED
input |
---|
aa ab ac ad ae af ag ah ai aj ... |
correct output |
---|
ba bbah bcah bdah be bf bgah b... |
user output |
---|
ba bbah bcah bdah be bf bgah b... |
Test 3
Verdict: ACCEPTED
input |
---|
axx bxx cxx dxx exx fxx gxx hx... |
correct output |
---|
bxx bxx cxx dxx dxx gxx gxx gx... |
user output |
---|
bxx bxx cxx dxx dxx gxx gxx gx... |
Test 4
Verdict: ACCEPTED
input |
---|
bc-acb bd-adb bg-agb bk-akb bn... |
correct output |
---|
bcabbah bdabbah bgabbah bkabba... |
user output |
---|
bcabbah bdabbah bgabbah bkabba... |
Test 5
Verdict: ACCEPTED
input |
---|
Hip-po Aip-pop cip-pop dip-pop... |
correct output |
---|
Gipgo Bipbobah cipcocah dipdod... |
user output |
---|
Gipgo Bipbobah cipcocah dipdod... |
Test 6
Verdict: ACCEPTED
input |
---|
d d d d d d d d d d d d d d d ... |
correct output |
---|
dah dah dah dah dah dah dah da... |
user output |
---|
dah dah dah dah dah dah dah da... |
Test 7
Verdict: ACCEPTED
input |
---|
Dad dad Dad dad dad dad dad da... |
correct output |
---|
Dadah dadah Dadah dadah dadah ... |
user output |
---|
Dadah dadah Dadah dadah dadah ... |
Test 8
Verdict: ACCEPTED
input |
---|
dddddddddddddddddddddddddddddd... |
correct output |
---|
dddddddddddddddddddddddddddddd... |
user output |
---|
dddddddddddddddddddddddddddddd... |
Test 9
Verdict: ACCEPTED
input |
---|
Wpgliaku-uibagddilpynomsytuubi... |
correct output |
---|
Tpgliakuuitatttiltytomsytuutil... |
user output |
---|
Tpgliakuuitatttiltytomsytuutil... |
Test 10
Verdict: ACCEPTED
input |
---|
Fsqn-ggoou-padnrosondpf-mtsjfs... |
correct output |
---|
Gsqnggoougaggrosogggfmgsjfsagl... |
user output |
---|
Gsqnggoougaggrosogggfmgsjfsagl... |
Test 11
Verdict: ACCEPTED
input |
---|
Ojaivaeduuucykdclkyammbvozytuk... |
correct output |
---|
Njaivaeduuucykdclkyammbvozytuk... |
user output |
---|
Njaivaeduuucykdclkyammbvozytuk... |
Test 12
Verdict: ACCEPTED
input |
---|
Uprtouo-nvnabbiedq-vzogovufjaa... |
correct output |
---|
Tprtouotvtattietqvzotovufjaaee... |
user output |
---|
Tprtouotvtattietqvzotovufjaaee... |