結果

問題 No.201 yukicoderじゃんけん
ユーザー yuppe19 😺yuppe19 😺
提出日時 2018-12-03 21:53:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 64,700 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 02:24:15
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

struct Player {
  string name;
  string score;
  bool operator<(const Player &other) const {
    int n1 = static_cast<int>(score.size()),
        n2 = static_cast<int>(other.score.size());
    if(n1 < n2) { return true; }
    if(n2 < n1) { return false; }
    for(int i=0; i<n1; ++i) {
      if(score[i] < other.score[i]) { return true; }
      if(other.score[i] < score[i]) { return false; }
    }
    return false; // 等しいとき
  }
};

string f(Player o1, Player o2) {
  if(o1 < o2) { return o2.name; }
  if(o2 < o1) { return o1.name; }
  return "-1";
}

int main(void) {
  string a, x, unused1, b, y, unused2;
  cin >> a >> x >> unused1 >> b >> y >> unused2;
  string res = f(Player{a, x}, Player{b, y});
  cout << res << '\n';
  return 0;
}
0