結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー | akakimidori |
提出日時 | 2019-06-07 02:40:56 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 3,147 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 32,384 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 09:59:47 |
合計ジャッジ時間 | 2,765 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 1 ms
5,248 KB |
testcase_12 | AC | 1 ms
5,248 KB |
testcase_13 | AC | 1 ms
5,248 KB |
testcase_14 | AC | 1 ms
5,248 KB |
testcase_15 | AC | 1 ms
5,248 KB |
testcase_16 | AC | 1 ms
5,248 KB |
testcase_17 | AC | 1 ms
5,248 KB |
testcase_18 | AC | 1 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 1 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 1 ms
5,248 KB |
testcase_25 | AC | 1 ms
5,248 KB |
testcase_26 | AC | 1 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 1 ms
5,248 KB |
testcase_29 | AC | 1 ms
5,248 KB |
testcase_30 | AC | 1 ms
5,248 KB |
testcase_31 | AC | 1 ms
5,248 KB |
testcase_32 | AC | 1 ms
5,248 KB |
testcase_33 | AC | 3 ms
5,248 KB |
testcase_34 | AC | 2 ms
5,248 KB |
testcase_35 | AC | 1 ms
5,248 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | AC | 2 ms
5,248 KB |
testcase_38 | AC | 3 ms
5,248 KB |
testcase_39 | AC | 2 ms
5,248 KB |
testcase_40 | AC | 3 ms
5,248 KB |
testcase_41 | AC | 3 ms
5,248 KB |
testcase_42 | AC | 3 ms
5,248 KB |
testcase_43 | AC | 3 ms
5,248 KB |
testcase_44 | AC | 17 ms
5,248 KB |
testcase_45 | AC | 16 ms
5,248 KB |
testcase_46 | AC | 16 ms
5,248 KB |
testcase_47 | AC | 17 ms
5,248 KB |
testcase_48 | AC | 17 ms
5,248 KB |
testcase_49 | AC | 3 ms
5,248 KB |
testcase_50 | AC | 3 ms
5,248 KB |
testcase_51 | AC | 3 ms
5,248 KB |
testcase_52 | AC | 3 ms
5,248 KB |
testcase_53 | AC | 17 ms
5,248 KB |
testcase_54 | AC | 17 ms
5,248 KB |
testcase_55 | AC | 16 ms
5,248 KB |
testcase_56 | AC | 17 ms
5,248 KB |
testcase_57 | AC | 16 ms
5,248 KB |
testcase_58 | AC | 17 ms
5,248 KB |
testcase_59 | AC | 17 ms
5,248 KB |
testcase_60 | AC | 16 ms
5,248 KB |
testcase_61 | AC | 16 ms
5,248 KB |
testcase_62 | AC | 16 ms
5,248 KB |
testcase_63 | AC | 20 ms
5,248 KB |
testcase_64 | AC | 20 ms
5,248 KB |
testcase_65 | AC | 14 ms
5,248 KB |
testcase_66 | AC | 20 ms
5,248 KB |
ソースコード
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> #include<string.h> typedef int32_t i32; typedef int64_t i64; typedef uint64_t u64; static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}} static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;} typedef u64 radix_type; #define RADIX_WIDTH 15 const uint32_t radix_type_max = 60; const uint32_t radix_type_begin = 0; const uint32_t radix_width = RADIX_WIDTH; const uint32_t radix_mask = (1 << RADIX_WIDTH) - 1; #undef RADIX_WIDTH static inline uint32_t radix_get_bit (radix_type v, uint32_t shift) { return v >> shift & radix_mask; } void radix_sort (radix_type *a, uint32_t n) { radix_type * const array = (radix_type *) calloc (4 * n, sizeof (radix_type)); radix_type **bucket = (radix_type **) calloc (1 << radix_width, sizeof (radix_type *)); uint32_t *len = (uint32_t *) calloc (2 << radix_width, sizeof (uint32_t)); uint32_t *max_len = len + (1 << radix_width); for (uint32_t shift = radix_type_begin; shift < radix_type_max; shift += radix_width) { radix_type *p = array; memset (len, 0, sizeof (uint32_t) << (radix_width + 1)); for (uint32_t i = 0; i < n; ++i) { uint32_t bit = radix_get_bit (a[i], shift); if (len[bit] == max_len[bit]) { for (uint32_t j = 0; j < len[bit]; ++j) { p[j] = bucket[bit][j]; } max_len[bit] = 2 * max_len[bit] + 1; bucket[bit] = p; p += max_len[bit]; } bucket[bit][len[bit]++] = a[i]; } for (uint32_t bit = 0, i = 0; bit < (1 << radix_width); ++bit) { for (uint32_t j = 0; j < len[bit]; ++j, ++i) { a[i] = bucket[bit][j]; } } } free (array); free (bucket); free (len); } i32 max (i32 a, i32 b) { return a > b ? a : b; } void update (i32 *bit, i32 x, i32 v) { i32 n = bit[0]; for (i32 i = x; i <= n; i += i & -i) { bit[i] = max (bit[i], v); } } i32 find (i32 *bit, i32 x) { i32 res = 0; for (i32 i = x; i > 0; i -= i & -i) { res = max (res, bit[i]); } return res; } void run (void) { i32 n = read_int(); u64 *p = (u64 *) calloc (n, sizeof (u64)); for (i32 i = 0; i < n; ++i) { u64 a = read_int() + 1; u64 b = read_int() + 1; u64 c = read_int() + 1; p[i] = (a << 45) + (b << 31) + (c << 17) + i; } radix_sort (p, n); uint8_t *ok = (uint8_t *) calloc (n, sizeof (uint8_t)); const i32 m = 10000 + 1; i32 *bit = (i32 *) calloc (m + 1, sizeof (i32)); bit[0] = m; for (i32 i = n - 1; i >= 0; --i) { i32 b = (p[i] >> 31) & ((1 << 14) - 1); i32 c = (p[i] >> 17) & ((1 << 14) - 1); i32 index = p[i] & ((1 << 17) - 1); i32 k = m + 1 - b; if (find (bit, k) >= c) continue; ok[index] = 1; update (bit, k, c); } for (i32 i = 0; i < n; ++i) { if (ok[i]) { print_int (i + 1); puts (""); } } } int main (void) { run(); return 0; }