結果

問題 No.161 制限ジャンケン
コンテスト
ユーザー TLwiegehtt
提出日時 2015-07-12 01:15:50
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 994 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 245 ms
コンパイル使用メモリ 38,228 KB
最終ジャッジ日時 2026-02-23 18:41:42
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0