結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー bal4u
提出日時 2019-08-11 06:35:03
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 2,786 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 07:31:20
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:10:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
   10 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:18:24: note: in expansion of macro 'gc'
   18 |         int n = 0, c = gc();
      |                        ^~
main.c: In function 'out':
main.c:11:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
   11 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:28:17: note: in expansion of macro 'pc'
   28 |         if (!n) pc('0');
      |                 ^~

ソースコード

diff #
プレゼンテーションモードにする

// yukicoder: No.447 (2)
// bal4u 2019.8.11
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
////
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in() { //
int n = 0, c = gc();
// while (isspace(c)) c = gc();
do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
return n;
}
void out(int n) { //
int i;
char b[20];
if (!n) pc('0');
else {
i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
while (i--) pc(b[i]);
}
}
void ins(char *s) { //  
do *s = gc();
while (*s++ > ' ');
*(s-1) = 0;
}
void outs(char *s) { while (*s) pc(*s++); } //
////
#define HASHSIZ 100003
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;
int insert(char *s, int id) {
unsigned long long i;
int j; char *p; HASH *tp;
i = 0, p = s;
for (j = 0; *p && j < 12; j++) i = (i << 5) + (*p++ +1-'a');
tp = hash + (int)(i % HASHSIZ);
while (tp->s != NULL) {
if (!strcmp(tp->s, s)) return tp->id;
if (++tp == hashend) tp = hash;
}
tp->s = s, tp->id = id;
return -1;
}
////
typedef struct { char *name; int sum, score[28], tim; } TBL;
TBL tbl[4004]; int sz;
int N; //
int L[28]; //
int T; //
char name[4004][18]; //
int ord[28]; // AC
int cmp(const void *u, const void *v) { //
int t;
if (t = ((TBL *)v)->sum - ((TBL *)u)->sum) return t; //
return ((TBL *)u)->tim - ((TBL *)v)->tim; //
}
int calc(int i) { //
return (int)(50*L[i] + 50*L[i]/(0.8 + 0.2* ++ord[i]) + 0.00005); // 0.005
}
int main()
{
int i, j, id, p;
N = in();
for (i = 0; i < N; i++) L[i] = in(); //
T = in();
for (i = 0; i < T; i++) {
ins(name[sz]); //
if ((id = insert(name[sz], sz)) < 0) { //
id = sz; //
tbl[id].name = name[sz]; //
sz++; // AC調
}
p = gc()-'A', gc(); // AC
tbl[id].sum += tbl[id].score[p] = calc(p); //
tbl[id].tim = i;
}
qsort(tbl, sz, sizeof(TBL), cmp); //
for (i = 0; i < sz; i++) {
out(i+1); //
pc(' '), outs(tbl[i].name); //
for (j = 0; j < N; j++) pc(' '), out(tbl[i].score[j]);
pc(' '), out(tbl[i].sum), pc('\n');
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0