結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2020-10-23 20:44:04 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,084 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 31,744 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-21 10:23:34 |
| 合計ジャッジ時間 | 994 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
コンパイルメッセージ
main.c:20:1: warning: return type defaults to 'int' [-Wimplicit-int]
20 | main(){
| ^~~~
main.c: In function 'main':
main.c:26:17: warning: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
26 | memset(hash, 0, sizeof(hash));
| ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset'
+++ |+#include <string.h>
1 | // https://yukicoder.me/submissions/349896
main.c:26:17: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
26 | memset(hash, 0, sizeof(hash));
| ^~~~~~
main.c:26:17: note: include '<string.h>' or provide a declaration of 'memset'
main.c:48:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
48 | write(1,wbuf,w-wbuf);
| ^~~~~
main.c:49:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
49 | _exit(0);
| ^~~~~
| _Exit
ソースコード
// https://yukicoder.me/submissions/349896
// // yukicoder: 120 傾向と対策:門松列(その1)
// // 2019.6.3 bal4u
// を大いに参考にした(丸パクリともいう)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
char*mmap();
#define RD(v) int v=0;{int c;while(c=*r++-48,c>=0)v=v*10+c;}
char wbuf[3000];
// 数値のハッシュ関数
#define HSIZ 1009
typedef struct { int v, f; } HASH;
HASH hash[HSIZ+5], *hashend = hash+HSIZ;
int ma1, ma2;
main(){
char*r=mmap(0l,1536l*1024,1,2,0,0l);
char*w=wbuf;
RD(t);
while(t--){
int ma1=0,ma2=0;
memset(hash, 0, sizeof(hash));
RD(n);
for(int i=n;i--;){
RD(l);
// insert
HASH *p = hash + l % HSIZ;
while (p->v && p->v!=l) {
if (++p == hashend) p = hash;
}
p->v = l, p->f++;
if (p->f > ma1) ma1++;
else if (p->f > ma2) ma2++;
}
int ans;
if (ma1 <= n/3) ans = n/3;
else if ((n-ma1)/2 >= ma2) ans = (n-ma1)/2;
else ans = n-ma1-ma2;
//printf("%d\n", ans);
if(ans>=10) *w++=0x30|ans/10;
*w++=0x30|ans%10;
*w++=10;
}
write(1,wbuf,w-wbuf);
_exit(0);
}
tails