250
class NounReform {
public:
string solve(string s){
string t, u;
t += s[ (int)s.size() - 2 ];
t += s[ (int)s.size() - 1 ];
u += s[ (int)s.size() - 1 ];
if(u == "s" || u == "z" || u == "x" || t == "ch" || t == "sh"){
return s + "es";
}
if(t == "ay" || t == "ey" || t == "iy" || t == "oy" || t == "uy"){
return s + "s";
}
if(u == "y"){
s[ (int)s.size() - 1 ] = 'i';
return s + "es";
}
return s + "s";
}
vector <string> makePlural(vector <string> n) {
vector <string> r;
for(int i=0; i<n.size(); ++i){
r.push_back( solve(n[i]) );
}
return r;
}
};
500
class XBallGame {
public:
pair<string, string> sep(string s){
string t, u;
int i;
for(i=0; i<s.size() && s[i] != '-'; ++i){
t += s[i];
}
for(++i; i<s.size(); ++i){
u += s[i];
}
return make_pair(t, u);
}
vector <string> newStatistics(vector <string> p) {
vector <string> r;
map< string, vector<string> > m;
for(int i=0; i<p.size(); ++i){
pair<string, string> s = sep( p[i] );
m[ s.first ].push_back( s.second );
}
FOR(i, m){
sort( i->second.begin(), i->second.end() );
}
for(int i=0; i<p.size(); ++i){
pair<string, string> s = sep( p[i] );
int size = m[ s.first ].size();
for(int j=0; j<size; ++j){
if( s.second == m[s.first][j] )continue;
p[i] += "," + m[s.first][j];
}
}
return r = p;
}
};
900
int t[N];
class DivisorInc {
public:
int countOperations(int n, int m) {
fill(t, t + N, inf);
t[n] = 0;
for(int i=n; i<m; ++i){
if(t[i] == inf)continue;
for(int j=2; (lli)j*(lli)j<=(lli)m; ++j){
if(i % j == 0){
int a, b;
a = i / j;
if(a != 1 && a != i && i + a < N){
t[i + a] = min(t[i + a], t[i] + 1);
}
b = i / a;
if(b != 1 && b != i && i + b < N){
t[i + b] = min(t[i + b], t[i] + 1);
}
}
}
}
return t[m] == inf ? -1 : t[m];
}
};
0 件のコメント :
コメントを投稿