結果
| 問題 |
No.1254 補強への架け橋
|
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2020-08-28 12:28:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 2,048 bytes |
| コンパイル時間 | 1,777 ms |
| コンパイル使用メモリ | 174,428 KB |
| 実行使用メモリ | 6,848 KB |
| 最終ジャッジ日時 | 2024-11-09 01:09:55 |
| 合計ジャッジ時間 | 12,081 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 123 |
ソースコード
#include <bits/stdc++.h>
struct FastIO {
char inbuf[1500000];
char outbuf[800000];
char *inptr = inbuf;
char *outptr = outbuf;
void read() {
int size = fread(inbuf, 1, sizeof(inbuf) - 1, stdin);
inbuf[size] = '\0';
inptr = inbuf;
}
FastIO () {
read();
}
~FastIO() {
fwrite(outbuf, 1, outptr - outbuf, stdout);
}
template<typename Integer> Integer read() {
bool neg = false;
Integer res = 0;
while ((*inptr < '0' || *inptr > '9') && *inptr != '-') inptr++;
if (*inptr == '-') neg = true, inptr++;
while (*inptr >= '0' && *inptr <= '9') res = res * 10 + *inptr - '0', inptr++;
return neg ? -res : res;
}
void put(char c) { *outptr++ = c; }
void put(unsigned int n) {
if (n >= 100000) *outptr++ = '0' + n / 100000;
if (n >= 10000) *outptr++ = '0' + n / 10000 % 10;
if (n >= 1000) *outptr++ = '0' + n / 1000 % 10;
if (n >= 100) *outptr++ = '0' + n / 100 % 10;
if (n >= 10) *outptr++ = '0' + n / 10 % 10;
*outptr++ = '0' + n % 10;
}
} fastio;
#define ri fastio.read<int>
#define rs64 fastio.read<int64_t>
int main() {
int n = ri();
int degree[n];
uint64_t xored[n];
memset(degree, 0, sizeof(degree));
memset(xored, 0, sizeof(xored));
for (int i = 0; i < n; i++) {
int a = ri() - 1;
int b = ri() - 1;
degree[a]++;
degree[b]++;
xored[a] ^= (uint64_t) i << 32 | b;
xored[b] ^= (uint64_t) i << 32 | a;
}
bool ok[n];
for (auto &i : ok) i = true;
std::queue<int> que;
for (int i = 0; i < n; i++) if (degree[i] == 1) que.push(i);
while (que.size()) {
int i = que.front();
que.pop();
if (degree[i] == 1) {
int j_hen = xored[i] >> 32;
int j = xored[i] & 0xFFFFFFFF;
ok[j_hen] = false;
xored[j] ^= (uint64_t) j_hen << 32 | i;
if (--degree[j] == 1) que.push(j);
}
}
std::vector<int> res;
for (int i = 0; i < n; i++) if (ok[i]) res.push_back(i);
fastio.put((unsigned int) res.size());
fastio.put('\n');
for (int i = 0; i < (int) res.size(); i++) {
if (i) fastio.put(' ');
fastio.put((unsigned int) res[i] + 1);
}
fastio.put('\n');
return 0;
}
QCFium