結果

問題 No.201 yukicoderじゃんけん
ユーザー papinianus
提出日時 2016-06-20 15:46:46
言語 PHP
(843.2)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 771 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 30,980 KB
実行使用メモリ 31,280 KB
最終ジャッジ日時 2024-10-11 13:40:15
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
list($first_name, $first_point, $devnull) = explode(' ', trim(fgets(STDIN)));
list($second_name, $second_point, $devnull) = explode(' ', trim(fgets(STDIN)));
if(my_strcmp($first_point,$second_point)==0) {
    echo '-1';
} else if(my_strcmp($first_point,$second_point)>0) {
    echo $first_name;
} else {
    echo $second_name;
}
echo PHP_EOL;
function my_strcmp($str1, $str2) {
    $len1 = strlen($str1);
    $len2 = strlen($str2);
    if($len1 > $len2) {
        return 1;
    } else if($len2 > $len1) {
        return -1;
    } else {
        for($i = 0; $i < $len1; $i++){
            if($str1[$i] > $str2[$i]) {
                return 1;
            } else if($str1[$i] < $str2[$i]) {
                return -1;
            }
        }
        return 0;
    }
}
0