結果

問題 No.1859 ><<<
ユーザー tsuishitsuishi
提出日時 2022-03-03 19:00:33
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 2,135 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-24 14:44:00
合計ジャッジ時間 4,658 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 32 ms
4,380 KB
testcase_05 AC 28 ms
4,380 KB
testcase_06 AC 31 ms
4,376 KB
testcase_07 AC 25 ms
4,380 KB
testcase_08 AC 32 ms
4,376 KB
testcase_09 AC 31 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 17 ms
4,384 KB
testcase_16 AC 19 ms
4,380 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 19 ms
4,380 KB
testcase_19 AC 14 ms
4,380 KB
testcase_20 AC 20 ms
4,380 KB
testcase_21 AC 21 ms
4,380 KB
testcase_22 AC 19 ms
4,376 KB
testcase_23 AC 18 ms
4,376 KB
testcase_24 AC 22 ms
4,376 KB
testcase_25 AC 19 ms
4,380 KB
testcase_26 AC 17 ms
4,380 KB
testcase_27 AC 20 ms
4,380 KB
testcase_28 AC 18 ms
4,380 KB
testcase_29 AC 19 ms
4,380 KB
testcase_30 AC 18 ms
4,380 KB
testcase_31 AC 17 ms
4,376 KB
testcase_32 AC 20 ms
4,376 KB
testcase_33 AC 17 ms
4,380 KB
testcase_34 AC 18 ms
4,380 KB
testcase_35 AC 21 ms
4,376 KB
testcase_36 AC 20 ms
4,380 KB
testcase_37 AC 18 ms
4,376 KB
testcase_38 AC 21 ms
4,376 KB
testcase_39 AC 20 ms
4,376 KB
testcase_40 AC 24 ms
4,376 KB
testcase_41 AC 20 ms
4,380 KB
testcase_42 AC 16 ms
4,376 KB
testcase_43 AC 28 ms
4,380 KB
testcase_44 AC 29 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// for debug
#define DEBUGs
// -----------
#define NOP do{}while(0)
#ifdef DEBUGw
#include <time.h>
#define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0)
#define TRACECR do{putchar_unlocked('\n');fflush(stdout);}while(0)
static clock_t	startclock;
void DEBUGSTART(void){TRACE("--DEBUG MODE --\n");startclock=clock();}
void DEBUGEND(void){startclock=clock()-startclock;TRACE("--finish --\ntime is %.3fms\n",startclock/1000.);}
#else
#define TRACE(...) NOP
#define TRACECR NOP
void DEBUGSTART(void){return;}
void DEBUGEND(void){return;}
#endif
extern int getchar_unlocked(void);
extern int putchar_unlocked(int);
#define PRINCR do{printf("\n");fflush(stdout);}while(0)
#define GETLINE(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)
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];}
#define    GETINTS(a,b) {char s[34];int *ap=a;REP(i,b){GETWORD(s);sscanf(s,"%d", ap);ap++;}}
static int GETLINEINT(void) {char s[34];GETLINE(s);return atoi(s);}
static int GETWORDINT(void) {char s[34];GETWORD(s);return atoi(s);}
#define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
char sdn[600004];
char shi[300004];
int main(){
	long lN;
	long gt;
	int	num;
	int scc;
	char *cp0,*cpc0,*cpc1;
	int iFirst,iPrev,iNow,iEnd;

	scanf("%ld\n",&lN);
	cp0 = sdn;
	iFirst = GETWORDINT();
	iPrev = iFirst;
	for(long i=1L; i < lN-1; ++i){
		iNow = GETWORDINT();
		if( iPrev < iNow ) {
			*cp0++ = '<';
		} else {
			*cp0++ = '>';
		}
		iPrev = iNow;
		//TRACE("%d,",sdn[i]);
	}
	iEnd = GETWORDINT();
	if( iPrev < iEnd ) {
		*cp0++ = '<';
	} else {
		*cp0++ = '>';
	}
	if( iEnd < iFirst ) {
		*cp0++ = '<';
	} else {
		*cp0++ = '>';
	}

	cpc0 = sdn;
	for(long i=0L; i < lN; ++i){
		*cp0++ = *cpc0++;
	}
	*cp0 = '\0';
	GETLINE(shi);
	TRACE("%s\n",shi);
	cpc0 = strstr( sdn , shi );
	if( cpc0 == NULL ) {
		gt = -1;
	} else {
		gt = (long)(cpc0 - sdn);
	}
	printf("%ld\n", gt );
}
0