結果
| 問題 | No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-08-10 19:13:31 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,461 bytes |
| 記録 | |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 31,104 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-19 17:19:10 |
| 合計ジャッジ時間 | 4,607 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 WA * 2 |
コンパイルメッセージ
main.c: In function 'in':
main.c:9:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
9 | #define gc() getchar_unlocked()
| ^~~~~~~~~~~~~~~~
main.c:17:24: note: in expansion of macro 'gc'
17 | int n = 0, c = gc();
| ^~
main.c: In function 'out':
main.c:10:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
10 | #define pc(c) putchar_unlocked(c)
| ^~~~~~~~~~~~~~~~
main.c:26:17: note: in expansion of macro 'pc'
26 | if (!n) pc('0');
| ^~
ソースコード
// yukicoder 433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
// 2019.8.10 bal4u
#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();
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]);
}
pc('\n');
}
int N, K;
typedef struct { int id, s, p, u; } T;
T a[100005];
T b[100005]; int sz;
int f[1000005];
int cmpsp(const void *u, const void *v) {
int t; if (t = ((T *)v)->s - ((T *)u)->s) return t;
return ((T *)u)->p - ((T *)v)->p;
}
int cmpup(const void *u, const void *v) {
int t; if (t = ((T *)u)->s - ((T *)v)->s) return t;
return ((T *)u)->p - ((T *)v)->p;
}
int select(int s, int i) {
int j;
sz = 0;
while (a[i].s == s) {
b[sz].s = f[a[i].u]++, b[sz].p = a[i].p, b[sz].id = a[i].id;
sz++, i++;
}
qsort(b, sz, sizeof(T), cmpup);
for (j = 0; K && j < sz; j++) out(b[j].id), K--;
return i;
}
int main()
{
int i;
N = in(), K = in();
for (i = 0; i < N; i++) {
a[i].id = i, a[i].s = in(), a[i].p = in(), a[i].u = in();
}
qsort(a, N, sizeof(T), cmpsp);
i = 0; while (K) i = select(a[i].s, i);
return 0;
}
bal4u