結果
問題 | No.8042 本棚 |
ユーザー |
![]() |
提出日時 | 2019-04-01 22:29:42 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,058 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 31,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 01:52:33 |
合計ジャッジ時間 | 1,024 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> #include<string.h> #include<math.h> typedef int32_t i32; typedef int64_t i64; #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) typedef struct node { char *s; i32 index; } node; int cmp (const void *a, const void *b) { const node *p = a; const node *q = b; int c = strcmp(p->s,q->s); if (c != 0) return c; return p->index - q->index; } void run (void) { i32 n; scanf ("%" SCNi32, &n); char *s = (char *) calloc (26 * n, sizeof (char)); node *p = (node *) calloc (n, sizeof (node)); for (i32 i = 0; i < n; ++i) { scanf ("%s", s + 26 * i); char t[10]; scanf ("%s", t); p[i] = (node) {s + 26 * i, t[0] == 'i' ? 0 : t[0] == 'n' ? 1 : t[0] == 's' ? 2 : 3}; } qsort (p, n, sizeof (node), cmp); char *ans[4] = {"iti","ni","san","yon"}; for (i32 i = 0; i < n; ++i) { printf ("%s %s\n", p[i].s,ans[p[i].index]); } } int main (void) { run (); return 0; }