結果

問題 No.1183 コイン遊び
ユーザー tsuishitsuishi
提出日時 2021-01-05 14:41:47
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 3,090 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 29,232 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-05 23:08:25
合計ジャッジ時間 8,152 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// ***********************
// for debug
#define DEBUG1


#define NOP do{}while(0)
#ifdef DEBUG
#define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0)
#define TRACECR do{printf("\n");fflush(stdout);}while(0)
#else
#define TRACE(...) NOP
#define TRACECR NOP
#endif

#define PRINCR printf("\n")
#define NOCR(strig) do{char *p;p=strchr(strig,'\n');if(p)*p='\0';}while(0)
// The out-of-date function
#define	asctime(...)	asctime_s(...)
#define	atof(a)		strtod(a,'\0')
#define	atoi(a)		((int)strtol(a,'\0'))
#define	atol(a)		strtol(a,'\0')
#define	ctime(...)		ctime_s(...)
//#define	fopen(...)		fopen_s(...)
//#define	freopen(...)	freopen_s(...)
//#define	rewind(a)		fseek(a,0L,SEEK_SET)
//#define	setbuf(a,b)		setvbuf(a,b,_IOFBF,BUFSIZ)

// for stdio
#define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
static char *getinput( char* str );

// for readaility
typedef	long long	lolong;
const int	INF = 1e9;
const int	MOD = 1e9+7;
const lolong	LINF = 1e18;
static char *getinput(char* str) {char c;char *cp;cp=&str[0];c=fgetc(stdin);while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=fgetc(stdin);}*cp='\0';return &str[0];}
#define	YES(a)	printf("%s",((a)?"YES":"NO"))
#define	Yes(a)	printf("%s",((a)?"Yes":"No"))
#define OK(a)	printf("%s",((a)?"OK":"NG"))
#define Ok(a)	printf("%s",((a)?"Ok":"Ng"))
#define	POSSIBLE(a)		printf("%s",((a)?"POSSIBLE":"IMPOSSIBLE"))
#define	Possible(a)		printf("%s",((a)?"Possible":"Impossible"))
#define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define REP1(a,b) for(int a=1;a<=(b);++a)
#define FLOOP(a,b) for(a=0;a<(b);++a)
#define FLOOP1(a,b) for(a=1;a<=(b);++a)
#define	ABS(c)	 ((c)<0?(-(c)):(c))
#define LSB(i) ((i) & -(i))

#define INPBUF 50
// ***********************
// ***********************
// ***********************
int main(void) {
	char str[INPBUF];
	int	query,val;
	int	i;
	unsigned int	cnt = 0;
	char	*aa, *bb;
	char	*a, *b;

	// init
	// ready
	INPUT(str); sscanf( str , "%d", &query );
	aa = malloc( query & sizeof(char) );
	bb = malloc( query & sizeof(char) );
	a = aa; b = bb;
	// start
	REP(i,query) {
		getinput( str );
		sscanf( str , "%d", &val );
		*a++ = (char)val;
	}

	REP(i,query) {
		getinput( str );
		sscanf( str , "%d", &val );
		*b++ = (char)val;
	}
#ifdef DEBUG
    a = aa;
	REP(i,query) {
		TRACE("%d ", *a++ );
	}
	TRACECR;
    b = bb;
	REP(i,query) {
		TRACE("%d ", *b++ );
	}
	TRACECR;
#endif

	a = aa; b = bb;
	i =0;
	while( *a == *b ) {
	    a++; b++;
		i++;
		if( i >= query ) break;
	}
    TRACE("a%d:%d %d %d\n", *a, *b, i, cnt);
	do {
		cnt++;
		if( i < query ) {
		    i++;
			while( *++a != *++b ) {
				i++;
				if( i >= query ) break;
			}
		}
        TRACE("b%d:%d %d %d\n", *a, *b, i, cnt);
		if( i < query ) {
			while( *a == *b ) {
			    a++; b++;
				i++;
				if( i >= query ) break;
			}
		}
        TRACE("c%d:%d %d %d\n", *a, *b, i, cnt);
	} while( i < query );

	printf("%d\n", cnt );

	free( aa );
	free( bb );
	return 0;
}
0