結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tsuishitsuishi
提出日時 2021-01-27 11:59:05
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 4,674 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 30,864 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-09-06 16:10:03
合計ジャッジ時間 24,583 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
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 AC 34 ms
4,380 KB
testcase_26 AC 34 ms
4,380 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 30 ms
4,380 KB
testcase_40 AC 29 ms
4,376 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 AC 8 ms
4,380 KB
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
// Yukicoder №1359
// https://yukicoder.me/problems/no/1359
// ***********************
// for debug
#define DEBUGe

#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	strlen(a)	mystr_len(a)
//#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)
#define mygc(c) (c)=getchar()
static char *getinput( char* str );
static void read1(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
static void read2(int *x, int *y){read1(x);read1(y);}
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];}
static int max(int a,int b){if(a>b){return a;}return b;}
static int min(int a,int b){if(a<b){return a;}return b;}
// for readaility
typedef	long long	lolong;
const int	INF = 1e9;
//const int	MOD = 1e9+7;
const lolong	LINF = 1e18;
#define PI	  ((double)3.141592653589793238462643383279)
#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	data_s	int
// ***********************
// ***********************
static int cmpint_asc(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
static int cmpint_desc(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
static int cmpchar_asc(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}
static int cmpchar_desc(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}
static int mystr_len(char *str){int i=0;do{if(str[i]=='\0')break;i++;if(i>9999)break;}while(1);return i;}
static int countchar(char str[],char c,int limit ) {int	cnt = 0;for(int i=0;i<limit;i++) if( str[i] == c )cnt++;return cnt;}
// ***********************
// ***********************
// ***********************
// ***********************
// ***********************
// ***********************
// 外部変数
// ***********************
int	P[20000];
int	E[20000];
int	A[20000];
int	H[20000];
long MOD = 1000000007;
lolong fastpow(long long x, long long n) {
    lolong ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD; // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1; // n を1bit 左にずらす
    }
    return ret;
}

#define INPBUF (11*3+3)
int main() {
	char	str[INPBUF];
	int		n;
	lolong	k,m;
	lolong	f;
	lolong	ftotal = 0LL;
	lolong	rmax,rmin;

	INPUT( str );
	sscanf( str,"%d %lld %lld", &n, &k, &m );
	MOD = m;
	REP(i,n) {
		getinput(str);
		sscanf(str,"%d", &P[i] );
	}
	REP(i,n) {
		getinput(str);
		sscanf(str,"%d", &E[i] );
	}
	REP(i,n) {
		getinput(str);
		sscanf(str,"%d", &A[i] );
	}
	REP(i,n) {
		getinput(str);
		sscanf(str,"%d", &H[i] );
	}
	qsort( P , n , sizeof(int) , cmpint_asc );
	qsort( E , n , sizeof(int) , cmpint_asc );
	qsort( A , n , sizeof(int) , cmpint_asc );
	qsort( H , n , sizeof(int) , cmpint_asc );

	REP(i,n) {
		rmax = max( max(P[i],E[i]), max(A[i],H[i]) );
		rmin = min( min(P[i],E[i]), min(A[i],H[i]) );
		if( rmax == rmin ) rmin = 0;
		f = fastpow( rmax - rmin ,k);
		ftotal += f;
	}
	ftotal %= m;
	printf("%lld\n", ftotal );
	return 0;
}

0