結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-12 01:15:50 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 994 bytes |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 21,120 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 04:45:10 |
| 合計ジャッジ時間 | 946 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d %d %d", &hand[0], &hand[1], &hand[2]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%s", s);
| ^~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(void){
int i,j,k;
int total = 0;
int hand[4] = {0};
char s[310];
scanf("%d %d %d", &hand[0], &hand[1], &hand[2]);
scanf("%s", s);
for(i=0;i<3;i++){ // 0 win, 1 even, 2 lose
for(j=0;j<3;j++){ // 0 G, 1 C, 2 P
for(k=0;s[k] != '\0';k++){
if(i == 0){
if(hand[j] != 0){
if(j==0 && s[k] == 'C'){
hand[j]--;
s[k] = '-';
total += 3;
}else if(j==1 && s[k] == 'P'){
hand[j]--;
s[k] = '-';
total += 3;
}else if(j==2 && s[k] == 'G'){
hand[j]--;
s[k] = '-';
total += 3;
}
}
}else if(i == 1){
if(hand[j] != 0){
if(j==0 && s[k] == 'G'){
hand[j]--;
s[k] = '-';
total += 1;
}else if(j==1 && s[k] == 'C'){
hand[j]--;
s[k] = '-';
total += 1;
}else if(j==2 && s[k] == 'P'){
hand[j]--;
s[k] = '-';
total += 1;
}
}
}
}
}
}
printf("%d\n", total);
return 0;
}
TLwiegehtt