結果
問題 | No.138 化石のバージョン |
ユーザー | demu |
提出日時 | 2015-06-01 00:07:56 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,737 bytes |
コンパイル時間 | 509 ms |
コンパイル使用メモリ | 26,728 KB |
実行使用メモリ | 5,060 KB |
最終ジャッジ日時 | 2023-09-20 18:10:00 |
合計ジャッジ時間 | 1,549 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | WA | - |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | WA | - |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 1 ms
4,500 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 1 ms
4,380 KB |
testcase_28 | AC | 2 ms
4,376 KB |
testcase_29 | AC | 2 ms
4,380 KB |
testcase_30 | AC | 1 ms
4,380 KB |
testcase_31 | AC | 2 ms
5,000 KB |
testcase_32 | AC | 1 ms
4,376 KB |
testcase_33 | AC | 1 ms
4,376 KB |
testcase_34 | AC | 2 ms
4,380 KB |
testcase_35 | AC | 2 ms
4,380 KB |
ソースコード
#include <stdio.h> #include <string.h> int divide(char* part) { int length = 0; for (int i=0; i < sizeof(part)-1; i++) { if (part[i] != '\0') length++; } return length; } void separate(char org[2][12], char part[2][3][4], int length[2][3]) { for (int i = 0; i < 2; i++) { char* tp = strtok(org[i], "."); sprintf(part[i][0],"%s",tp); int count = 0; while (tp != NULL) { tp = strtok(NULL, "."); if (tp != NULL) { if (count++ == 0) sprintf(part[i][1], "%s", tp); else sprintf(part[i][2], "%s", tp); } } for (int j=0; j<3; j++) length[i][j] = divide(part[i][j]); } } void bigger(char part[2][3][4], int length[2][3]) { for (int i=0; i < 3; i++) { int sum[2] = {0,0}; if (length[0][i] > length[1][i]) { printf("YES\n"); return; } else if (length[0][i] == length[1][i]) { for (int j =0; j < length[0][i]; j++) sum[0] += (int) part[0][i][j]; for (int k =0; k < length[1][i]; k++) sum[1] += (int) part[1][i][k]; if (sum[0] > sum[1]) { printf("YES\n"); return; } else if (sum[0] < sum[1]) { printf("NO\n"); return; } } else { printf("NO\n"); return; } } printf("YES\n"); // 全て等しいとき } int main() { int sum[2] = {0,0}; int length[2][3] = {0}; char version[2][12]; char part[2][3][4]= {0}; scanf("%s %s",&version[0], &version[1]); separate(version, part, length); bigger(part, length); return 0; }