結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー | chro_96 |
提出日時 | 2023-02-03 21:37:55 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 976 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 30,848 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 19:26:55 |
合計ジャッジ時間 | 1,961 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <stdio.h> typedef struct tree { struct tree *p; } tree; tree *get_root (tree *t) { if (t == NULL || t->p == NULL) { return t; } t->p = get_root(t->p); return t->p; } int main () { int n = 0; int m = 0; int a = 0; int b = 0; int res = 0; tree t[400000] = {}; int is_ok = 1; res = scanf("%d", &n); res = scanf("%d", &m); for (int i = 0; i < m; i++) { tree *rt1 = NULL; tree *rt2 = NULL; res = scanf("%d", &a); res = scanf("%d", &b); a--; b--; rt1 = get_root(t+a); rt2 = get_root(t+(b+n)); if (rt1 != rt2) { rt2->p = rt1; } rt1 = get_root(t+(a+n)); rt2 = get_root(t+b); if (rt1 != rt2) { rt2->p = rt1; } } for (int i = 0; i < n; i++) { tree *rt1 = get_root(t+i); tree *rt2 = get_root(t+(i+n)); if (rt1 != rt2) { is_ok = 0; } } if (is_ok > 0) { printf("Yes\n"); } else { printf("No\n"); } return 0; }