提出 #41751428
ソースコード 拡げる
#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define ldb long double
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
using namespace std;
const int N = 2e5 + 10, INF = 1e18;
inline int read()
{
int s = 0, w = 1;
char ch = getchar();
while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
int n;
int dir[N];
bool vis[N];
queue<int> lf;
vector<int> ans, G[N];
signed main()
{
n = read();
for(re int i = 1, x, y; i < n; i++)
x = read(), y = read(), G[x].pb(y), G[y].pb(x), dir[x] += 1, dir[y] += 1;
for(re int i = 1; i <= n; i++) if(dir[i] == 1) lf.push(i);
while(!lf.empty()){
int u = lf.front(), rt, k = 0; lf.pop();
if(vis[u] || !dir[u]) continue;
vector<int> del;
for(re int v : G[u]) if(!vis[v]) rt = v;
for(re int v : G[rt])
if(!vis[v]) vis[v] = true, k += 1, del.pb(v);
vis[rt] = true, ans.pb(k);
for(re int it : del)
for(re int v : G[it]) if(--dir[v] == 1) lf.push(v);
}
sort(ans.begin(), ans.end());
for(re int it : ans) printf("%lld ", it);
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:32:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
32 | for(re int i = 1, x, y; i < n; i++)
| ^
./Main.cpp:32:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
32 | for(re int i = 1, x, y; i < n; i++)
| ^
./Main.cpp:32:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
32 | for(re int i = 1, x, y; i < n; i++)
| ^
./Main.cpp:33:38: warning: address requested for ‘y’, which is declared ‘register’ [-Wextra]
33 | x = read(), y = read(), G[x].pb(y), G[y].pb(x), dir[x] += 1, dir[y] += 1;
| ^
./Main.cpp:33:50: warning: address requested for ‘x’, which is declared ‘register’ [-Wextra]
33 | x = read(), y = read(), G[x].pb(y), G[y].pb(x), dir[x] += 1, dir[y] += 1;
| ^
./Main.cpp:34:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
34 | for(re int i = 1; i <= n; i++) if(dir[i] == 1) lf.push(i);
| ^
./Main.cpp:34:59: warning: address requested for ‘i’, which is declared ‘register’ [-Wextra]
34 | for(re int i = 1; i <= n; i++) if(dir[i] == 1) lf.push(i);
| ^
./Main.cpp:39:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
39 | for(re int v : G[u]) if(!vis[v]) rt = v;
| ^
./Main.cpp:40:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
40 | for(re int v : G[rt])
| ^
./Main.cpp:41:50: warning: address requested for ‘v’, which is declared ‘register’ [-Wextra]
41 | if(!vis[v]) vis[v] = true, k += 1, del.pb(v);
| ...
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
475 / 475 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_01.txt |
AC |
8 ms |
8248 KiB |
| 00_sample_02.txt |
AC |
8 ms |
8364 KiB |
| 00_sample_03.txt |
AC |
7 ms |
8196 KiB |
| 01_test_01.txt |
AC |
84 ms |
18612 KiB |
| 01_test_02.txt |
AC |
89 ms |
18664 KiB |
| 01_test_03.txt |
AC |
86 ms |
18636 KiB |
| 01_test_04.txt |
AC |
70 ms |
20044 KiB |
| 01_test_05.txt |
AC |
68 ms |
20052 KiB |
| 01_test_06.txt |
AC |
72 ms |
20084 KiB |
| 01_test_07.txt |
AC |
62 ms |
20024 KiB |
| 01_test_08.txt |
AC |
65 ms |
20188 KiB |
| 01_test_09.txt |
AC |
66 ms |
20124 KiB |
| 01_test_10.txt |
AC |
67 ms |
19476 KiB |
| 01_test_11.txt |
AC |
63 ms |
19376 KiB |
| 01_test_12.txt |
AC |
60 ms |
19568 KiB |
| 01_test_13.txt |
AC |
57 ms |
19900 KiB |
| 01_test_14.txt |
AC |
58 ms |
20844 KiB |
| 01_test_15.txt |
AC |
65 ms |
21972 KiB |
| 01_test_16.txt |
AC |
70 ms |
19672 KiB |
| 01_test_17.txt |
AC |
99 ms |
16668 KiB |
| 01_test_18.txt |
AC |
61 ms |
22040 KiB |