結果
| 問題 |
No.1109 調の判定
|
| コンテスト | |
| ユーザー |
tsuishi
|
| 提出日時 | 2021-04-15 12:55:27 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,950 bytes |
| コンパイル時間 | 850 ms |
| コンパイル使用メモリ | 32,896 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-01 11:52:49 |
| 合計ジャッジ時間 | 2,272 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
extern int getchar_unlocked(void);
extern int putchar_unlocked(int);
#define DEBUG
#define NOP do{}while(0)
#define gc(d) (d)=getchar_unlocked()
#define pc(d) putchar_unlocked(d)
#define PRINCR pc('\n')
#ifdef DEBUG
#include <time.h>
#define TRACE(...) do{fprintf(stderr,__VA_ARGS__);}while(0)
#define TRACECR do{fprintf(stderr,"\n");}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
#define NOCR(strig) do{char *p;p=strchr(strig,'\n');if(p)*p='\0';}while(0)
#define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define REP1(a,b) for(int a=1;a<=(int)(b);++a)
static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];gc(c);while(c!=EOF){if((c==' ')||(c=='\n'))break;*cp++=c;gc(c);}*cp='\0';return &str[0];}
#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 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);}
#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
static int GETLINEINT(void) {char s[34];GETLINE(s);return atoi(s);}
static int GETWORDINT(void) {char s[34];GETWORD(s);return atoi(s);}
static int cmpint123(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
static int cmpint321(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
#define ull unsigned long long
#define ui unsigned int
// *********************
#define USEKEY (7)
int D[USEKEY] = { 0, 2, 4, 5, 7, 9,11 };
int score[14];
int chance = 12;
// *********************
int main( void ) {
int N,bad,ans=99;
// read
N = GETWORDINT();
REP(i,N) {
score[i] = GETWORDINT();
}
DEBUGSTART();
REP(y,12) {
bad = 0;
REP(i,N) {
int aru = 0;
REP(k,USEKEY) {
if( score[i] == (D[k]+y) % 12 ) {
aru = 1;
break;
}
}
if( !aru ) {
bad = 1;
TRACE("nai(%d) %d:", y,score[i]);
REP(h,USEKEY) TRACE(",%d", (D[h]+y) %12);
TRACECR;
break;
}
}
if( bad ) {
chance--;
} else {
ans = y;
TRACE("aru(%d)\n", y);
}
}
if( chance == 1 ) {
printf("%d\n",ans);
} else {
printf("-1\n");
}
TRACE("chance=%d\n",chance);
DEBUGEND();
}
tsuishi