結果

問題 No.423 ハムスター語初級(数詞)
ユーザー motimoti
提出日時 2016-09-22 22:36:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,235 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 173,156 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 18:54:28
合計ジャッジ時間 2,243 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string hams[2] = {"hamu", "ham"};

int main() {

  string s; cin >> s;
  int st = 0;
  int x = 0;
  rep(i, s.size()) {
    rep(j, 2) {
      if(i + hams[j].size() > s.size()) continue;
      bool ok = 1;
      rep(k, hams[j].size()) {
        if(s[i + k] != hams[j][k]) {
          ok = 0;
        }
      }
      if(ok) {
        x <<= 1;
        if(j == 0)
          x += 1;
        st += hams[j].size();
        i += hams[j].size() - 1;
      }
    }
  }

  x *= 2;
  stringstream ss;
  while(x > 0) {
    ss << hams[(1^x) & 1] << " ";
    x /= 2;
  }
  vector<string> vs;
  while(ss >> s) vs.push_back(s);
  for(int i=0; i<vs.size(); i++) cout << vs[vs.size() - 1 - i];
  cout << endl;

  return 0;
}
0