結果
| 問題 |
No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-08-10 19:27:54 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,470 bytes |
| コンパイル時間 | 94 ms |
| コンパイル使用メモリ | 15,232 KB |
| 最終ジャッジ日時 | 2025-03-21 15:38:30 |
| 合計ジャッジ時間 | 2,021 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c:50:5: error: conflicting types for ‘select’; have ‘int(int, int)’
50 | int select(int s, int i) {
| ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
from /usr/include/stdlib.h:514,
from main.c:5:
/usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration of ‘select’ with type ‘int(int, fd_set * restrict, fd_set * restrict, fd_set * restrict, struct timeval * restrict)’
102 | extern int select (int __nfds, fd_set *__restrict __readfds,
| ^~~~~~
ソースコード
// 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 (i < N && 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