解いた問題

4/21/2011

SRM312Div2

250
苦戦した。
class EsperantoNumbers {
public:
  string nameThisNumber(int x) {
    string r;
    string s[] = {"unu", "du", "tri", "kvar", "kvin", "ses", "sep", "ok", "nau"};
    if(x / 10){
      if(1 < x / 10)r += s[x / 10 - 1];
      r += "dek";
      x %= 10;
    }
    if(x){
      if(r.size())r += ' ';
      r += s[x - 1];
    }
    return r;
  }
};
500
class ParallelepipedUnion {
public:
  int getVolume(vector <string> p) {
    const int N = 100 + 1;
    bool g[N][N][N];
    fill(&g[0][0][0], &g[N-1][N-1][N], false);
    for(int i=0; i<p.size(); ++i){
      istringstream iss(p[i]);
      int x1, y1, z1;
      int x2, y2, z2;
      iss >> x1 >> y1 >> z1;
      iss >> x2 >> y2 >> z2;
      for(int x=x1; x<x2; ++x){
        for(int y=y1; y<y2; ++y){
          for(int z=z1; z<z2; ++z){
            g[x][y][z] = true;
          }
        }
      }
    }
    return count(&g[0][0][0], &g[N-1][N-1][N], true);
  }
};
1000
幾何はできる気もやる気も起きない。

0 件のコメント :

コメントを投稿