結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー | tsuishi |
提出日時 | 2021-01-27 12:58:31 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 369 ms / 2,000 ms |
コード長 | 5,184 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 33,408 KB |
実行使用メモリ | 5,932 KB |
最終ジャッジ日時 | 2024-06-24 11:30:03 |
合計ジャッジ時間 | 22,095 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 189 ms
5,376 KB |
testcase_04 | AC | 189 ms
5,376 KB |
testcase_05 | AC | 175 ms
5,376 KB |
testcase_06 | AC | 177 ms
5,376 KB |
testcase_07 | AC | 259 ms
5,376 KB |
testcase_08 | AC | 264 ms
5,376 KB |
testcase_09 | AC | 70 ms
5,376 KB |
testcase_10 | AC | 70 ms
5,376 KB |
testcase_11 | AC | 323 ms
5,376 KB |
testcase_12 | AC | 330 ms
5,376 KB |
testcase_13 | AC | 208 ms
5,376 KB |
testcase_14 | AC | 212 ms
5,376 KB |
testcase_15 | AC | 185 ms
5,376 KB |
testcase_16 | AC | 187 ms
5,376 KB |
testcase_17 | AC | 354 ms
5,376 KB |
testcase_18 | AC | 350 ms
5,472 KB |
testcase_19 | AC | 296 ms
5,376 KB |
testcase_20 | AC | 297 ms
5,376 KB |
testcase_21 | AC | 334 ms
5,376 KB |
testcase_22 | AC | 325 ms
5,376 KB |
testcase_23 | AC | 223 ms
5,376 KB |
testcase_24 | AC | 230 ms
5,376 KB |
testcase_25 | AC | 35 ms
5,376 KB |
testcase_26 | AC | 34 ms
5,376 KB |
testcase_27 | AC | 115 ms
5,376 KB |
testcase_28 | AC | 117 ms
5,376 KB |
testcase_29 | AC | 143 ms
5,376 KB |
testcase_30 | AC | 143 ms
5,376 KB |
testcase_31 | AC | 195 ms
5,376 KB |
testcase_32 | AC | 190 ms
5,376 KB |
testcase_33 | AC | 140 ms
5,376 KB |
testcase_34 | AC | 140 ms
5,376 KB |
testcase_35 | AC | 194 ms
5,376 KB |
testcase_36 | AC | 184 ms
5,376 KB |
testcase_37 | AC | 36 ms
5,376 KB |
testcase_38 | AC | 36 ms
5,376 KB |
testcase_39 | AC | 31 ms
5,376 KB |
testcase_40 | AC | 30 ms
5,376 KB |
testcase_41 | AC | 67 ms
5,376 KB |
testcase_42 | AC | 64 ms
5,376 KB |
testcase_43 | AC | 52 ms
5,376 KB |
testcase_44 | AC | 358 ms
5,504 KB |
testcase_45 | AC | 145 ms
5,376 KB |
testcase_46 | AC | 48 ms
5,376 KB |
testcase_47 | AC | 243 ms
5,376 KB |
testcase_48 | AC | 230 ms
5,376 KB |
testcase_49 | AC | 236 ms
5,376 KB |
testcase_50 | AC | 182 ms
5,376 KB |
testcase_51 | AC | 9 ms
5,376 KB |
testcase_52 | AC | 317 ms
5,376 KB |
testcase_53 | AC | 353 ms
5,804 KB |
testcase_54 | AC | 365 ms
5,684 KB |
testcase_55 | AC | 366 ms
5,632 KB |
testcase_56 | AC | 361 ms
5,684 KB |
testcase_57 | AC | 364 ms
5,804 KB |
testcase_58 | AC | 365 ms
5,808 KB |
testcase_59 | AC | 361 ms
5,808 KB |
testcase_60 | AC | 361 ms
5,804 KB |
testcase_61 | AC | 343 ms
5,680 KB |
testcase_62 | AC | 366 ms
5,676 KB |
testcase_63 | AC | 365 ms
5,680 KB |
testcase_64 | AC | 363 ms
5,808 KB |
testcase_65 | AC | 362 ms
5,932 KB |
testcase_66 | AC | 366 ms
5,680 KB |
testcase_67 | AC | 369 ms
5,676 KB |
testcase_68 | AC | 361 ms
5,664 KB |
testcase_69 | AC | 346 ms
5,808 KB |
testcase_70 | AC | 350 ms
5,684 KB |
testcase_71 | AC | 343 ms
5,680 KB |
testcase_72 | AC | 367 ms
5,680 KB |
testcase_73 | AC | 1 ms
5,376 KB |
testcase_74 | AC | 1 ms
5,376 KB |
testcase_75 | AC | 1 ms
5,376 KB |
testcase_76 | AC | 1 ms
5,376 KB |
testcase_77 | AC | 1 ms
5,376 KB |
ソースコード
#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 DEBUGs #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 REPLL(a,b) for(lolong a=0;a<(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; int *E; int *A; int *H; lolong 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]; lolong n; lolong k,m; lolong f; lolong ftotal = 0LL; lolong rmax,rmin; TRACE("Run\n"); INPUT( str ); sscanf( str,"%lld %lld %lld", &n, &k, &m ); MOD = m; if( m == 1 ) { printf("%d\n", 0); return 0; } P = malloc( n * sizeof(int) ); if( P == NULL ) { YES(0); return 13; } E = malloc( n * sizeof(int) ); if( E == NULL ) { free(P); YES(0);return 13; } A = malloc( n * sizeof(int) ); if( A == NULL ) { free(E); free(P); YES(0);return 13; } H = malloc( n * sizeof(int) ); if( H == NULL ) { free(A); free(E); free(P); YES(0);return 13; } REPLL(i,n) { getinput(str); sscanf(str,"%d", &P[i] ); } REPLL(i,n) { getinput(str); sscanf(str,"%d", &E[i] ); } REPLL(i,n) { getinput(str); sscanf(str,"%d", &A[i] ); } REPLL(i,n) { getinput(str); sscanf(str,"%d", &H[i] ); } TRACE("Sort.\n"); 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 ); REPLL(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 ); free( H ); free( A ); free( E ); free( P ); return 0; }