problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02706
C++
Runtime Error
#include <bits/stdc++.h> #include <math.h> #define _GLIBCXX_DEBUG using namespace std; int main() { int N, M; cin >> N >> M; vector<int> vec(M); for (int i = 0; i < M; i++) { cin >> vec[i]; } int sum = 0; for (int i = 0; i < N; i++) { sum += vec[i]; } if (sum <= N) { cout << N - sum << endl; } else { cout << "-1" << endl; } }
#include <bits/stdc++.h> #include <math.h> #define _GLIBCXX_DEBUG using namespace std; int main() { int N, M; cin >> N >> M; vector<int> vec(M); for (int i = 0; i < M; i++) { cin >> vec[i]; } int sum = 0; for (int i = 0; i < M; i++) { sum += vec[i]; } if (sum <= N) { cout << N - sum << endl; } else { cout << "-1" << endl; } }
replace
14
15
14
15
0
p02706
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define endl "\n" int main() { fast; ll n, m, i, a[10000], sum = 0; cin >> n >> m; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) cout << abs(sum - n) << endl; else cout << "-1" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define endl "\n" int main() { fast; ll n, m, i, a[10000], sum = 0; cin >> n >> m; for (i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) cout << abs(sum - n) << endl; else cout << "-1" << endl; return 0; }
replace
15
16
15
16
0
p02706
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a, b) for (int a = 0; a < b; a++) #define Sort(a) sort(a.begin(), a.end()) #define rev(a) reverse(a.begin(), a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(), a.end()), a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int, vector<int>, greater<int>> #define PriP \ priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(), (a).end() #define elif else if int low(V<int> &a, int b) { auto c = lower_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } int upp(V<int> &a, int b) { auto c = upper_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } template <class T> void cou(vector<vector<T>> a) { int b = a.size(); int c = a[0].size(); fo(i, b) { fo(j, c) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } int wari(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int keta(int a) { double b = a; b = log10(b); int c = b; return c + 1; } int souwa(int a) { return a * (a + 1) / 2; } int gcm(int a, int b) { if (a % b == 0) return b; return gcm(b, a % b); } bool prime(int a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; for (int i = 3; i <= sqrt(a) + 1; i += 2) { if (a % i == 0) return false; } return true; } struct Union { vector<int> par; Union(int a) { par = vector<int>(a, -1); } int find(int a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(int a, int b) { return find(a) == find(b); } int Size(int a) { return -par[find(a)]; } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<int>(a, b); par[a] += par[b]; par[b] = a; } }; int ketas(int a) { string b = to_string(a); int c = 0; fo(i, keta(a)) { c += b[i] - '0'; } return c; } bool fe(int a, int b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } int INF = 1000000007; struct edge { int s, t, d; }; V<int> mojisyu(string a) { V<int> b(26, 0); fo(i, a.sz) { b[a[i] - 'a']++; } return b; } int wa2(int a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n, int r) { int a = 1; r = min(r, n - r); for (int i = n; i > n - r; i--) { a *= i; a /= n - i + 1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a) { int b = 1; fo(i, a) b *= i + 1; return b; } int nPr(int a, int b) { if (a < b) return 0; if (b == 0) return 1; int c = 1; for (int i = a; i > a - b; i--) { c *= i; c %= INF; } return c; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } int lcm(int a, int b) { int c = modinv(gcm(a, b), INF); return ((a * c) % INF) * (b % INF) % INF; } int MOD = INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 // 先にCOMinit()で前処理をする // ABC145D void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 1000010; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 int COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool naka(int a, int b, V<V<char>> c) { return (a >= 0 && b >= 0 && a < c.sz && b < c[0].sz); } V<P<int, int>> mawari8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}, {-1, -1}, {1, 1}, {1, -1}, {-1, -1}}; int inf = 1000000000000000007; V<P<int, int>> mawari4 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}; // 最短経路の表 a(全部INFで初期化) // 縦横 x,y // 迷路 f // スタートsx,sy // ゴールgx,gy // 文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a) { V<int> b(a.sz); for (int i = 1, j = 0; i < a.sz; i++) { if (i + b[i - j] < j + b[j]) b[i] = b[i - j]; else { int c = max<int>(0, j + b[j] - i); while (i + c < a.sz && a[c] == a[i + c]) c++; b[i] = c; j = i; } } b[0] = a.sz; return b; } // 各頂点ごとにどこに辺が出てるかの表がc // 各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する // aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ V<int> color(200005); bool nibu_hantei(int a, int b, V<V<int>> c) { color[a] = b; fo(i, c[a].sz) { if (b == color[c[a][i]]) return false; if (color[c[a][i]] == 0 && !nibu_hantei(c[a][i], -b, c)) return false; } return true; } // aは頂点数 // nibu_hanteiの上にcolorを用意する // 各頂点ごとにどこに辺が出てるかの表がc bool renketujanai_nibu_hantei(int a, V<V<int>> c) { fo(i, a) { if (color[i] == 0) { if (!nibu_hantei(i, 1, c)) return false; } } return true; } struct segmin { vector<int> seg; int b; segmin(V<int> a) { b = 1; while (b < a.sz) b *= 2; seg = vector<int>(2 * b - 1, inf); fo(i, a.sz) { seg[i + b - 1] = a[i]; } for (int i = b - 2; i >= 0; i--) { seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]); } } void update(int i, int a) { i += b - 1; seg[i] = a; while (i) { i = (i - 1) / 2; seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]); } } // 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで // l,rは探すところ int getmin(int x, int y, int a, int l, int r) { if (r == INF) r = b; if (r <= x || y <= l) return INF; if (x <= l && r <= y) return seg[a]; int a1 = getmin(x, y, 2 * a + 1, l, (l + r) / 2); int a2 = getmin(x, y, 2 * a + 2, (l + r) / 2, r); return min(a1, a2); } }; struct segadd { vector<int> seg; int b; segadd(V<int> a) { b = 1; while (b < a.sz) b *= 2; seg = vector<int>(2 * b - 1, 0); fo(i, a.sz) { seg[i + b - 1] = a[i]; } for (int i = b - 2; i >= 0; i--) { seg[i] = seg[2 * i + 1] + seg[2 * i + 2]; } } void update(int i, int a) { i += b - 1; seg[i] = a; while (i) { i = (i - 1) / 2; seg[i] = seg[2 * i + 1] + seg[2 * i + 2]; } } // 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで // l,rは探すところ int getadd(int x, int y, int a, int l, int r) { if (r == INF) r = b; if (r <= x || y <= l) return 0; if (x <= l && r <= y) return seg[a]; int a1 = getadd(x, y, 2 * a + 1, l, (l + r) / 2); int a2 = getadd(x, y, 2 * a + 2, (l + r) / 2, r); return a1 + a2; } }; struct sege { vector<P<int, V<int>>> seg; int b; sege(string a) { b = 1; while (b < a.sz) b *= 2; seg = vector<P<int, V<int>>>(2 * b - 1); fo(i, a.sz) { seg[i + b - 1].fi = 1; seg[i + b - 1].se.pb(a[i] - 'a'); } for (int i = b - 2; i >= 0; i--) { V<int> d = seg[2 * i + 1].se; fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); } Sort(d); uni(d); seg[i].se = d; seg[i].fi = d.sz; } } V<int> mu; void update(int i, char a) { i += b - 1; seg[i].se = mu; seg[i].se.pb(a - 'a'); seg[i].fi = 1; while (i) { i = (i - 1) / 2; V<int> d = seg[2 * i + 1].se; fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); } Sort(d); uni(d); seg[i].se = d; seg[i].fi = d.sz; } } void unko() { fo(i, 2 * b - 1) cout << seg[i].fi << ' '; } // 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで // l,rは探すところ P<int, V<int>> gete(int x, int y, int a, int l, int r) { if (r == INF) r = b; if (r <= x || y <= l) return {0, mu}; if (x <= l && r <= y) return seg[a]; P<int, V<int>> a1 = gete(x, y, 2 * a + 1, l, (l + r) / 2); P<int, V<int>> a2 = gete(x, y, 2 * a + 2, (l + r) / 2, r); fo(i, a2.se.sz) a1.se.pb(a2.se[i]); Sort(a1.se); uni(a1.se); return {a1.se.sz, a1.se}; } }; /* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ // aのb乗mod c int kurikaesijijou(int a, int b, int c) { a %= c; b %= c; if (b == 0) return 1; if (b % 2 == 0) { int d = kurikaesijijou(a, b / 2, c); d %= c; return d * d % c; } return a * kurikaesijijou(a, b - 1, c) % c; } signed main() { int a, b; cin >> a >> b; V<int> c(b); fo(i, b) cin >> c[i]; int d = 0; fo(i, a) d += c[i]; cout << max<int>(-1, a - d) << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a, b) for (int a = 0; a < b; a++) #define Sort(a) sort(a.begin(), a.end()) #define rev(a) reverse(a.begin(), a.end()) #define fi first #define se second #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(), a.end()), a.end()) #define Q queue #define pri priority_queue #define Pri priority_queue<int, vector<int>, greater<int>> #define PriP \ priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(), (a).end() #define elif else if int low(V<int> &a, int b) { auto c = lower_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } int upp(V<int> &a, int b) { auto c = upper_bound(a.begin(), a.end(), b); int d = c - a.bgn; return d; } template <class T> void cou(vector<vector<T>> a) { int b = a.size(); int c = a[0].size(); fo(i, b) { fo(j, c) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } int wari(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int keta(int a) { double b = a; b = log10(b); int c = b; return c + 1; } int souwa(int a) { return a * (a + 1) / 2; } int gcm(int a, int b) { if (a % b == 0) return b; return gcm(b, a % b); } bool prime(int a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; for (int i = 3; i <= sqrt(a) + 1; i += 2) { if (a % i == 0) return false; } return true; } struct Union { vector<int> par; Union(int a) { par = vector<int>(a, -1); } int find(int a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(int a, int b) { return find(a) == find(b); } int Size(int a) { return -par[find(a)]; } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<int>(a, b); par[a] += par[b]; par[b] = a; } }; int ketas(int a) { string b = to_string(a); int c = 0; fo(i, keta(a)) { c += b[i] - '0'; } return c; } bool fe(int a, int b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } int INF = 1000000007; struct edge { int s, t, d; }; V<int> mojisyu(string a) { V<int> b(26, 0); fo(i, a.sz) { b[a[i] - 'a']++; } return b; } int wa2(int a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n, int r) { int a = 1; r = min(r, n - r); for (int i = n; i > n - r; i--) { a *= i; a /= n - i + 1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a) { int b = 1; fo(i, a) b *= i + 1; return b; } int nPr(int a, int b) { if (a < b) return 0; if (b == 0) return 1; int c = 1; for (int i = a; i > a - b; i--) { c *= i; c %= INF; } return c; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } int lcm(int a, int b) { int c = modinv(gcm(a, b), INF); return ((a * c) % INF) * (b % INF) % INF; } int MOD = INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 // 先にCOMinit()で前処理をする // ABC145D void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 1000010; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 int COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool naka(int a, int b, V<V<char>> c) { return (a >= 0 && b >= 0 && a < c.sz && b < c[0].sz); } V<P<int, int>> mawari8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}, {-1, -1}, {1, 1}, {1, -1}, {-1, -1}}; int inf = 1000000000000000007; V<P<int, int>> mawari4 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}; // 最短経路の表 a(全部INFで初期化) // 縦横 x,y // 迷路 f // スタートsx,sy // ゴールgx,gy // 文字はgから使おうね /*int bfs_haba(){ Q<P<int,int>> b; a[sx][sy]=0; b.push({sx,sy}); while(!b.empty()){ P<int,int> c=b.front(); b.pop(); if(c.fi==gx&&c.se==gy){ break; } fo(i,4){ int d=c.fi+mawari4[i].fi; int e=c.se+mawari4[i].se; if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){ b.push({d,e}); a[d][e]=1+a[c.fi][c.se]; } } } return a[gx][gy]; }*/ V<int> onajibubun(string a) { V<int> b(a.sz); for (int i = 1, j = 0; i < a.sz; i++) { if (i + b[i - j] < j + b[j]) b[i] = b[i - j]; else { int c = max<int>(0, j + b[j] - i); while (i + c < a.sz && a[c] == a[i + c]) c++; b[i] = c; j = i; } } b[0] = a.sz; return b; } // 各頂点ごとにどこに辺が出てるかの表がc // 各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する // aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ V<int> color(200005); bool nibu_hantei(int a, int b, V<V<int>> c) { color[a] = b; fo(i, c[a].sz) { if (b == color[c[a][i]]) return false; if (color[c[a][i]] == 0 && !nibu_hantei(c[a][i], -b, c)) return false; } return true; } // aは頂点数 // nibu_hanteiの上にcolorを用意する // 各頂点ごとにどこに辺が出てるかの表がc bool renketujanai_nibu_hantei(int a, V<V<int>> c) { fo(i, a) { if (color[i] == 0) { if (!nibu_hantei(i, 1, c)) return false; } } return true; } struct segmin { vector<int> seg; int b; segmin(V<int> a) { b = 1; while (b < a.sz) b *= 2; seg = vector<int>(2 * b - 1, inf); fo(i, a.sz) { seg[i + b - 1] = a[i]; } for (int i = b - 2; i >= 0; i--) { seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]); } } void update(int i, int a) { i += b - 1; seg[i] = a; while (i) { i = (i - 1) / 2; seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]); } } // 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで // l,rは探すところ int getmin(int x, int y, int a, int l, int r) { if (r == INF) r = b; if (r <= x || y <= l) return INF; if (x <= l && r <= y) return seg[a]; int a1 = getmin(x, y, 2 * a + 1, l, (l + r) / 2); int a2 = getmin(x, y, 2 * a + 2, (l + r) / 2, r); return min(a1, a2); } }; struct segadd { vector<int> seg; int b; segadd(V<int> a) { b = 1; while (b < a.sz) b *= 2; seg = vector<int>(2 * b - 1, 0); fo(i, a.sz) { seg[i + b - 1] = a[i]; } for (int i = b - 2; i >= 0; i--) { seg[i] = seg[2 * i + 1] + seg[2 * i + 2]; } } void update(int i, int a) { i += b - 1; seg[i] = a; while (i) { i = (i - 1) / 2; seg[i] = seg[2 * i + 1] + seg[2 * i + 2]; } } // 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで // l,rは探すところ int getadd(int x, int y, int a, int l, int r) { if (r == INF) r = b; if (r <= x || y <= l) return 0; if (x <= l && r <= y) return seg[a]; int a1 = getadd(x, y, 2 * a + 1, l, (l + r) / 2); int a2 = getadd(x, y, 2 * a + 2, (l + r) / 2, r); return a1 + a2; } }; struct sege { vector<P<int, V<int>>> seg; int b; sege(string a) { b = 1; while (b < a.sz) b *= 2; seg = vector<P<int, V<int>>>(2 * b - 1); fo(i, a.sz) { seg[i + b - 1].fi = 1; seg[i + b - 1].se.pb(a[i] - 'a'); } for (int i = b - 2; i >= 0; i--) { V<int> d = seg[2 * i + 1].se; fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); } Sort(d); uni(d); seg[i].se = d; seg[i].fi = d.sz; } } V<int> mu; void update(int i, char a) { i += b - 1; seg[i].se = mu; seg[i].se.pb(a - 'a'); seg[i].fi = 1; while (i) { i = (i - 1) / 2; V<int> d = seg[2 * i + 1].se; fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); } Sort(d); uni(d); seg[i].se = d; seg[i].fi = d.sz; } } void unko() { fo(i, 2 * b - 1) cout << seg[i].fi << ' '; } // 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで // l,rは探すところ P<int, V<int>> gete(int x, int y, int a, int l, int r) { if (r == INF) r = b; if (r <= x || y <= l) return {0, mu}; if (x <= l && r <= y) return seg[a]; P<int, V<int>> a1 = gete(x, y, 2 * a + 1, l, (l + r) / 2); P<int, V<int>> a2 = gete(x, y, 2 * a + 2, (l + r) / 2, r); fo(i, a2.se.sz) a1.se.pb(a2.se[i]); Sort(a1.se); uni(a1.se); return {a1.se.sz, a1.se}; } }; /* signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } }*/ // aのb乗mod c int kurikaesijijou(int a, int b, int c) { a %= c; b %= c; if (b == 0) return 1; if (b % 2 == 0) { int d = kurikaesijijou(a, b / 2, c); d %= c; return d * d % c; } return a * kurikaesijijou(a, b - 1, c) % c; } signed main() { int a, b; cin >> a >> b; V<int> c(b); fo(i, b) cin >> c[i]; int d = 0; fo(i, b) d += c[i]; cout << max<int>(-1, a - d) << endl; }
replace
504
505
504
505
0
p02706
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> V; for (int i = 0; i < M; i++) { cin >> V.at(i); } int P = 0; for (int i = 0; i < M; i++) { P += V.at(i); } if (N - P >= 0) cout << N - P; else cout << "-1"; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> V(M); for (int i = 0; i < M; i++) { cin >> V.at(i); } int P = 0; for (int i = 0; i < M; i++) { P += V.at(i); } if (N - P >= 0) cout << N - P; else cout << "-1"; }
replace
6
7
6
7
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
p02706
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <numeric> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() int main() { int n, m; cin >> n >> m; vector<int> A(m); rep(i, n) cin >> A.at(i); int sum = accumulate(A.begin(), A.end(), 0); if (sum > n) { cout << -1 << endl; } else { cout << n - sum << endl; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <numeric> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() int main() { int n, m; cin >> n >> m; vector<int> A(m); rep(i, m) cin >> A.at(i); int sum = accumulate(A.begin(), A.end(), 0); if (sum > n) { cout << -1 << endl; } else { cout << n - sum << endl; } }
replace
15
16
15
16
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 2) >= this->size() (which is 2)
p02706
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, m; int a[100]; int s = 0; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; s += a[i]; } if (s > n) { cout << -1 << endl; } else { cout << n - s << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; int a[100100]; int s = 0; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; s += a[i]; } if (s > n) { cout << -1 << endl; } else { cout << n - s << endl; } }
replace
5
6
5
6
0
p02706
C++
Runtime Error
#include <iostream> using namespace std; int main() { int n; int m; int a[1000]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; } int sum = 0; for (int i = 0; i < m; i++) { sum = sum + a[i]; } if (n - sum < 0) { cout << -1 << endl; } else { cout << n - sum << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n; int m; int a[10000]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; } int sum = 0; for (int i = 0; i < m; i++) { sum = sum + a[i]; } if (n - sum < 0) { cout << -1 << endl; } else { cout << n - sum << endl; } return 0; }
replace
7
8
7
8
0
p02706
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int main() { int n, m, a[1000]; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) { cout << n - sum; } else { cout << -1; } }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int main() { int n, m, a[10000]; cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum <= n) { cout << n - sum; } else { cout << -1; } }
replace
7
8
7
8
0
p02706
C++
Time Limit Exceeded
// #pragma GCC optimize("O3") // #pragma GCC target("avx2") // 293206GT #include <algorithm> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> typedef long long ll; #define int ll using namespace std; #define put(a) cout << (a) << '\n' #define sqr(x) (x) * (x) typedef pair<ll, ll> pii; typedef long double ld; typedef pair<ld, ld> pld; #define rep(x, y, a) for (int x = (y); x < (int)(a); ++x) #define all(a) a.begin(), a.end() #define chkmax(a, b) a = max(a, (b)) #define chkmin(a, b) a = min(a, (b)) #define prev asasdasd #define next aasdasda #define left asdasdasdasd #define right asnabsdkasdl #define rank asdasdknlasd #define move asdasdas typedef vector<int> vi; typedef vector<pii> vpii; namespace IO { template <class A, class B> ostream &operator<<(ostream &out, pair<A, B> &a) { out << a.first << " " << a.second; return out; } template <class A, class B> ostream &operator<<(ostream &out, vector<pair<A, B>> &a) { for (pair<A, B> x : a) out << x.first << " " << x.second << '\n'; } template <class A> ostream &operator<<(ostream &out, vector<A> &a) { for (A x : a) out << x << ' '; return out; } template <class A, class B> istream &operator>>(istream &in, pair<A, B> &a) { in >> a.first >> a.second; return in; } template <class A> istream &operator>>(istream &in, vector<A> &a) { for (A &x : a) in >> x; return in; } } // namespace IO using namespace IO; int solve() { int n, m; cin >> n >> m; rep(i, 0, m) { int a; cin >> a; n -= a; } if (n < 0) put(-1); else put(n); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); int t = 1; // cin >> t; while (t--) solve(); }
// #pragma GCC optimize("O3") // #pragma GCC target("avx2") // 293206GT #include <algorithm> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> typedef long long ll; #define int ll using namespace std; #define put(a) cout << (a) << '\n' #define sqr(x) (x) * (x) typedef pair<ll, ll> pii; typedef long double ld; typedef pair<ld, ld> pld; #define rep(x, y, a) for (int x = (y); x < (int)(a); ++x) #define all(a) a.begin(), a.end() #define chkmax(a, b) a = max(a, (b)) #define chkmin(a, b) a = min(a, (b)) #define prev asasdasd #define next aasdasda #define left asdasdasdasd #define right asnabsdkasdl #define rank asdasdknlasd #define move asdasdas typedef vector<int> vi; typedef vector<pii> vpii; namespace IO { template <class A, class B> ostream &operator<<(ostream &out, pair<A, B> &a) { out << a.first << " " << a.second; return out; } template <class A, class B> ostream &operator<<(ostream &out, vector<pair<A, B>> &a) { for (pair<A, B> x : a) out << x.first << " " << x.second << '\n'; } template <class A> ostream &operator<<(ostream &out, vector<A> &a) { for (A x : a) out << x << ' '; return out; } template <class A, class B> istream &operator>>(istream &in, pair<A, B> &a) { in >> a.first >> a.second; return in; } template <class A> istream &operator>>(istream &in, vector<A> &a) { for (A &x : a) in >> x; return in; } } // namespace IO using namespace IO; void solve() { int n, m; cin >> n >> m; rep(i, 0, m) { int a; cin >> a; n -= a; } if (n < 0) put(-1); else put(n); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); int t = 1; // cin >> t; while (t--) solve(); }
replace
72
73
72
73
TLE
p02707
C++
Runtime Error
#include <algorithm> #include <cmath> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; #define ll long long #define sc(n) static_cast<ll>(n) #define IO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); int main() { IO; #ifdef _DEBUG ifstream cin("In.txt"); #endif ll n, a; cin >> n >> a; vector<ll> vc(n); for (int i = 0; i < n - 1; i++) { cin >> a; vc[--a]++; } for (int i = 0; i < n; i++) cout << vc[i] << '\n'; return 0; }
#include <algorithm> #include <cmath> #include <ctime> #include <fstream> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; #define ll long long #define sc(n) static_cast<ll>(n) #define IO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); int main() { IO; #ifdef _DEBUG ifstream cin("In.txt"); #endif ll n, a; cin >> n; vector<ll> vc(n); for (int i = 0; i < n - 1; i++) { cin >> a; vc[--a]++; } for (int i = 0; i < n; i++) cout << vc[i] << '\n'; return 0; }
replace
33
34
33
34
0
p02707
C++
Runtime Error
#include <iostream> using namespace std; int main(void) { // Your code here! int human_number; int __report[160000], __sums[160000] = {0}; cin >> human_number; for (int index = 1; index < human_number; index++) { cin >> __report[index]; __sums[__report[index]]++; } for (int index = 1; index <= human_number; index++) { cout << __sums[index] << endl; } }
#include <iostream> using namespace std; int main(void) { // Your code here! int human_number; int __report[2560000], __sums[2560000] = {0}; cin >> human_number; for (int index = 1; index < human_number; index++) { cin >> __report[index]; __sums[__report[index]]++; } for (int index = 1; index <= human_number; index++) { cout << __sums[index] << endl; } }
replace
6
7
6
7
0
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long using namespace std; int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; } const double PI = 3.14159265358979323846; int main() { int n; cin >> n; int a[n]; for (int i = 1; i <= n; i++) { int b = 0; for (int j = 0; j < n; j++) { cin >> a[j]; if (a[j] == i) { b++; } } cout << b << endl; } return 0; } // g++ lo.cpp // ./a.exe // g++ -o つくりたいふぁいるめい もとのふぁいる.cpp /* for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { int k = 2 * j - i;*/
#include <bits/stdc++.h> #define ll long long using namespace std; int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; } const double PI = 3.14159265358979323846; int main() { int N; cin >> N; vector<int> a(N - 1); for (int i = 0; i < N - 1; i++) { cin >> a.at(i); } vector<int> b(N); for (int i = 0; i < N - 1; i++) { b.at(a.at(i) - 1)++; } for (int i = 0; i < N; i++) { cout << b.at(i) << endl; } return 0; } // g++ lo.cpp // ./a.exe // g++ -o つくりたいふぁいるめい もとのふぁいる.cpp /* for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { int k = 2 * j - i;*/
replace
6
18
6
18
TLE
p02707
C++
Runtime Error
#include <iostream> #include <string> using namespace std; int main() { int N; int A[21000]; cin >> N; A[1] = 1; for (int i = 2; i <= N; ++i) cin >> A[i]; int B[N]; for (int i = 1; i <= N; ++i) { B[i] = 0; } for (int i = 1; i <= N; ++i) { if (i != A[i]) B[A[i]] += 1; } for (int i = 1; i <= N; ++i) { cout << B[i] << endl; } }
#include <iostream> #include <string> using namespace std; int main() { int N; int A[220000]; cin >> N; A[1] = 1; for (int i = 2; i <= N; ++i) cin >> A[i]; int B[N]; for (int i = 1; i <= N; ++i) { B[i] = 0; } for (int i = 1; i <= N; ++i) { if (i != A[i]) B[A[i]] += 1; } for (int i = 1; i <= N; ++i) { cout << B[i] << endl; } }
replace
6
7
6
7
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, arr[10000], p = 0; memset(arr, 0, sizeof(arr)); cin >> n; for (int i = 2; i <= n; i++) { int x; cin >> x; arr[x]++; } for (int i = 1; i <= n; i++) { cout << arr[i] << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, arr[1000000], p = 0; memset(arr, 0, sizeof(arr)); cin >> n; for (int i = 2; i <= n; i++) { int x; cin >> x; arr[x]++; } for (int i = 1; i <= n; i++) { cout << arr[i] << "\n"; } return 0; }
replace
4
5
4
5
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> #ifdef __LOCAL #define DBG(X) cout << #X << " = " << (X) << endl; #define SAY(X) cout << (X) << endl; #include <filesystem> namespace fs = std::filesystem; #else #define DBG(X) #define SAY(X) #endif using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int INT_INF = (int)(2e9); const ll LL_INF = (ll)(2e18); static mt19937 _g(time(nullptr)); inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); } inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }; template <typename T, typename S> inline ostream &operator<<(ostream &os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; } template <typename T, typename S> inline ostream &operator<<(ostream &os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto &elem : ret) cin >> elem; return ret; } int N; vector<int> Cnt; void input() { fast_io(); #ifdef __LOCAL fs::path __p = __FILE__; fs::path __input, __output; __input = __output = __p.parent_path(); __input += string("/input/") + string(__p.stem()) + string(".txt"); __output += string("/output/") + string(__p.stem()) + string(".txt"); freopen(__input.c_str(), "r", stdin); freopen(__output.c_str(), "w", stdout); #endif cin >> N; Cnt.assign(N, 0); for (int i = 0; i < N; i++) { int a; cin >> a; Cnt[--a]++; } } int solve() { for (int i = 0; i < N; i++) { cout << Cnt[i] << endl; } return 0; } int main() { input(); solve(); return 0; }
#include <bits/stdc++.h> #ifdef __LOCAL #define DBG(X) cout << #X << " = " << (X) << endl; #define SAY(X) cout << (X) << endl; #include <filesystem> namespace fs = std::filesystem; #else #define DBG(X) #define SAY(X) #endif using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int INT_INF = (int)(2e9); const ll LL_INF = (ll)(2e18); static mt19937 _g(time(nullptr)); inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); } inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }; template <typename T, typename S> inline ostream &operator<<(ostream &os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; } template <typename T, typename S> inline ostream &operator<<(ostream &os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto &elem : ret) cin >> elem; return ret; } int N; vector<int> Cnt; void input() { fast_io(); #ifdef __LOCAL fs::path __p = __FILE__; fs::path __input, __output; __input = __output = __p.parent_path(); __input += string("/input/") + string(__p.stem()) + string(".txt"); __output += string("/output/") + string(__p.stem()) + string(".txt"); freopen(__input.c_str(), "r", stdin); freopen(__output.c_str(), "w", stdout); #endif cin >> N; Cnt.assign(N, 0); for (int i = 0; i < N - 1; i++) { int a; cin >> a; Cnt[--a]++; } } int solve() { for (int i = 0; i < N; i++) { cout << Cnt[i] << endl; } return 0; } int main() { input(); solve(); return 0; }
replace
73
74
73
74
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N - 1; i++) { cin >> A[i]; } vector<int> C(N); for (int i = 0; i < N; i++) { C[A[i] - 1]++; } for (int i = 0; i < N; i++) { cout << C[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N - 1; i++) { cin >> A[i]; } vector<int> C(N); for (int i = 0; i < N - 1; i++) { C[A[i] - 1]++; } for (int i = 0; i < N; i++) { cout << C[i] << endl; } return 0; }
replace
12
13
12
13
-6
double free or corruption (out)
p02707
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; ///////////////////////////////////////////////////////////////////////////////////////////// using namespace std; typedef long long ll; #define rep(i, s, n) for (ll i = s; i < n; i++) #define repe(i, s, n) for (ll i = s; i <= n; i++) int a[100001] = {}; int main() { int n; cin >> n; repe(i, 2, n) { int x; cin >> x; a[x]++; } repe(i, 1, n) { cout << a[i] << endl; } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; ///////////////////////////////////////////////////////////////////////////////////////////// using namespace std; typedef long long ll; #define rep(i, s, n) for (ll i = s; i < n; i++) #define repe(i, s, n) for (ll i = s; i <= n; i++) int a[200001] = {}; int main() { int n; cin >> n; repe(i, 2, n) { int x; cin >> x; a[x]++; } repe(i, 1, n) { cout << a[i] << endl; } return 0; }
replace
20
21
20
21
0
p02707
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <stack> using namespace std; #define read(x) scanf("%d", &x) #define readl(x) scanf("%lld", &x) #define ll long long #define ull unsigned long long int n, l; int b[100005] = {0}; int main() { read(n); for (int i = 2; i <= n; i++) read(l), b[l]++; for (int i = 1; i <= n; i++) printf("%d\n", b[i]); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <stack> using namespace std; #define read(x) scanf("%d", &x) #define readl(x) scanf("%lld", &x) #define ll long long #define ull unsigned long long int n, l; int b[200005] = {0}; int main() { read(n); for (int i = 2; i <= n; i++) read(l), b[l]++; for (int i = 1; i <= n; i++) printf("%d\n", b[i]); return 0; }
replace
14
15
14
15
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 1e5 + 11; const int M = 1e6 + 11; const int MOD = 1e9 + 7; const double PI = acos(-1.0); int son[N]; int main(int argc, char **args) { // freopen("in.txt", "r", stdin); int n; cin >> n; for (int i = 1; i < n; i++) { int fa; scanf("%d", &fa); son[fa]++; } for (int i = 1; i <= n; i++) { printf("%d\n", son[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 2e5 + 11; const int M = 1e6 + 11; const int MOD = 1e9 + 7; const double PI = acos(-1.0); int son[N]; int main(int argc, char **args) { // freopen("in.txt", "r", stdin); int n; cin >> n; for (int i = 1; i < n; i++) { int fa; scanf("%d", &fa); son[fa]++; } for (int i = 1; i <= n; i++) { printf("%d\n", son[i]); } return 0; }
replace
6
7
6
7
0
p02707
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <string> #define ll long long #define YES cout << "YES" << endl #define NO cout << "NO" << endl #define yes cout << "Yes" << endl #define no cout << "No" << endl #define loop(i, start, stop) for (int i = start; i < (stop); i++) using namespace std; int main() { ll N; cin >> N; ll A[100001] = {0}; ll ans[100001] = {0}; loop(i, 0, N) { cin >> A[i]; ans[A[i]]++; } loop(i, 1, N + 1) cout << ans[i] << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #define ll long long #define YES cout << "YES" << endl #define NO cout << "NO" << endl #define yes cout << "Yes" << endl #define no cout << "No" << endl #define loop(i, start, stop) for (int i = start; i < (stop); i++) using namespace std; int main() { ll N; cin >> N; ll A[200001] = {0}; ll ans[200001] = {0}; loop(i, 0, N) { cin >> A[i]; ans[A[i]]++; } loop(i, 1, N + 1) cout << ans[i] << endl; return 0; }
replace
16
18
16
18
0
p02707
C++
Runtime Error
#include <algorithm> #include <array> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { int num; int tmp; cin >> num; vector<pair<int, int>> v; array<int, 20010> ans; for (int i = 2; i <= num; i++) { cin >> tmp; ans[tmp]++; } for (int i = 1; i <= num; i++) { cout << ans[i] << endl; } return 0; }
#include <algorithm> #include <array> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { int num; int tmp; cin >> num; array<long long, 200010> ans = {}; for (int i = 1; i < num; i++) { cin >> tmp; ans[tmp]++; } for (int i = 1; i <= num; i++) { cout << ans[i] << endl; } return 0; }
replace
18
21
18
20
0
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans[n]; for (int i = 0; i < n; i++) { ans[i] = 0; } int a; for (int i = 1; i < n; i++) { cin >> a; for (int j = 1; j <= n; j++) { if (j == a) { ans[j - 1] = ans[j - 1] + 1; break; } } } for (int i = 0; i < n; i++) { cout << ans[i] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans[n]; for (int i = 0; i < n; i++) { ans[i] = 0; } int a; for (int i = 1; i < n; i++) { cin >> a; ans[a - 1] = ans[a - 1] + 1; } for (int i = 0; i < n; i++) { cout << ans[i] << endl; } }
replace
13
19
13
14
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, sum = 0; int a[10000], b[10000] = {}; int i = 0; cin >> N; for (int i = 0; i < N - 1; i++) { cin >> a[i]; b[a[i] - 1]++; } for (int i = 0; i < N; i++) { cout << b[i] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, sum = 0; int a[1000000], b[1000000] = {}; int i = 0; cin >> N; for (int i = 0; i < N - 1; i++) { cin >> a[i]; b[a[i] - 1]++; } for (int i = 0; i < N; i++) { cout << b[i] << endl; } }
replace
5
6
5
6
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define setbits(x) __builtin_popcount(x) #define setbitsll(x) __builtin_popcountll(x) // #define endl '\n' #define all(x) (x).begin(), (x).end() #define pb push_back #define se second #define fi first #define pai acos(-1) #define maxe max_element #define mine min_element #define fn(i, x) for (i = 0; i < x; i++) #define fs(i, s, x) for (i = s; i < x; i++) #define fr(i, x) for (i = x; i >= 0; i--) #define fit(itr, s) for (itr = s.begin(); itr != s.end(); itr++) #define W while #define pp pair<ll, ll> #define ppi pair<ll, ll> #define vl vector<ll> #define vll vector<pp> #define vi vector<int> #define vii vector<ppi> #define debug(x) cerr << #x << " :: " << x << endl; #define debug2(x, y) \ cerr << #x << " :: " << x << "\t" << #y << " :: " << y << endl; #define debug3(x, y, z) \ cerr << #x << " :: " << x << "\t" << #y << " :: " << y << "\t" << #z \ << " :: " << z << endl; #define debug4(x, y, z, w) \ cerr << #x << " :: " << x << "\t" << #y << " :: " << y << "\t" << #z \ << " :: " << z << "\t" << #w << " :: " << w << endl; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define SIZE 5000 + 1 const ll MAX = 1e9; const ll mod = 1e9; ll expo(ll x, ll n) { ll ans = 1; while (n > 0) { if (n & 1) { ans = (ans * x) % mod; } x = (x * x) % mod; n >>= 1; } return ans; } vl adj[200001]; void solve() { ll n, i; cin >> n; vl a(n); ll sum = 0; fs(i, 2, n + 1) { cin >> a[i]; adj[a[i]].pb(i); } fs(i, 1, n + 1) { cout << adj[i].size() << endl; } } int main() { boost; ll t = 1; // cin>>t; while (t--) { solve(); } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define setbits(x) __builtin_popcount(x) #define setbitsll(x) __builtin_popcountll(x) // #define endl '\n' #define all(x) (x).begin(), (x).end() #define pb push_back #define se second #define fi first #define pai acos(-1) #define maxe max_element #define mine min_element #define fn(i, x) for (i = 0; i < x; i++) #define fs(i, s, x) for (i = s; i < x; i++) #define fr(i, x) for (i = x; i >= 0; i--) #define fit(itr, s) for (itr = s.begin(); itr != s.end(); itr++) #define W while #define pp pair<ll, ll> #define ppi pair<ll, ll> #define vl vector<ll> #define vll vector<pp> #define vi vector<int> #define vii vector<ppi> #define debug(x) cerr << #x << " :: " << x << endl; #define debug2(x, y) \ cerr << #x << " :: " << x << "\t" << #y << " :: " << y << endl; #define debug3(x, y, z) \ cerr << #x << " :: " << x << "\t" << #y << " :: " << y << "\t" << #z \ << " :: " << z << endl; #define debug4(x, y, z, w) \ cerr << #x << " :: " << x << "\t" << #y << " :: " << y << "\t" << #z \ << " :: " << z << "\t" << #w << " :: " << w << endl; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define boost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define SIZE 5000 + 1 const ll MAX = 1e9; const ll mod = 1e9; ll expo(ll x, ll n) { ll ans = 1; while (n > 0) { if (n & 1) { ans = (ans * x) % mod; } x = (x * x) % mod; n >>= 1; } return ans; } vl adj[200001]; void solve() { ll n, i; cin >> n; vl a(n); ll sum = 0; fs(i, 1, n) { cin >> a[i]; adj[a[i]].pb(i); } fs(i, 1, n + 1) { cout << adj[i].size() << endl; } } int main() { boost; ll t = 1; // cin>>t; while (t--) { solve(); } }
replace
62
63
62
63
-6
munmap_chunk(): invalid pointer
p02707
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define ll long long typedef long double ld; #define all(v) ((v).begin()), ((v).end()) #define vec2(n, m) vector<vector<ll>> vv(n + 10, vector<ll>(m + 10, 0)); #define p_q1 priority_queue<int, vector<int>, greater<int>> pq1; #define format(n) fixed << setprecision(n) #define ll_min LLONG_MIN; #define ll_max LLONG_MIN; #define endl "\n" #define F first #define S second #define mkpr(x, y) make_pair(x, y) using namespace std; void weza() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int main() { weza(); int n, m, a, mx = 0; cin >> n; vector<int> fre(100100); for (int i = 1; i < n; i++) { cin >> a; fre[a]++; } for (int i = 1; i <= n; i++) { cout << fre[i] << endl; } }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define ll long long typedef long double ld; #define all(v) ((v).begin()), ((v).end()) #define vec2(n, m) vector<vector<ll>> vv(n + 10, vector<ll>(m + 10, 0)); #define p_q1 priority_queue<int, vector<int>, greater<int>> pq1; #define format(n) fixed << setprecision(n) #define ll_min LLONG_MIN; #define ll_max LLONG_MIN; #define endl "\n" #define F first #define S second #define mkpr(x, y) make_pair(x, y) using namespace std; void weza() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int main() { weza(); int n, m, a, mx = 0; cin >> n; vector<int> fre(200100); for (int i = 1; i < n; i++) { cin >> a; fre[a]++; } for (int i = 1; i <= n; i++) { cout << fre[i] << endl; } }
replace
38
39
38
39
0
p02707
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> vec(n - 1); for (int i = 0; i < n - 1; i++) { cin >> vec.at(i); } vector<int> ans(n, 0); for (int i = 0; i < n - 1; i++) { ans.at(vec.at(i) - 1)++; } // cout << ans.at(0); for (int i = 0; i <= n; i++) { cout << ans.at(i) << endl; } }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> vec(n - 1); for (int i = 0; i < n - 1; i++) { cin >> vec.at(i); } vector<int> ans(n, 0); for (int i = 0; i < n - 1; i++) { ans.at(vec.at(i) - 1)++; } cout << ans.at(0); for (int i = 1; i < n; i++) { cout << endl << ans.at(i); } }
replace
14
17
14
17
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)
p02707
C++
Runtime Error
#include <bits/stdc++.h> #include <string> using namespace std; int main() { int S[100000] = {0}; int M; int W; cin >> M; for (int i = 0; i < M - 1; i++) { cin >> W; S[W - 1]++; } cout << ""; for (int i = 0; i < M; i++) { cout << S[i] << "\n"; } return 0; }
#include <bits/stdc++.h> #include <string> using namespace std; int main() { int S[200000] = {0}; int M; int W; cin >> M; for (int i = 0; i < M - 1; i++) { cin >> W; S[W - 1]++; } cout << ""; for (int i = 0; i < M; i++) { cout << S[i] << "\n"; } return 0; }
replace
6
7
6
7
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define RREP0(i, n) for (int i = (n)-1; i >= 0; --i) #define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define RREP1(i, n) for (int i = (n); i >= 1; --i) #define pow10(n) int(1e##n + n) typedef long long LL; typedef pair<int, int> P; const int INTINF = int(1e9) + 1; const LL LLINF = LL(1e18) + 1; long double eps = 1.0E-14; int buka[pow10(5)]; void solve() { int N; cin >> N; FOR(i, 2, N + 1) { int a; cin >> a; buka[a]++; } REP1(i, N) { std::cout << buka[i] << endl; } } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define RREP0(i, n) for (int i = (n)-1; i >= 0; --i) #define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define RREP1(i, n) for (int i = (n); i >= 1; --i) #define pow10(n) int(1e##n + n) typedef long long LL; typedef pair<int, int> P; const int INTINF = int(1e9) + 1; const LL LLINF = LL(1e18) + 1; long double eps = 1.0E-14; int buka[2 * pow10(5)]; void solve() { int N; cin >> N; FOR(i, 2, N + 1) { int a; cin >> a; buka[a]++; } REP1(i, N) { std::cout << buka[i] << endl; } } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); solve(); return 0; }
replace
17
18
17
18
0
p02707
C++
Runtime Error
// naveen mall #include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define pb push_back #define sz(c) (int)c.size() #define len(c) (int)c.length() #define vec vector #define int long long int #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define trav(a, i) for (auto i : a) #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define invect(v, n) \ for (int i = 0; i < n; i++) { \ int arb; \ cin >> arb; \ v.pb(arb); \ } #define inset(s, n) \ fl(i, 0, n) { \ int aset; \ cin >> aset; \ s.insert(aset); \ } #define display(c) \ trav(c, i) cout << i << " "; \ cout << "\n"; #define F first #define S second #define pii pair<int, int> #define PB pop_back #define endl "\n" #define what(x) cerr << #x << " is " << x << endl; int sum() { return 0; } template <typename T, typename... Args> T sum(T a, Args... args) { return a + sum(args...); } vec<int> v[20000 + 5]; void solve() { int n; cin >> n; rep(i, 2, n + 1) { int a; cin >> a; v[a].pb(i); } rep(i, 1, n + 1) cout << sz(v[i]) << endl; } signed main() { fast int t; t = 1; // cin>>t; while (t--) { solve(); } }
// naveen mall #include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define pb push_back #define sz(c) (int)c.size() #define len(c) (int)c.length() #define vec vector #define int long long int #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define trav(a, i) for (auto i : a) #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define invect(v, n) \ for (int i = 0; i < n; i++) { \ int arb; \ cin >> arb; \ v.pb(arb); \ } #define inset(s, n) \ fl(i, 0, n) { \ int aset; \ cin >> aset; \ s.insert(aset); \ } #define display(c) \ trav(c, i) cout << i << " "; \ cout << "\n"; #define F first #define S second #define pii pair<int, int> #define PB pop_back #define endl "\n" #define what(x) cerr << #x << " is " << x << endl; int sum() { return 0; } template <typename T, typename... Args> T sum(T a, Args... args) { return a + sum(args...); } vec<int> v[200000 + 5]; void solve() { int n; cin >> n; rep(i, 2, n + 1) { int a; cin >> a; v[a].pb(i); } rep(i, 1, n + 1) cout << sz(v[i]) << endl; } signed main() { fast int t; t = 1; // cin>>t; while (t--) { solve(); } }
replace
44
45
44
45
0
p02707
C++
Time Limit Exceeded
#include <iostream> #include <string> using namespace std; int main(void) { int n, m; cin >> n; // cin>>m; int a[n]; int sum = 0; for (int i = 0; i < n; i++) { a[i] = 0; } for (int i = 1; i < n; i++) { int b; cin >> b; for (int j = 0; j < n; j++) { if (j + 1 == b) a[j]++; } } for (int i = 0; i < n; i++) { cout << a[i] << endl; } }
#include <iostream> #include <string> using namespace std; int main(void) { int n, m; cin >> n; // cin>>m; int a[n]; int sum = 0; for (int i = 0; i < n; i++) { a[i] = 0; } for (int i = 1; i < n; i++) { int b; cin >> b; a[b - 1]++; } for (int i = 0; i < n; i++) { cout << a[i] << endl; } }
replace
17
21
17
18
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long; #define dbg(x) cout << #x << "--------------" << x << endl; #define dl cout << "LINE" << __LINE__ << endl; using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n; int a[9999]; cin >> n; for (int i = 2; i <= n; i++) { int x; cin >> x; a[x]++; } for (int i = 1; i <= n; i++) { cout << a[i] << endl; } return 0; }
#include <bits/stdc++.h> #define ll long long; #define dbg(x) cout << #x << "--------------" << x << endl; #define dl cout << "LINE" << __LINE__ << endl; using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n; int a[999999]; cin >> n; for (int i = 2; i <= n; i++) { int x; cin >> x; a[x]++; } for (int i = 1; i <= n; i++) { cout << a[i] << endl; } return 0; }
replace
9
10
9
10
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, x; int cnt[100010] = {0}; cin >> n; for (int i = 1; i < n; i++) { cin >> x; cnt[x]++; } for (int i = 1; i <= n; i++) { cout << cnt[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x; int cnt[200010] = {0}; cin >> n; for (int i = 1; i < n; i++) { cin >> x; cnt[x]++; } for (int i = 1; i <= n; i++) { cout << cnt[i] << endl; } return 0; }
replace
4
5
4
5
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int INF = 1e9; const ll INFLL = 1e18; const int MOD = 1e9 + 7; const int NIL = -1; const ld PI = acosl(-1); #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(n) n.begin(), n.end() int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(6); int n; cin >> n; vi a(n); rep(i, n - 1) cin >> a[i]; vi ans(n + 1, 0); rep(i, n) { ans[a[i] - 1]++; } rep(i, n) { cout << ans[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int INF = 1e9; const ll INFLL = 1e18; const int MOD = 1e9 + 7; const int NIL = -1; const ld PI = acosl(-1); #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(n) n.begin(), n.end() int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(6); int n; cin >> n; vi a(n); rep(i, n - 1) cin >> a[i]; vi ans(n + 1, 0); rep(i, n - 1) { ans[a[i] - 1]++; } rep(i, n) { cout << ans[i] << endl; } return 0; }
replace
28
29
28
29
-6
double free or corruption (out)
p02707
C++
Runtime Error
#include <iostream> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; int main() { int i, n; int *C; cin >> n; C = (int *)malloc(sizeof(int)); for (i = 0; i < n; i++) { C[i] = 0; } for (i = 0; i < n - 1; i++) { int k; cin >> k; C[k - 1]++; } for (i = 0; i < n; i++) { cout << C[i] << endl; } free(C); }
#include <iostream> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; int main() { int i, n; int *C; cin >> n; C = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; i++) { C[i] = 0; } for (i = 0; i < n - 1; i++) { int k; cin >> k; C[k - 1]++; } for (i = 0; i < n; i++) { cout << C[i] << endl; } free(C); }
replace
12
13
12
13
0
p02707
C++
Runtime Error
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); vector<int> b(n, 0); for (int i = 0; i < n - 1; i++) cin >> a[i]; for (auto e : a) b[e - 1]++; for (auto e : b) cout << e << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(16); solve(); return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; void solve() { int n; cin >> n; vector<int> a(n - 1); vector<int> b(n, 0); for (int i = 0; i < n - 1; i++) cin >> a[i]; for (auto e : a) b[e - 1]++; for (auto e : b) cout << e << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(16); solve(); return 0; }
replace
16
17
16
17
-6
double free or corruption (out)
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; #define all(x) x.begin(), x.end() template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) { if (x > y) x = y; } template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) { if (x < y) x = y; } int n; vector<int> a; void read() { cin >> n; a.resize(n); for (int i = 0; i < n; i++) { int x; cin >> x; x--; a[x]++; } for (auto i : a) cout << i << "\n"; } void run() {} void write() {} signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); read(); run(); write(); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; #define all(x) x.begin(), x.end() template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) { if (x > y) x = y; } template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) { if (x < y) x = y; } int n; vector<int> a; void read() { cin >> n; a.resize(n); for (int i = 0; i < n - 1; i++) { int x; cin >> x; x--; a[x]++; } for (auto i : a) cout << i << "\n"; } void run() {} void write() {} signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); read(); run(); write(); return 0; }
replace
23
24
23
24
0
p02707
C++
Runtime Error
#include <iostream> #define ll long int const int ARR = 1e5 + 2; using namespace std; int main() { ll n; cin >> n; ll a[ARR]; a[0] = 1; for (int i = 1; i < n; i++) { cin >> a[i]; } ll ans[ARR] = {0}; for (int i = 1; i < n; i++) { ans[a[i] - 1]++; } for (int i = 0; i < n; i++) { cout << ans[i] << endl; } return 0; }
#include <iostream> #define ll long int const int ARR = 2e5 + 5; using namespace std; int main() { ll n; cin >> n; ll a[ARR]; a[0] = 1; for (int i = 1; i < n; i++) { cin >> a[i]; } ll ans[ARR] = {0}; for (int i = 1; i < n; i++) { ans[a[i] - 1]++; } for (int i = 0; i < n; i++) { cout << ans[i] << endl; } return 0; }
replace
2
3
2
3
0
p02707
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<int> B(N); A[0] = 0; B[0] = 0; for (int i = 1; i < N; i++) { cin >> A[i]; B[i] = 0; } for (int i = 0; i < N; i++) { B[A[i] - 1] += 1; } for (int i = 0; i < N; i++) { cout << B[i] << endl; } return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<int> B(N); A[0] = 0; B[0] = 0; for (int i = 1; i < N; i++) { cin >> A[i]; B[i] = 0; } for (int i = 1; i < N; i++) { B[A[i] - 1] += 1; } for (int i = 0; i < N; i++) { cout << B[i] << endl; } return 0; }
replace
23
24
23
24
-6
double free or corruption (out)
p02707
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; int main() { #ifdef RUN_LOCAL ifstream in("../input.txt"); cin.rdbuf(in.rdbuf()); #endif cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); vector<int> b(n); for (int i = 0; i < n; ++i) { cin >> a[i]; b[a[i] - 1]++; } for (int i = 0; i < n; ++i) { cout << b[i] << endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; int main() { #ifdef RUN_LOCAL ifstream in("../input.txt"); cin.rdbuf(in.rdbuf()); #endif cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); vector<int> b(n); for (int i = 0; i < n - 1; ++i) { cin >> a[i]; b[a[i] - 1]++; } for (int i = 0; i < n; ++i) { cout << b[i] << endl; } return 0; }
replace
33
34
33
34
-6
double free or corruption (out)
p02707
C++
Runtime Error
#include <iostream> using namespace std; int A[100005]; int main() { int N, M; cin >> N; for (int i = 1; i < N; i++) { int t; cin >> t; A[t - 1]++; } for (int i = 0; i < N; i++) cout << A[i] << endl; return 0; }
#include <iostream> using namespace std; int A[200005]; int main() { int N, M; cin >> N; for (int i = 1; i < N; i++) { int t; cin >> t; A[t - 1]++; } for (int i = 0; i < N; i++) cout << A[i] << endl; return 0; }
replace
2
3
2
3
0
p02707
C++
Time Limit Exceeded
#include <algorithm> #include <cstring> #include <iostream> #include <math.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using namespace std; int main() { ll n; cin >> n; vector<int> a(n - 1); rep(i, n - 1) cin >> a[i]; ll ans1 = 0; rep(i, n - 1) { if (a[i] == 1) ++ans1; } cout << ans1 << endl; for (int z = 2; z <= n; ++z) { ll ans2 = 0; rep(i, n) { if (a[i] == z) { ++ans2; } } cout << ans2 << endl; } return 0; }
#include <algorithm> #include <cstring> #include <iostream> #include <math.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using namespace std; int main() { ll n; cin >> n; vector<int> a(n - 1); rep(i, n - 1) cin >> a[i]; vector<int> z(n); rep(i, n - 1) { z[a[i] - 1] += 1; } rep(i, n) { cout << z[i] << endl; } return 0; }
replace
15
30
15
19
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 2; int arr[MAXN]; int main() { int N; cin >> N; for (int i = 2; i <= N; i++) { int pos; cin >> pos; arr[pos]++; } for (int i = 1; i <= N; i++) { cout << arr[i] << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 2; int arr[MAXN]; int main() { int N; cin >> N; for (int i = 2; i <= N; i++) { int pos; cin >> pos; arr[pos]++; } for (int i = 1; i <= N; i++) { cout << arr[i] << "\n"; } return 0; }
replace
3
4
3
4
0
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> s(N, 0); for (int i = 1; i < N; i++) { cin >> s.at(i); } vector<int> result(N, 0); for (int i = 1; i < N; i++) { for (int j = 1; j < N; j++) { if (s.at(j) == i) { result.at(i - 1) += 1; } } } for (int i = 0; i < N; i++) { cout << result.at(i) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> s(N, 0); for (int i = 1; i < N; i++) { cin >> s.at(i); } vector<int> result(N, 0); for (int i = 1; i < N; i++) { result.at(s.at(i) - 1) += 1; } for (int i = 0; i < N; i++) { cout << result.at(i) << endl; } return 0; }
replace
11
16
11
12
TLE
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N - 1); vector<int> b(N); for (int i = 0; i < N - 1; i++) { cin >> a[i]; } for (int j = 0; j < N - 1; j++) { for (int k = 1; k < N; k++) { if (a[j] == k) b[k - 1]++; } } for (int l = 0; l < N; l++) { cout << b[l] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N - 1); vector<int> b(N); for (int i = 0; i < N - 1; i++) { cin >> a[i]; } for (int j = 0; j < N - 1; j++) { b[a[j] - 1]++; } for (int l = 0; l < N; l++) { cout << b[l] << endl; } }
replace
13
17
13
14
TLE
p02707
C++
Runtime Error
#include <algorithm> #include <array> #include <cmath> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <string> typedef long long int ll; using namespace std; #define maxN 200007 int n; int solve() { int temp[maxN] = {}; for (int i = 0; i < n - 1; i++) { int a; cin >> a; temp[a]++; } for (int i = 1; i <= n; i++) { cout << temp[i] << endl; } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; solve(); }
#include <algorithm> #include <array> #include <cmath> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <string> typedef long long int ll; using namespace std; #define maxN 200007 int n; void solve() { int temp[maxN] = {}; for (int i = 0; i < n - 1; i++) { int a; cin >> a; temp[a]++; } for (int i = 1; i <= n; i++) { cout << temp[i] << endl; } } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; solve(); }
replace
15
16
15
16
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; signed main() { int subs[100000]; int n; cin >> n; subs[0] = 0; for (int i = 1; i < n; i++) { subs[i] = 0; int no; cin >> no; subs[no - 1]++; } for (int i = 0; i < n; i++) { cout << subs[i] << endl; } }
#include <bits/stdc++.h> using namespace std; signed main() { int subs[200000]; int n; cin >> n; subs[0] = 0; for (int i = 1; i < n; i++) { subs[i] = 0; int no; cin >> no; subs[no - 1]++; } for (int i = 0; i < n; i++) { cout << subs[i] << endl; } }
replace
4
5
4
5
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> #include <cmath> #include <math.h> #include <stdio.h> using namespace std; #define vsort(vec) sort(vec.begin(), vec.end()) #define vreverse(vec) reverse(vec.begin(), vec.end()) using ll = long long; using ull = unsigned long long; const ll INF = 1001001001; // 10億7。   100000007 // 最大公約数 ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } // 最小公倍数 ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { cout << fixed << setprecision(10); // cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> vec(N - 1); vector<ll> vecans(N); for (int i = 0; i < N - 1; i++) { cin >> vec[i]; } for (int i = 0; i < N; i++) { vecans[i] = 0; } for (int i = 0; i < N; i++) { vecans[vec[i] - 1]++; } for (int i = 0; i < N; i++) { cout << vecans[i] << endl; } }
#include <bits/stdc++.h> #include <cmath> #include <math.h> #include <stdio.h> using namespace std; #define vsort(vec) sort(vec.begin(), vec.end()) #define vreverse(vec) reverse(vec.begin(), vec.end()) using ll = long long; using ull = unsigned long long; const ll INF = 1001001001; // 10億7。   100000007 // 最大公約数 ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } // 最小公倍数 ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { cout << fixed << setprecision(10); // cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> vec(N - 1); vector<ll> vecans(N); for (int i = 0; i < N - 1; i++) { cin >> vec[i]; } for (int i = 0; i < N; i++) { vecans[i] = 0; } for (int i = 0; i < N - 1; i++) { vecans[vec[i] - 1]++; } for (int i = 0; i < N; i++) { cout << vecans[i] << endl; } }
replace
38
39
38
39
-6
munmap_chunk(): invalid pointer
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int a[100001]; int main() { int n; cin >> n; int temp; for (int i = 1; i < n; i++) { cin >> temp; a[temp]++; } for (int i = 1; i <= n; i++) cout << a[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[200001]; int main() { int n; cin >> n; int temp; for (int i = 1; i < n; i++) { cin >> temp; a[temp]++; } for (int i = 1; i <= n; i++) cout << a[i] << endl; return 0; }
replace
3
4
3
4
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> vec(N - 1); for (int i = 0; i < N - 1; i++) { cin >> vec.at(i); } vector<int> count(N - 1); for (int i = 0; i < N - 1; i++) { count.at(vec.at(i))++; } for (int i = 1; i <= N; i++) { cout << count.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> vec(N - 1); for (int i = 0; i < N - 1; i++) { cin >> vec.at(i); } vector<int> count(N + 1); for (int i = 0; i < N - 1; i++) { count.at(vec.at(i))++; } for (int i = 1; i <= N; i++) { cout << count.at(i) << endl; } }
replace
11
12
11
12
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
p02707
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> v1(n); vector<int> v2(n - 1); for (int i = 0; i < n - 1; ++i) { cin >> v2[i]; } for (int i = 1; i < n; ++i) { for (int j = 0; j < n - 1; j++) { if (i == v2[j]) v1[i - 1]++; } } for (int i = 0; i < n; ++i) { cout << v1[i] << endl; } return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> v1(n); vector<int> v2(n - 1); for (int i = 0; i < n - 1; ++i) { cin >> v2[i]; v1[v2[i] - 1]++; } for (int i = 0; i < n; ++i) { cout << v1[i] << endl; } return 0; }
replace
10
16
10
11
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define fo(i, n) for (int i = 0; i < n; i++) #define Fo(i, k, n) for (int i = k; i < n; i++) #define endl "\n" #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define vec(x) vector<x> #define matrix(x) vector<vector<x>> #define mem(a, b) memset(a, b, sizeof a) #define vii vector<pair<int, int>> #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define MOD 998244353 #define deb(x) cerr << #x << " = " << x << "\n" #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; #define w(x) \ int x; \ cin >> x; \ while (x--) #define all(v) v.begin(), v.end() #define rep(i, a, b) for (int i = a; i < b; ++i) #define len(s) s.length() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; int power(int a, int b, int m = mod) { int ans = 1; while (b > 0) { if (b & 1) ans = (ans * a) % m; a = (a * a) % m; b >>= 1; } return ans; } void angshuGod() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } const int N = 1e5 + 1; const double pi = acos(-1); vi adj[N]; void solve() { int n; cin >> n; for (int i = 2; i <= n; i++) { int x; cin >> x; adj[x].pb(i); } for (int i = 1; i <= n; i++) { cout << adj[i].size() << "\n"; } } int32_t main() { angshuGod(); int t; t = 1; // cin>>t; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define fo(i, n) for (int i = 0; i < n; i++) #define Fo(i, k, n) for (int i = k; i < n; i++) #define endl "\n" #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define vec(x) vector<x> #define matrix(x) vector<vector<x>> #define mem(a, b) memset(a, b, sizeof a) #define vii vector<pair<int, int>> #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define MOD 998244353 #define deb(x) cerr << #x << " = " << x << "\n" #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; #define w(x) \ int x; \ cin >> x; \ while (x--) #define all(v) v.begin(), v.end() #define rep(i, a, b) for (int i = a; i < b; ++i) #define len(s) s.length() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; int power(int a, int b, int m = mod) { int ans = 1; while (b > 0) { if (b & 1) ans = (ans * a) % m; a = (a * a) % m; b >>= 1; } return ans; } void angshuGod() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } const int N = 200007; const double pi = acos(-1); vi adj[N]; void solve() { int n; cin >> n; for (int i = 2; i <= n; i++) { int x; cin >> x; adj[x].pb(i); } for (int i = 1; i <= n; i++) { cout << adj[i].size() << "\n"; } } int32_t main() { angshuGod(); int t; t = 1; // cin>>t; while (t--) { solve(); } return 0; }
replace
64
65
64
65
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define pb push_back int main() { int n; cin >> n; int a[n + 1]; for (int i = 2; i <= n; i++) cin >> a[i]; int v[n + 1]; for (int i = 1; i <= n; i++) { v[i] = 0; } for (int i = 1; i <= n; i++) { v[a[i]]++; } for (int i = 1; i <= n; i++) { cout << v[i] << "\n"; } }
#include <bits/stdc++.h> using namespace std; #define pb push_back int main() { int n; cin >> n; int a[n + 1]; for (int i = 2; i <= n; i++) cin >> a[i]; int v[n + 1]; for (int i = 1; i <= n; i++) { v[i] = 0; } for (int i = 2; i <= n; i++) { v[a[i]]++; } for (int i = 1; i <= n; i++) { cout << v[i] << "\n"; } }
replace
13
14
13
14
-11
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<int> B(N); for (int x : A) { cin >> x; B.at(x - 1)++; } for (int i = 0; i < N; i++) { cout << B.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N - 1); vector<int> B(N); for (int x : A) { cin >> x; B.at(x - 1)++; } for (int i = 0; i < N; i++) { cout << B.at(i) << endl; } }
replace
6
7
6
7
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 5)
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define d(x) cerr << #x ":" << x << endl; #define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl #define rep(i, n) for (int i = (int)(0); i < (int)(n); i++) #define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define all(v) v.begin(), v.end() #define dump(v) \ cerr << #v ":[ "; \ for (auto macro_vi : v) { \ cerr << macro_vi << " "; \ } \ cerr << "]" << endl; #define ddump(v) \ cerr << #v ":" << endl; \ for (auto macro_row : v) { \ cerr << "["; \ for (auto macro__vi : macro_row) { \ cerr << macro__vi << " "; \ } \ cerr << "]" << endl; \ } using lint = long long; const int INF = 1e9; const lint LINF = 1e18; const lint MOD = 1e9 + 7; const double EPS = 1e-10; int main() { int N; cin >> N; vector<lint> A(N, 0); vector<lint> X(N, 0); rep(i, N) { cin >> A[i]; A[i]--; X[A[i]]++; } // dump(X); rep(i, N) { cout << X[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define d(x) cerr << #x ":" << x << endl; #define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl #define rep(i, n) for (int i = (int)(0); i < (int)(n); i++) #define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define all(v) v.begin(), v.end() #define dump(v) \ cerr << #v ":[ "; \ for (auto macro_vi : v) { \ cerr << macro_vi << " "; \ } \ cerr << "]" << endl; #define ddump(v) \ cerr << #v ":" << endl; \ for (auto macro_row : v) { \ cerr << "["; \ for (auto macro__vi : macro_row) { \ cerr << macro__vi << " "; \ } \ cerr << "]" << endl; \ } using lint = long long; const int INF = 1e9; const lint LINF = 1e18; const lint MOD = 1e9 + 7; const double EPS = 1e-10; int main() { int N; cin >> N; vector<lint> A(N, 0); vector<lint> X(N, 0); rep(i, N - 1) { cin >> A[i]; A[i]--; X[A[i]]++; } // dump(X); rep(i, N) { cout << X[i] << endl; } return 0; }
replace
34
35
34
35
-6
munmap_chunk(): invalid pointer
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int t, i, c[100], x; cin >> t; for (i = 1; i <= t - 1; i++) { cin >> x; c[x]++; } for (int i = 1; i <= t; i++) cout << c[i] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int t, i, c[1000005], x; cin >> t; for (i = 1; i <= t - 1; i++) { cin >> x; c[x]++; } for (int i = 1; i <= t; i++) cout << c[i] << endl; }
replace
3
4
3
4
0
p02707
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vi; #define forn(i, n) for (int(i) = 0; (i) != (n); (i)++) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define popcount(x) __builtin_popcount(x) #define popcountll(x) __builtin_popcountll(x) #define fi first #define se second #ifdef LOCAL #define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl #define ln cerr << __LINE__ << endl #else #define dbg(x) void(0) #define ln void(0) #endif // LOCAL const int N = 150000; const int M = 500; const int MOD = 1e9 + 7; const int alpha = 26; const double PI = acos(-1); ll n, k; ll ans = 0; ll a[N]; ll b[N]; signed main() { #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif // ONLINE_JUDGE cin >> n; for (int i = 1; i < n; i++) cin >> k, a[k]++; for (int i = 1; i <= n; i++) cout << a[i] << "\n"; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vi; #define forn(i, n) for (int(i) = 0; (i) != (n); (i)++) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define popcount(x) __builtin_popcount(x) #define popcountll(x) __builtin_popcountll(x) #define fi first #define se second #ifdef LOCAL #define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl #define ln cerr << __LINE__ << endl #else #define dbg(x) void(0) #define ln void(0) #endif // LOCAL const int N = 250000; const int M = 500; const int MOD = 1e9 + 7; const int alpha = 26; const double PI = acos(-1); ll n, k; ll ans = 0; ll a[N]; ll b[N]; signed main() { #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif // ONLINE_JUDGE cin >> n; for (int i = 1; i < n; i++) cin >> k, a[k]++; for (int i = 1; i <= n; i++) cout << a[i] << "\n"; }
replace
31
32
31
32
0
p02707
C++
Runtime Error
/** * author: musasi * created: 19.04.2020 21:29:30 **/ #include <bits/stdc++.h> using namespace std; #define rep2(x, from, to) for (long long(x) = (from); (x) < (to); (x)++) #define rep(x, to) rep2(x, 0, to) #define MOD 10000007 // 10^9+7 #define PB push_back #define MP make_pair #define F first #define S second #define ALL(x) (x).begin(), (x).end() #define ASSERT(expr...) assert((expr)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> PP; typedef pair<ll, PP> PPP; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int n; int ans[100006]; signed main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> n; vector<int> a(n - 1); rep(i, n - 1) { cin >> a[i]; ans[a[i] - 1]++; } rep(i, n) cout << ans[i] << endl; return 0; }
/** * author: musasi * created: 19.04.2020 21:29:30 **/ #include <bits/stdc++.h> using namespace std; #define rep2(x, from, to) for (long long(x) = (from); (x) < (to); (x)++) #define rep(x, to) rep2(x, 0, to) #define MOD 10000007 // 10^9+7 #define PB push_back #define MP make_pair #define F first #define S second #define ALL(x) (x).begin(), (x).end() #define ASSERT(expr...) assert((expr)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; typedef pair<ll, ll> P; typedef pair<ll, P> PP; typedef pair<ll, PP> PPP; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int n; int ans[200006]; signed main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> n; vector<int> a(n - 1); rep(i, n - 1) { cin >> a[i]; ans[a[i] - 1]++; } rep(i, n) cout << ans[i] << endl; return 0; }
replace
38
39
38
39
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; #define REP(i, n) for (ll i = 0LL; i < (ll)(n); i++) #define REPR(i, n) for (ll i = n - 1; i > 0LL; i--) #define FOR(i, n, m) for (ll i = n; i < (ll)(m); i++) #define PRINT(x) cout << x << endl #define ALL(v) v.begin(), v.end() #define INF (ll)1e18 #define PI 3.14159265358979 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll MOD = 1000000007; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } int main() { ll N; cin >> N; vector<ll> A(N - 1); REP(i, N - 1) cin >> A[i]; vector<ll> ans(N); REP(i, N) { ans[A[i] - 1] += 1; } REP(i, N) { PRINT(ans[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; #define REP(i, n) for (ll i = 0LL; i < (ll)(n); i++) #define REPR(i, n) for (ll i = n - 1; i > 0LL; i--) #define FOR(i, n, m) for (ll i = n; i < (ll)(m); i++) #define PRINT(x) cout << x << endl #define ALL(v) v.begin(), v.end() #define INF (ll)1e18 #define PI 3.14159265358979 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll MOD = 1000000007; const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } int main() { ll N; cin >> N; vector<ll> A(N - 1); REP(i, N - 1) cin >> A[i]; vector<ll> ans(N); REP(i, N - 1) { ans[A[i] - 1] += 1; } REP(i, N) { PRINT(ans[i]); } return 0; }
replace
64
65
64
65
-6
munmap_chunk(): invalid pointer
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int N = 100005; vector<int> g[N]; int sz[N]; int dfs(int u, int p) { sz[u] = 1; for (int v : g[u]) if (v != p) sz[u] += dfs(v, u); return sz[u]; } int main() { int n; scanf("%d", &n); for (int i = 2; i <= n; i++) { int p; scanf("%d", &p); sz[p]++; g[p].push_back(i); } // dfs(1, 1); for (int i = 1; i <= n; i++) { printf("%d\n", sz[i]); } }
#include <bits/stdc++.h> using namespace std; const int N = 200005; vector<int> g[N]; int sz[N]; int dfs(int u, int p) { sz[u] = 1; for (int v : g[u]) if (v != p) sz[u] += dfs(v, u); return sz[u]; } int main() { int n; scanf("%d", &n); for (int i = 2; i <= n; i++) { int p; scanf("%d", &p); sz[p]++; g[p].push_back(i); } // dfs(1, 1); for (int i = 1; i <= n; i++) { printf("%d\n", sz[i]); } }
replace
4
5
4
5
0
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> a(n - 1); for (int i = 0; i < n - 1; i++) { cin >> a.at(i); } vector<int> sum(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (i + 1 == a.at(j)) { sum.at(i) += 1; } } } for (int i = 0; i < n; i++) { cout << sum.at(i) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> a(n - 1); for (int i = 0; i < n - 1; i++) { cin >> a.at(i); } vector<int> sum(n); for (int i = 0; i < n - 1; i++) { sum.at(a.at(i) - 1)++; } for (int i = 0; i < n; i++) { cout << sum.at(i) << endl; } return 0; }
replace
11
17
11
13
TLE
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; struct node { int num; int sco; } b[200005]; int main() { int n, i, j; cin >> n; int a[n]; for (i = 1; i <= n; i++) b[i].num = i; for (i = 1; i < n; i++) cin >> a[i]; for (i = 1; i < n; i++) for (j = 1; j <= n; j++) { if (a[i] == b[j].num) b[j].sco++; } for (i = 1; i <= n; i++) cout << b[i].sco << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct node { int num; int sco; } b[200005]; int main() { int n, i, j; cin >> n; int a[n]; for (i = 1; i <= n; i++) b[i].num = i; for (i = 1; i < n; i++) cin >> a[i]; for (i = 1; i < n; i++) b[a[i]].sco++; for (i = 1; i <= n; i++) cout << b[i].sco << endl; return 0; }
replace
19
23
19
20
TLE
p02707
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <vector> #define pb push_back #define fi first #define se second #define sz(x) x.size() #define cl(x) x.clear() #define all(x) x.begin(), x.end() #define r(x) scanf("%d", &x) #define rr(x, y) scanf("%d%d", &x, &y) #define rst(s) scanf("%s", s) #define rl(x) scanf("%lld", &x) #define rrl(x, y) scanf("%lld%lld", &x, &y) #define w(x) printf("%d", x) #define ww(x, y) printf("%d %d", x, y) #define wl(x) printf("%lld", x) #define wwl(x, y) printf("%lld %lld", x, y) #define sp() printf(" ") #define en() puts("") #define rep(i, x, n) for (int i = x; i <= n; i++) #define per(i, n, x) for (int i = n; i >= x; i--) #define mem0(x) memset(x, 0, sizeof(x)) #define mem_1(x) memset(x, -1, sizeof(x)) #define mem_inf(x) memset(x, inf, sizeof(x)) #define mem__inf(x) memset(x, -inf, sizeof(x)) #define p_queue priority_queue #define debug(x) cout << x << '\n' #define ddebug(x, y) cout << x << ' ' << y << '\n' using namespace std; // mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) // ; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; typedef pair<ll, int> pli; const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 5; const int maxm = 30; const ll mod = 1e9 + 7; int n, in[maxn]; int main() { r(n); mem0(in); rep(i, 1, n - 1) { int x; r(x); in[x]++; } rep(i, 1, n) w(in[i]), en(); return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <vector> #define pb push_back #define fi first #define se second #define sz(x) x.size() #define cl(x) x.clear() #define all(x) x.begin(), x.end() #define r(x) scanf("%d", &x) #define rr(x, y) scanf("%d%d", &x, &y) #define rst(s) scanf("%s", s) #define rl(x) scanf("%lld", &x) #define rrl(x, y) scanf("%lld%lld", &x, &y) #define w(x) printf("%d", x) #define ww(x, y) printf("%d %d", x, y) #define wl(x) printf("%lld", x) #define wwl(x, y) printf("%lld %lld", x, y) #define sp() printf(" ") #define en() puts("") #define rep(i, x, n) for (int i = x; i <= n; i++) #define per(i, n, x) for (int i = n; i >= x; i--) #define mem0(x) memset(x, 0, sizeof(x)) #define mem_1(x) memset(x, -1, sizeof(x)) #define mem_inf(x) memset(x, inf, sizeof(x)) #define mem__inf(x) memset(x, -inf, sizeof(x)) #define p_queue priority_queue #define debug(x) cout << x << '\n' #define ddebug(x, y) cout << x << ' ' << y << '\n' using namespace std; // mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) // ; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; typedef pair<ll, int> pli; const int inf = 0x3f3f3f3f; const int maxn = 2e5 + 5; const int maxm = 30; const ll mod = 1e9 + 7; int n, in[maxn]; int main() { r(n); mem0(in); rep(i, 1, n - 1) { int x; r(x); in[x]++; } rep(i, 1, n) w(in[i]), en(); return 0; }
replace
45
46
45
46
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int n, x = 0; cin >> n; vector<int> a, b; rep(i, n - 1) cin >> a[i]; rep(i, n) b[i] = 0; sort(a.begin(), a.end()); rep(i, n) { while (a[x] == i + 1) { x++; b[i]++; } } rep(i, n) cout << b[i] << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int n, x = 0; cin >> n; vector<int> a(n - 1), b(n); rep(i, n - 1) cin >> a[i]; rep(i, n) b[i] = 0; sort(a.begin(), a.end()); rep(i, n) { while (a[x] == i + 1) { x++; b[i]++; } } rep(i, n) cout << b[i] << endl; return 0; }
replace
8
9
8
9
-11
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n - 1); for (int i = 0; i < n - 1; i++) { cin >> a.at(i); } vector<int> ans(n, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (i + 1 == a.at(j)) { ans.at(i)++; } } } for (int i = 0; i < n; i++) { cout << ans.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n - 1); for (int i = 0; i < n - 1; i++) { cin >> a.at(i); } vector<int> ans(n); for (int i = 0; i < n - 1; i++) { ans.at(a.at(i) - 1)++; } for (int i = 0; i < n; i++) { cout << ans.at(i) << endl; } }
replace
10
17
10
13
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // typedef typedef long long ll; typedef vector<int> vi; typedef vector<string> vs; // define #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) int main() { int n; cin >> n; vi a(n), b(n); rep(i, n - 1) cin >> a[i]; rep(i, n) { b[a.at(i) - 1] += 1; } rep(i, n) cout << b[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; // typedef typedef long long ll; typedef vector<int> vi; typedef vector<string> vs; // define #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) int main() { int n; cin >> n; vi a(n), b(n); rep(i, n - 1) cin >> a[i]; rep(i, n - 1) { b[a.at(i) - 1] += 1; } rep(i, n) cout << b[i] << endl; return 0; }
replace
16
17
16
17
-6
double free or corruption (out)
p02707
C++
Runtime Error
#include <iostream> using namespace std; int main(void) { int N; cin >> N; int a[20000] = {0}; int c[20000] = {0}; for (int i = 2; i <= N; i++) { cin >> a[i]; c[a[i]]++; } for (int i = 1; i <= N; i++) { cout << c[i] << endl; } }
#include <iostream> using namespace std; int main(void) { int N; cin >> N; int a[200001] = {0}; int c[200001] = {0}; for (int i = 2; i <= N; i++) { cin >> a[i]; c[a[i]]++; } for (int i = 1; i <= N; i++) { cout << c[i] << endl; } }
replace
8
10
8
10
0
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n)) #define ALL(a) (a).begin(), (a).end() using ll = long long; int main() { int n; cin >> n; vector<int> a(n); vector<int> add(n); rep(i, n - 1) { cin >> a.at(i + 1); } a.at(0) = 0; for (int i = 1; i < n; i++) { for (int j = 1; j <= n; j++) { if (a.at(i) == j) { add.at(j - 1)++; } } } rep(i, n) { printf("%d\n", add.at(i)); } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n)) #define ALL(a) (a).begin(), (a).end() using ll = long long; int main() { int n; cin >> n; vector<int> a(n); vector<int> add(n); rep(i, n - 1) { cin >> a.at(i + 1); } a.at(0) = 0; for (int i = 1; i < n; i++) { add.at(a.at(i) - 1)++; } rep(i, n) { printf("%d\n", add.at(i)); } }
replace
17
22
17
18
TLE
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long int #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define tc \ ll t = 0; \ cin >> t; \ while (t--) #define pb push_back #define pop pop_back #define all(x) (x).begin(), (x).end() #define lb lower_bound #define ub upper_bound #define endl "\n" #define max *max_element #define min *min_element #define f first #define s second #define vli vll::iterator #define mp make_pair #define max_val 99999999 #define min_val -99999999 #define mod 1000000007 int main() { IOS #ifdef LOCAL freopen("C:\\Users\\Just Coding Things\\Codeforces\\input.txt", "r", stdin); freopen("C:\\Users\\Just Coding Things\\Codeforces\\output.txt", "w", stdout); #endif ll n, i, cnt; cin >> n; vll v(n - 1), u(n); for (i = 0; i < n - 1; i++) cin >> v[i]; set<int> s; for (i = 0; i < v.size(); i++) s.insert(v[i]); set<int>::iterator it; for (it = s.begin(); it != s.end(); it++) { ll var = *it; cnt = count(all(v), var); u[var - 1] = cnt; } for (i = 0; i < n; i++) { cout << u[i] << "\n"; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long int #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define tc \ ll t = 0; \ cin >> t; \ while (t--) #define pb push_back #define pop pop_back #define all(x) (x).begin(), (x).end() #define lb lower_bound #define ub upper_bound #define endl "\n" #define max *max_element #define min *min_element #define f first #define s second #define vli vll::iterator #define mp make_pair #define max_val 99999999 #define min_val -99999999 #define mod 1000000007 int main() { IOS #ifdef LOCAL freopen("C:\\Users\\Just Coding Things\\Codeforces\\input.txt", "r", stdin); freopen("C:\\Users\\Just Coding Things\\Codeforces\\output.txt", "w", stdout); #endif ll n, i, cnt; cin >> n; vll v(n - 1), u(n), x; for (i = 0; i < n - 1; i++) { cin >> cnt; u[cnt - 1]++; } for (i = 0; i < n; i++) { cout << u[i] << "\n"; } cout << endl; return 0; }
replace
41
53
41
45
TLE
p02707
C++
Runtime Error
using namespace std; #include <bits/stdc++.h> int n, x; int a[100005]; int main() { cin >> n; for (int i = 0; i < n - 1; i++) { cin >> x; a[x - 1]++; } for (int i = 0; i < n; i++) { cout << a[i] << endl; } }
using namespace std; #include <bits/stdc++.h> int n, x; int a[200005]; int main() { cin >> n; for (int i = 0; i < n - 1; i++) { cin >> x; a[x - 1]++; } for (int i = 0; i < n; i++) { cout << a[i] << endl; } }
replace
4
5
4
5
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int ar[100003]; int main() { int n; cin >> n; int x; for (int i = 1; i <= n - 1; i++) { cin >> x; ar[x] = ar[x] + 1; } for (int i = 1; i <= n; i++) { cout << ar[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int ar[200005]; int main() { int n; cin >> n; int x; for (int i = 1; i <= n - 1; i++) { cin >> x; ar[x] = ar[x] + 1; } for (int i = 1; i <= n; i++) { cout << ar[i] << endl; } return 0; }
replace
3
4
3
4
0
p02707
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { int n; cin >> n; vector<int> a(20001); for (int i = 0; i < n - 1; i++) { int x; cin >> x; a[x]++; } for (int i = 1; i <= n; i++) { cout << a[i] << '\n'; } }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { int n; cin >> n; vector<int> a(200001); for (int i = 0; i < n - 1; i++) { int x; cin >> x; a[x]++; } for (int i = 1; i <= n; i++) { cout << a[i] << '\n'; } }
replace
10
11
10
11
0
p02707
Python
Time Limit Exceeded
N = int(input()) A = list(map(int, input().split())) for i in range(1, N + 1): print(A.count(i))
N = int(input()) A = list(map(int, input().split())) lis = [0] * N for i in range(N - 1): lis[(A[i] - 1)] += 1 for i in range(N): print(lis[i])
replace
2
4
2
9
TLE
p02707
Python
Time Limit Exceeded
n = int(input()) a = list(map(int, input().split())) for i in range(n): print(a.count(i + 1))
n = int(input()) a = list(map(int, input().split())) b = [0 for i in range(n)] for i in a: b[i - 1] += 1 for i in b: print(i)
replace
2
4
2
9
TLE
p02707
Python
Time Limit Exceeded
N = int(input()) A = list(map(int, input().split())) B = [] for i in range(1, N + 1): print(A.count(i))
N = int(input()) A = list(map(int, input().split())) B = [0 for i in range(N)] for i in A: B[i - 1] += 1 for i in B: print(i)
replace
2
5
2
7
TLE
p02707
Python
Time Limit Exceeded
N = int(input()) A_i = list(map(int, input().split())) uq_A_i = list(set(A_i)) C = ["0\n"] * N for i in uq_A_i: C[i - 1] = "{}".format(A_i.count(i)) + "\n" print("".join(C))
N = int(input()) A_i = list(map(int, input().split())) C = [0] * N for i in A_i: C[i - 1] += 1 print(*C)
replace
2
7
2
6
TLE
p02707
C++
Runtime Error
#include <iostream> using namespace std; int main() { int n; int *p; cin >> n; p = new int(n); for (int i = 0; i < n; i++) p[i] = 0; for (int i = 0; i < n - 1; i++) { int data; cin >> data; p[data - 1]++; } for (int i = 0; i < n; i++) cout << p[i] << endl; delete[] p; return 0; }
#include <iostream> using namespace std; int main() { int n; int *p; cin >> n; p = new int[n]; for (int i = 0; i < n; i++) p[i] = 0; for (int i = 0; i < n - 1; i++) { int data; cin >> data; p[data - 1]++; } for (int i = 0; i < n; i++) cout << p[i] << endl; delete[] p; return 0; }
replace
9
10
9
10
0
p02707
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define I64d_OJ // #ifdef I64d_OJ // #define LL __int64 // #endif // I64d_OJ #ifdef I64d_OJ #define LL long long #endif // I64d_OJ typedef unsigned LL ULL; typedef unsigned uint; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<LL, LL> pLL; typedef vector<int> vi; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -f; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define ls rt << 1 #define rs rt << 1 | 1 #define MID(a, b) (((LL)(a) + (LL)(b)) >> 1) #define absx(a) ((a) < 0 ? -(a) : (a)) #define MK(a, b) make_pair(a, b) #define PB(a) push_back(a) #define lowbit(x) ((x) & -(x)) #define lc c[x][0] #define rc c[x][1] template <typename T> inline void Max(T &a, T &b) { if (a < b) a = b; } template <typename T> inline void Min(T &a, T &b) { if (a > b) a = b; } const double pi = (double)acos(-1.0); const double eps = (double)1e-8; const int INF = (int)0x3f3f3f3f; const int MOD = (int)998244353; const int MAXN = (int)3e3 + 10; const int MAXM = (int)3e6 + 10; ///--------------------START------------------------- int N; vector<int> G[MAXN]; void work() { scanf("%d", &N); for (int i = 1; i < N; i++) { int p; scanf("%d", &p); G[p].push_back(i); } for (int i = 1; i <= N; i++) { printf("%d\n", G[i].size()); } } ///--------------------END------------------------- int main() { #ifdef NNever // freopen("data.in","r",stdin); /// freopen("out.txt","w",stdout); #endif // NNever work(); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define I64d_OJ // #ifdef I64d_OJ // #define LL __int64 // #endif // I64d_OJ #ifdef I64d_OJ #define LL long long #endif // I64d_OJ typedef unsigned LL ULL; typedef unsigned uint; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<LL, LL> pLL; typedef vector<int> vi; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -f; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define ls rt << 1 #define rs rt << 1 | 1 #define MID(a, b) (((LL)(a) + (LL)(b)) >> 1) #define absx(a) ((a) < 0 ? -(a) : (a)) #define MK(a, b) make_pair(a, b) #define PB(a) push_back(a) #define lowbit(x) ((x) & -(x)) #define lc c[x][0] #define rc c[x][1] template <typename T> inline void Max(T &a, T &b) { if (a < b) a = b; } template <typename T> inline void Min(T &a, T &b) { if (a > b) a = b; } const double pi = (double)acos(-1.0); const double eps = (double)1e-8; const int INF = (int)0x3f3f3f3f; const int MOD = (int)998244353; const int MAXN = (int)2e5 + 10; const int MAXM = (int)3e6 + 10; ///--------------------START------------------------- int N; vector<int> G[MAXN]; void work() { scanf("%d", &N); for (int i = 1; i < N; i++) { int p; scanf("%d", &p); G[p].push_back(i); } for (int i = 1; i <= N; i++) { printf("%d\n", G[i].size()); } } ///--------------------END------------------------- int main() { #ifdef NNever // freopen("data.in","r",stdin); /// freopen("out.txt","w",stdout); #endif // NNever work(); return 0; }
replace
77
78
77
78
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define repi(i, a, n) for (int i = (int)a; i < (int)(n); i++) #define ll long long int main(void) { int n; std::cin >> n; std::vector<int> num(100005, 0); rep(i, n - 1) { int t; std::cin >> t; num[t]++; } repi(i, 1, n + 1) { std::cout << num[i] << std::endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define repi(i, a, n) for (int i = (int)a; i < (int)(n); i++) #define ll long long int main(void) { int n; std::cin >> n; std::vector<int> num(1000005, 0); rep(i, n - 1) { int t; std::cin >> t; num[t]++; } repi(i, 1, n + 1) { std::cout << num[i] << std::endl; } }
replace
10
11
10
11
0
p02707
C++
Time Limit Exceeded
#pragma GCC diagnostic error "-std=c++14" #pragma GCC target("avx") #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #include <cctype> #include <cstdio> using namespace std; template <class code> inline code read(const code &a) { code x = 0; short w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return w ? -x : x; } void print(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) print(x / 10); putchar(x % 10 + 48); } int a[200005]; int main() { int n = read(n); for (int i = 1; i <= n; i++) { int x = read(x); a[x]++; } for (int i = 1; i <= n; i++) printf("%d\n", a[i]); return 0; }
#pragma GCC diagnostic error "-std=c++14" #pragma GCC target("avx") #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #include <cctype> #include <cstdio> using namespace std; template <class code> inline code read(const code &a) { code x = 0; short w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return w ? -x : x; } void print(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) print(x / 10); putchar(x % 10 + 48); } int a[200005]; int main() { int n = read(n); for (int i = 1; i <= n - 1; i++) { int x = read(x); a[x]++; } for (int i = 1; i <= n; i++) printf("%d\n", a[i]); return 0; }
replace
31
32
31
32
TLE
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define ALL(n) begin(n), end(n) using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> a(n); a[0] = 0; for (int i = 1; i < n; i++) { cin >> a[i]; } sort(ALL(a)); vector<int> ans(n + 1); ans[0] = 0; for (int i = 1; i < n + 1; i++) { ans[i] = count(a.begin() + ans[i - 1], a.end(), i); } rep(i, n) { cout << ans[i + 1] << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define ALL(n) begin(n), end(n) using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> a(n); a[0] = 0; for (int i = 1; i < n; i++) { cin >> a[i]; } sort(ALL(a)); vector<int> ans(n + 1); ans[0] = 0; int sum = 0; for (int i = 1; i <= n; i++) { for (int j = sum; j <= n; j++) { if (a[j + 1] != i) { ans[i] = j - sum; sum = j; break; } } } rep(i, n) { cout << ans[i + 1] << endl; } return 0; }
replace
18
20
18
27
TLE
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> vec1(N - 1); vector<int> vec2(N); for (int i = 0; i < N - 1; i++) { cin >> vec1.at(i); } for (int i = 0; i < N - 1; i++) { for (int j = 0; j < N; j++) { if (vec1.at(i) == j) { vec2.at(j - 1)++; } } } for (int i = 0; i < N; i++) { cout << vec2.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> vec1(N - 1); vector<int> vec2(N); for (int i = 0; i < N - 1; i++) { cin >> vec1.at(i); vec2.at(vec1.at(i) - 1)++; } for (int i = 0; i < N; i++) { cout << vec2.at(i) << endl; } }
replace
12
20
12
13
TLE
p02707
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main(void) { int N; int A[200001]; cin >> N; for (int i = 2; i <= N; i++) { cin >> A[i]; } int ans[200001]; for (int i = 1; i <= N; i++) { for (int j = 2; j <= N; j++) { if (A[j] == i) { ans[i]++; } } } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } return 0; }
#include <iostream> using namespace std; int main(void) { int N; int A[200001]; cin >> N; for (int i = 2; i <= N; i++) { cin >> A[i]; } int ans[200001]; for (int j = 2; j <= N; j++) { ans[A[j]]++; } for (int i = 1; i <= N; i++) { cout << ans[i] << endl; } return 0; }
replace
12
18
12
14
TLE
p02707
C++
Runtime Error
#include <iostream> using namespace std; int main(void) { int A[20001] = {0}; int N; int chk; cin >> N; for (int i = 0; i < N - 1; i++) { cin >> chk; A[chk]++; } for (int i = 1; i <= N; i++) { cout << A[i] << " "; } cout << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int A[200001] = {0}; int N; int chk; cin >> N; for (int i = 0; i < N - 1; i++) { cin >> chk; A[chk]++; } for (int i = 1; i <= N; i++) { cout << A[i] << " "; } cout << endl; return 0; }
replace
4
5
4
5
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i, a, n) for (ll i = a; i < n; i++) #define PI 3.141592653 int main() { ll arr[20002] = {0}; ll n; cin >> n; rep(i, 1, n) { ll ch; cin >> ch; arr[ch] += 1; } rep(i, 1, n + 1) cout << arr[i] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i, a, n) for (ll i = a; i < n; i++) #define PI 3.141592653 int main() { ll arr[200002] = {0}; ll n; cin >> n; rep(i, 1, n) { ll ch; cin >> ch; arr[ch] += 1; } rep(i, 1, n + 1) cout << arr[i] << "\n"; return 0; }
replace
6
7
6
7
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> a(n), ans(n, 0); for (int i = 2; i <= n; i++) cin >> a.at(i); for (int i = 2; i <= n; i++) ans.at(a.at(i))++; for (int i = 1; i <= n; i++) cout << ans.at(i) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> A(n - 1); vector<long long> B(n, 0); for (int i = 0; i < n - 1; i++) { cin >> A.at(i); B.at(A.at(i) - 1)++; } for (int i = 0; i < n; i++) { cout << B.at(i) << endl; } }
replace
6
13
6
17
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)
p02707
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> A(n - 1); for (int i = 0; i < n - 1; i++) { cin >> A.at(i); } vector<long long> B(n, 0); for (int i = 0; i < n - 1; i++) { for (int j = 1; j < n; j++) { if (A.at(i) == j) { B.at(j - 1)++; } } } for (int i = 0; i < n; i++) { cout << B.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> A(n - 1); for (int i = 0; i < n - 1; i++) { cin >> A.at(i); } vector<long long> B(n, 0); for (int i = 0; i < n - 1; i++) { B.at(A.at(i) - 1)++; } for (int i = 0; i < n; i++) { cout << B.at(i) << endl; } }
replace
15
20
15
16
TLE
p02707
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 1; i <= n; i++) { a[i] = 0; } int A[n]; for (int i = 2; i <= n; i++) { cin >> A[i]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == A[j]) a[i]++; } } for (int i = 1; i <= n; i++) { cout << a[i] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 1; i <= n; i++) { a[i] = 0; } int A[n]; for (int i = 2; i <= n; i++) { cin >> A[i]; a[A[i]]++; } for (int i = 1; i <= n; i++) { cout << a[i] << endl; } return 0; }
replace
15
22
15
16
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int mN = 100100; int c[mN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 2, a; i <= n; i++) cin >> a, c[a]++; for (int i = 1; i <= n; i++) cout << c[i] << " "; }
#include <bits/stdc++.h> using namespace std; const int mN = 200200; int c[mN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 2, a; i <= n; i++) cin >> a, c[a]++; for (int i = 1; i <= n; i++) cout << c[i] << " "; }
replace
3
4
3
4
0
p02707
C++
Runtime Error
#include <algorithm> #include <iomanip> #include <iostream> #include <limits> #include <math.h> using namespace std; #define rep(i, n) for (int i = 2; i <= (int)(n); i++) long long A[21111]; long long dp[21111]; int main() { long long N; cin >> N; rep(i, N) { cin >> A[i]; dp[A[i]]++; } for (int i = 1; i <= N; ++i) cout << dp[i] << endl; return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <limits> #include <math.h> using namespace std; #define rep(i, n) for (int i = 2; i <= (int)(n); i++) long long A[211111]; long long dp[211111]; int main() { long long N; cin >> N; rep(i, N) { cin >> A[i]; dp[A[i]]++; } for (int i = 1; i <= N; ++i) cout << dp[i] << endl; return 0; }
replace
8
10
8
10
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> #define mes(a, b) memset(a, b, sizeof a) #define pb push_back typedef unsigned long long int ull; typedef long long int ll; const int maxn = 1e5 + 20; const int maxm = 1e5 + 10; const ll mod = 1e9 + 7; const ll INF = 1e18 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); const double eps = 1e-8; using namespace std; int has[maxn]; int main() { int n; cin >> n; for (int i = 1; i < n; i++) { int v; cin >> v; has[v]++; } for (int i = 1; i <= n; i++) printf("%d\n", has[i]); }
#include <bits/stdc++.h> #define mes(a, b) memset(a, b, sizeof a) #define pb push_back typedef unsigned long long int ull; typedef long long int ll; const int maxn = 2e5 + 20; const int maxm = 1e5 + 10; const ll mod = 1e9 + 7; const ll INF = 1e18 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); const double eps = 1e-8; using namespace std; int has[maxn]; int main() { int n; cin >> n; for (int i = 1; i < n; i++) { int v; cin >> v; has[v]++; } for (int i = 1; i <= n; i++) printf("%d\n", has[i]); }
replace
6
7
6
7
0
p02707
C++
Runtime Error
//**PEACE BE UPON YOU** // AZMAYEN FAYEK SABIL // IUT CSE SWE-19 #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <cmath> #include <string> using namespace std; int main() { int n; cin >> n; int a[100005]; int c[100005] = {0}; int i; for (i = 1; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { c[a[i] - 1]++; } for (i = 0; i < n; i++) { cout << c[i] << endl; } return 0; }
//**PEACE BE UPON YOU** // AZMAYEN FAYEK SABIL // IUT CSE SWE-19 #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <cmath> #include <string> using namespace std; int main() { int n; cin >> n; int a[200005]; int c[200005] = {0}; int i; for (i = 1; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { c[a[i] - 1]++; } for (i = 0; i < n; i++) { cout << c[i] << endl; } return 0; }
replace
18
20
18
20
0
p02707
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); vector<int> b(n + 1); for (int i = 1; i < n; i++) { cin >> a[i]; } for (int i = 1; i < n + 1; i++) { int cnt = 0; for (int j = 1; j < n + 1; j++) { if (i == a[j]) { cnt++; b[a[j]] = cnt; } } } for (int i = 1; i < n + 1; i++) cout << b[i] << endl; }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); vector<int> b(n + 1); for (int i = 1; i < n; i++) { cin >> a[i]; b[a[i]]++; } for (int i = 1; i < n + 1; i++) cout << b[i] << endl; }
replace
11
20
11
12
TLE
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long int n; cin >> n; long long int a[n]; vector<long long int> v(n + 1, 0); for (long long int i = 0; i < n; i++) { cin >> a[i]; v[a[i]] += 1; } for (long long int i = 1; i < n + 1; i++) cout << v[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long int n; cin >> n; long long int a[n]; vector<long long int> v(n + 1, 0); for (long long int i = 0; i < n - 1; i++) { cin >> a[i]; v[a[i]] += 1; } for (long long int i = 1; i < n + 1; i++) cout << v[i] << endl; return 0; }
replace
9
10
9
10
-11
p02707
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e5 + 5, mod = 1e9 + 7; int freq[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i < n; i++) { int x; cin >> x; freq[x]++; } for (int i = 1; i <= n; i++) { cout << freq[i] << '\n'; } return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5 + 5, mod = 1e9 + 7; int freq[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i < n; i++) { int x; cin >> x; freq[x]++; } for (int i = 1; i <= n; i++) { cout << freq[i] << '\n'; } return 0; }
replace
3
4
3
4
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (i = a; i < n; i++) #define per(i, a, n) for (i = n - 1; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) #define SIZE 1000001 #define ONLINE_JUDGE #define rd #define PI acos(-1) typedef vector<int> VI; typedef long long ll; typedef pair<int, int> PII; typedef double db; mt19937 mrand(random_device{}()); auto clk = clock(); const ll mod = 1000000007; int rnd(int x) { return mrand() % x; } ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll infl = 0x3f3f3f3f3f3f3f3fLL; const int infi = 0x3f3f3f3f; int main() { int i, n, freq[100005]; memset(freq, 0, sizeof(freq)); cin >> n; rep(i, 1, n) { int x; cin >> x; freq[x - 1]++; } rep(i, 0, n) cout << freq[i] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (i = a; i < n; i++) #define per(i, a, n) for (i = n - 1; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) #define SIZE 1000001 #define ONLINE_JUDGE #define rd #define PI acos(-1) typedef vector<int> VI; typedef long long ll; typedef pair<int, int> PII; typedef double db; mt19937 mrand(random_device{}()); auto clk = clock(); const ll mod = 1000000007; int rnd(int x) { return mrand() % x; } ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll infl = 0x3f3f3f3f3f3f3f3fLL; const int infi = 0x3f3f3f3f; int main() { int i, n, freq[200005]; memset(freq, 0, sizeof(freq)); cin >> n; rep(i, 1, n) { int x; cin >> x; freq[x - 1]++; } rep(i, 0, n) cout << freq[i] << "\n"; return 0; }
replace
39
40
39
40
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> #include <map> using namespace std; int main(void) { int n; cin >> n; vector<int> a(n - 1); vector<int> cnt(n, 0); for (int i = 1; i < n; i++) cin >> a[i]; for (int i = 1; i < n;) { cnt[a[i] - 1]++; i++; } for (int i = 0; i < n; i++) cout << cnt[i] << endl; return 0; }
#include <bits/stdc++.h> #include <map> using namespace std; int main(void) { int n; cin >> n; vector<int> a(n); vector<int> cnt(n, 0); for (int i = 1; i < n; i++) cin >> a[i]; for (int i = 1; i < n;) { cnt[a[i] - 1]++; i++; } for (int i = 0; i < n; i++) cout << cnt[i] << endl; return 0; }
replace
6
7
6
7
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int ar[100000] = {0}; int n; cin >> n; for (int i = 1; i < n; i++) { int temp; cin >> temp; ++ar[temp]; } for (int i = 1; i <= n; i++) { printf("%d\n", ar[i]); } }
#include <bits/stdc++.h> using namespace std; int main() { int ar[1000000] = {0}; int n; cin >> n; for (int i = 1; i < n; i++) { int temp; cin >> temp; ++ar[temp]; } for (int i = 1; i <= n; i++) { printf("%d\n", ar[i]); } }
replace
4
5
4
5
0
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } using ll = long long; int n, m, a; string s, t; int ans[100005]; int main() { cin >> n; rep(i, n - 1) cin >> a, ans[a - 1]++; rep(i, n) cout << ans[i] << endl; }
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } using ll = long long; int n, m, a; string s, t; int ans[200005]; int main() { cin >> n; rep(i, n - 1) cin >> a, ans[a - 1]++; rep(i, n) cout << ans[i] << endl; }
replace
22
23
22
23
0
p02707
Python
Runtime Error
N = int(input()) A = list(map(int, input().split())) result = [0] * N for a in A: result[a - 1] += 1 print("\n".join(result))
N = int(input()) A = list(map(int, input().split())) result = [0] * N for a in A: result[a - 1] += 1 print("\n".join(map(str, result)))
replace
6
7
6
7
TypeError: sequence item 0: expected str instance, int found
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02707/Python/s320227284.py", line 7, in <module> print('\n'.join(result)) TypeError: sequence item 0: expected str instance, int found
p02707
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int mp[100200]; int s[100200]; int main() { int a, i; cin >> a; for (i = 2; i <= a; i++) { cin >> s[i]; mp[s[i]]++; } for (i = 1; i <= a; i++) { cout << mp[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int mp[1000200]; int s[1000200]; int main() { int a, i; cin >> a; for (i = 2; i <= a; i++) { cin >> s[i]; mp[s[i]]++; } for (i = 1; i <= a; i++) { cout << mp[i] << endl; } return 0; }
replace
2
4
2
4
0