結果
問題 | No.635 自然門松列 |
ユーザー | tsuishi |
提出日時 | 2021-02-19 18:52:25 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,767 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 32,128 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 08:45:29 |
合計ジャッジ時間 | 1,450 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.c: In function 'GETWORD': main.c:38:63: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration] 38 | static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];c=getchar_unlocked();while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=getchar_unlocked();}*cp='\0';return &str[0];} | ^~~~~~~~~~~~~~~~ main.c: In function 'main': main.c:23:16: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration] 23 | #define PRINCR putchar_unlocked('\n') | ^~~~~~~~~~~~~~~~ main.c:124:25: note: in expansion of macro 'PRINCR' 124 | PRINCR; | ^~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <ctype.h> // Yukicoder №635 自然門松列 // https://yukicoder.me/problems/no/635 // *********************** // for debug #define DEBUGd // ----------- #define NOP do{}while(0) #ifdef DEBUG #define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0) #define TRACECR do{putchar_unlocked('\n');fflush(stdout);}while(0) #else #define TRACE(...) NOP #define TRACECR NOP #endif #define PRINCR putchar_unlocked('\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) //#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 GETLINE(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 *GETWORD( char* str ); static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];c=getchar_unlocked();while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=getchar_unlocked();}*cp='\0';return &str[0];} #define GETINTS(a,b) {char s[34];int *ap=a;REP(i,b){GETWORD(s);*ap++=atoi(s);}} 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) 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 MABS(c) ((c)<0?(-(c)):(c)) #define LSB(i) ((i) & -(i)) #define INPBUF (250+2) #define DI_KADOMATU 50 #define DI_ASC 123 #define DI_DESC 321 // *********************** // *********************** 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;} static int absi(int c) {if(c<0){return -c;}else{return c;}} static double mind(double a,double b){if(a<b){return a;}return b;} // *********************** // 外部変数 // *********************** // *********************** // *********************** // *********************** // *********************** // *********************** // *********************** // *********************** int kadomatu( double aa, double bb, double cc ) { long a= aa * 1000; long b= bb * 1000; long c= cc * 1000; if( a == b ) return 0; // 同じ数値 if( a == c ) return 0; // 同じ数値 if( b == c ) return 0; // 同じ数値 if( ( a < b )&&( b < c ) ) return DI_ASC; // 昇順 if( ( a > b )&&( b > c ) ) return DI_DESC; // 降順 if( ( a < b )&&( b > c ) ) return DI_KADOMATU; // 門松 if( ( a > b )&&( b < c ) ) return DI_KADOMATU; // 門松 return 0; // ??? } // *********************** int main() { int query; double a1,a2,a3; double m1,m2,m3; int modef,model; query = GETLINEINT(); REP(i,query) { a1 = (double)GETWORDINT(); a2 = (double)GETWORDINT(); a3 = (double)GETWORDINT(); m1 = (double)GETWORDINT(); m2 = (double)GETWORDINT(); m3 = (double)GETWORDINT(); modef = kadomatu( a1, a2, a3 ); TRACE("%d %d %d:(%d)", (int)a1, (int)a2, (int)a3, modef); if( modef == DI_KADOMATU ) { YES(1); PRINCR; } else { model = kadomatu( a1+(double)m1*360., a2+(double)m2*360., a3+(double)m3*360. ); if( model != DI_KADOMATU ) { model = kadomatu( a1+(double)m1*10., a2+(double)m2*10., a3+(double)m3*10. ); } if( model != DI_KADOMATU ) { double Bb = a3 - a1; double aA = m1 - m3; double xx = Bb / aA; double ed = xx + 0.5; double m1m,m2m,m3m; if( xx >= 0. ) { TRACE("CROSS%lf ",xx); xx -= 0.5 ; if( xx > 0.) xx = 0.; a1 = a1 + (double)m1 * xx; a2 = a2 + (double)m2 * xx; a3 = a3 + (double)m3 * xx; m1m = (double)m1/50.; m2m = (double)m2/50.; m3m = (double)m3/50.; do{ a1 = a1 + m1m; a2 = a2 + m2m; a3 = a3 + m3m; model = kadomatu( a1, a2, a3 ); if(model == DI_KADOMATU ) { double mini = mind(a1,mind(a2,a3)); TRACE("OK![%.16lf %.16lf %.16lf,%f]",a1-mini,a2-mini,a3-mini); break; } xx += (1. / 50.); } while( xx < ed ); } model = kadomatu( a1, a2, a3 ); } if( model == DI_KADOMATU ) { YES(1); PRINCR; } else { YES(0); PRINCR; } } } return 0; }