結果

問題 No.201 yukicoderじゃんけん
ユーザー tsuishitsuishi
提出日時 2021-02-09 12:48:26
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 2,161 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 28,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 23:11:52
合計ジャッジ時間 1,936 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 0 ms
4,380 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Yukicoder №201 yukicoderじゃんけん
// https://yukicoder.me/problems/no/201
// 1万桁の数値の比較
// ***********************
// for debug
#define DEBUG

#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	ctime(...)		ctime_s(...)
#define	strlen(a)	mystr_len(a)

// for stdio
#define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define lolong long long
#define INPBUF (250+2)
static char *getword(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];}
// ***********************
// ***********************
// 外部変数
char	*pa1;
char	*pa2;
// ***********************
int main() {
	char	str[INPBUF];
	char	name1[INPBUF];
	char	name2[INPBUF];
	int		cmpval = 0;
	char	*p1, *p2;
	int		jlen1, jlen2;
	char	c;

	if((pa1 = (char*)malloc( (100000 + 2)*sizeof(char) )) == NULL ) return 13;
	if((pa2 = (char*)malloc( (100000 + 2)*sizeof(char) )) == NULL ) { free(pa1);return 13;}
	p1 = pa1;
	getword(name1);
	while((c = getchar())!= ' ' ) *p1++ = c;
	*p1 = '\0';
	jlen1 = p1 - pa1;
	getword(str);
	getword(name2);
	p2 = pa2;
	while((c = getchar())!= ' ' ) *p2++ = c;
	*p2 = '\0';
	jlen2 = p2 - pa2;

	if( jlen1 == jlen2 ) {
		p1 = pa1;
		p2 = pa2;
		while( *p1 != '\0' ) {
			if( *p1 > *p2 ) {
				cmpval = 1;
				break;
			} else if( *p1 < *p2 ) {
				cmpval = 2;
				break;
			}
			p1++;	p2++;
		}
	} else {
		if( jlen1 > jlen2 ) {
			cmpval = 1;
		} else {
			cmpval = 2;
		}
	}
	if( cmpval == 1 ) {
		printf("%s\n", name1 );
	} else if( cmpval == 2 ) {
		printf("%s\n", name2 );
	} else {
		printf("-1\n" );
	}
	free( pa2 );
	free( pa1 );
	return 0;
}

0