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
p02686
C++
Runtime Error
#include <bits/stdc++.h> #define ss second #define ff first #define all(x) x.begin(), x.end() #define DEBUG using namespace std; using ll = long long; using pii = pair<ll, ll>; const int oo = 1e9 + 7; const ll mod = 998244353, maxn = 200200; const double PI = acos(-1); bool comp(pii a, pii b) { return a.ss > b.ss; } int main() { int n; string s; bool can = true; cin >> n; vector<pii> v1, v2; for (int i = 0; i < n; i++) { cin >> s; int tam = s.size(), a = 0, b = 0, q = 0; for (int j = 0; j < tam; j++) { if (s[i] == ')') { if (q > 0) q--; else a++; } else ++q; } b = q; if (a < b) v1.emplace_back(a, b); else v2.emplace_back(a, b); } sort(all(v1)); sort(all(v2), comp); int q = 0; for (auto x : v1) { q -= x.ff; if (q < 0) can = false; q += x.ss; } for (auto x : v2) { q -= x.ff; if (q < 0) can = false; q += x.ss; } if (q != 0) can = false; if (can) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <bits/stdc++.h> #define ss second #define ff first #define all(x) x.begin(), x.end() #define DEBUG using namespace std; using ll = long long; using pii = pair<ll, ll>; const int oo = 1e9 + 7; const ll mod = 998244353, maxn = 200200; const double PI = acos(-1); bool comp(pii a, pii b) { return a.ss > b.ss; } int main() { int n; string s; bool can = true; cin >> n; vector<pii> v1, v2; for (int i = 0; i < n; i++) { cin >> s; int tam = s.size(), a = 0, b = 0, q = 0; for (int j = 0; j < tam; j++) { if (s[j] == ')') { if (q > 0) q--; else a++; } else ++q; } b = q; if (a < b) v1.emplace_back(a, b); else v2.emplace_back(a, b); } sort(all(v1)); sort(all(v2), comp); int q = 0; for (auto x : v1) { q -= x.ff; if (q < 0) can = false; q += x.ss; } for (auto x : v2) { q -= x.ff; if (q < 0) can = false; q += x.ss; } if (q != 0) can = false; if (can) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
replace
29
30
29
30
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define time_taken_start int begtime = clock(); #define time_taken_end \ int endtime = clock(); \ cerr << "\n\n" \ << "Time elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC \ << " ms\n\n"; \ return 0; #define ll long long int #define ull unsigned long long int #define ld long double #define mod 998244353 #define inf 1000000000000000007 #define eps 0.0000000001 #define pi acosl(-1) #define pdd pair<ld, ld> #define pll pair<ll, ll> #define ff first #define ss second #define vpl vector<pll> #define vll vector<ll> #define mseti multiset<ll> #define msetd multiset<ll, greater<ll>> #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define stp fixed << setprecision(20) #define endl '\n' vpl v; bool comparion(pll a, pll b) { ll x = min(a.ss, a.ff + b.ss); ll y = min(b.ss, b.ff + a.ss); return (x >= y); } void solve() { ll n; cin >> n; string s; for (ll i = 0; i < n; i++) { cin >> s; ll d = 0, x = 0; for (ll j = 0; j < s.length(); j++) { if (s[j] == '(') x++; else x--; d = min(d, x); } v.pb({x, d}); } sort(v.begin(), v.end(), comparion); ll cnt = 0; for (auto i : v) { ll x = cnt + i.ss; if (x < 0) { cout << "No"; return; } cnt += i.ff; if (cnt < 0) { cout << "No"; return; } } if (cnt != 0) cout << "No"; else cout << "Yes"; } int main() { FAST #ifdef ayk_16 freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif time_taken_start ll t = 1; // cin>>t; for (ll i = 0; i < t; i++) { // cout<<"Case #"<<i+1<<": "; solve(); } time_taken_end }
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define time_taken_start int begtime = clock(); #define time_taken_end \ int endtime = clock(); \ cerr << "\n\n" \ << "Time elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC \ << " ms\n\n"; \ return 0; #define ll long long int #define ull unsigned long long int #define ld long double #define mod 998244353 #define inf 1000000000000000007 #define eps 0.0000000001 #define pi acosl(-1) #define pdd pair<ld, ld> #define pll pair<ll, ll> #define ff first #define ss second #define vpl vector<pll> #define vll vector<ll> #define mseti multiset<ll> #define msetd multiset<ll, greater<ll>> #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define stp fixed << setprecision(20) #define endl '\n' vpl v; bool comparion(pll a, pll b) { ll x = min(a.ss, a.ff + b.ss); ll y = min(b.ss, b.ff + a.ss); return (x > y); } void solve() { ll n; cin >> n; string s; for (ll i = 0; i < n; i++) { cin >> s; ll d = 0, x = 0; for (ll j = 0; j < s.length(); j++) { if (s[j] == '(') x++; else x--; d = min(d, x); } v.pb({x, d}); } sort(v.begin(), v.end(), comparion); ll cnt = 0; for (auto i : v) { ll x = cnt + i.ss; if (x < 0) { cout << "No"; return; } cnt += i.ff; if (cnt < 0) { cout << "No"; return; } } if (cnt != 0) cout << "No"; else cout << "Yes"; } int main() { FAST #ifdef ayk_16 freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif time_taken_start ll t = 1; // cin>>t; for (ll i = 0; i < t; i++) { // cout<<"Case #"<<i+1<<": "; solve(); } time_taken_end }
replace
37
38
37
38
0
Time elapsed: 0 ms
p02686
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; struct X { int y, z; int id, tp; } s[maxn]; int n; char t[maxn]; bool cmp(const X &a, const X &b) { if (a.tp != b.tp) return a.tp < b.tp; if (a.tp == 2) { if (a.y != b.y) return a.y < b.y; return a.z > b.z; } else if (a.tp == 3) { return a.z > b.z; } else { return 0; } } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", t); int z = 0, y = 0; for (int j = 0; t[j]; j++) { if (t[j] == '(') z++; else { if (z) z--; else y++; } } s[i].y = y; s[i].z = z; s[i].id = i; /* ))) y个 ((( z个 */ if (y + z == 0) s[i].tp = 0; else if (y == 0 && z != 0) s[i].tp = 1; else if (y != 0 && z == 0) s[i].tp = 4; else if (z - y >= 0) s[i].tp = 2; else s[i].tp = 3; } sort(s, s + n, cmp); int sum = 0; int fail = 0; for (int i = 0; i < n; i++) { sum = sum - s[i].y; if (sum < 0) { fail = 1; break; } sum = sum + s[i].z; } if (fail || sum != 0) { printf("No\n"); } else { printf("Yes\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; struct X { int y, z; int id, tp; } s[maxn]; int n; char t[maxn]; bool cmp(const X &a, const X &b) { if (a.tp != b.tp) return a.tp < b.tp; if (a.tp == 2) { if (a.y != b.y) return a.y < b.y; return a.z > b.z; } else if (a.tp == 3) { return a.z > b.z; } else { return 0; } } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", t); int z = 0, y = 0; for (int j = 0; t[j]; j++) { if (t[j] == '(') z++; else { if (z) z--; else y++; } } s[i].y = y; s[i].z = z; s[i].id = i; /* ))) y个 ((( z个 */ if (y + z == 0) s[i].tp = 0; else if (y == 0 && z != 0) s[i].tp = 1; else if (y != 0 && z == 0) s[i].tp = 4; else if (z - y >= 0) s[i].tp = 2; else s[i].tp = 3; } sort(s, s + n, cmp); int sum = 0; int fail = 0; for (int i = 0; i < n; i++) { sum = sum - s[i].y; if (sum < 0) { fail = 1; break; } sum = sum + s[i].z; } if (fail || sum != 0) { printf("No\n"); } else { printf("Yes\n"); } return 0; }
replace
3
4
3
4
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define sz(x) int(x.size()) using namespace std; const int maxn = 1100; string a[maxn]; int arr[maxn], n; vector<pair<int, int>> v; int main() { cin >> n; int minind = -1, maxind = -1; int minbal = INT_MAX, maxbal = INT_MIN; for (int i = 0; i < n; i++) { cin >> a[i]; int bal = 0; for (char j : a[i]) { if (j == '(') bal--; else bal++; } if (a[i][0] == '(' && bal < minbal) { minbal = bal; minind = i; } else if (a[i][sz(a[i]) - 1] == ')') { if (bal > maxbal) { maxbal = bal; maxind = i; } } } if (minind == -1 || maxind == -1) { cout << "No\n"; return 0; } arr[0] = minind; arr[n - 1] = maxind; for (int i = 0; i < n; i++) { if (i == minind || i == maxind) { continue; } int bal = 0; for (char j : a[i]) { if (j == '(') bal--; else bal++; } v.pb(mp(bal, i)); } sort(v.begin(), v.end()); for (int i = 0; i < n - 2; i++) { arr[i + 1] = v[i].second; } int bal = 0; for (int i = 0; i < n; i++) { for (char j : a[arr[i]]) { if (j == '(') bal--; else bal++; if (bal > 0) { cout << "No\n"; return 0; } } } if (bal != 0) { cout << "No\n"; } else { cout << "Yes\n"; } }
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define sz(x) int(x.size()) using namespace std; const int maxn = 1000100; string a[maxn]; int arr[maxn], n; vector<pair<int, int>> v; int main() { cin >> n; int minind = -1, maxind = -1; int minbal = INT_MAX, maxbal = INT_MIN; for (int i = 0; i < n; i++) { cin >> a[i]; int bal = 0; for (char j : a[i]) { if (j == '(') bal--; else bal++; } if (a[i][0] == '(' && bal < minbal) { minbal = bal; minind = i; } else if (a[i][sz(a[i]) - 1] == ')') { if (bal > maxbal) { maxbal = bal; maxind = i; } } } if (minind == -1 || maxind == -1) { cout << "No\n"; return 0; } arr[0] = minind; arr[n - 1] = maxind; for (int i = 0; i < n; i++) { if (i == minind || i == maxind) { continue; } int bal = 0; for (char j : a[i]) { if (j == '(') bal--; else bal++; } v.pb(mp(bal, i)); } sort(v.begin(), v.end()); for (int i = 0; i < n - 2; i++) { arr[i + 1] = v[i].second; } int bal = 0; for (int i = 0; i < n; i++) { for (char j : a[arr[i]]) { if (j == '(') bal--; else bal++; if (bal > 0) { cout << "No\n"; return 0; } } } if (bal != 0) { cout << "No\n"; } else { cout << "Yes\n"; } }
replace
6
7
6
7
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; struct num { int a; int b; bool operator<(const num &right) const { if (b - a >= 0) { if (right.b - right.a <= 0) return true; if (a == right.a) return b > right.b; return a < right.a; } if (right.b - right.a >= 0) return false; return b > right.b; } }; int main(void) { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) { cin >> S[i]; } // A, B vector<num> numV(N); for (int i = 0; i < N; i++) { string s = S[i]; int a = 0, b = 0; for (unsigned int j = 0; j < s.size(); j++) { if (s[j] == '(') b++; else { if (b == 0) a++; else b--; } } num n = {a, b}; numV[i] = n; } sort(numV.begin(), numV.end()); // check ll total_b = 0; for (int i = 0; i < N; i++) { total_b -= ll(numV[i].a); if (total_b < 0) { cout << "No" << endl; return 0; } total_b += ll(numV[i].b); } if (total_b == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; struct num { int a; int b; bool operator<(const num &right) const { if (b - a >= 0) { if (right.b - right.a < 0) return true; if (a == right.a) return b > right.b; return a < right.a; } if (right.b - right.a >= 0) return false; return b > right.b; } }; int main(void) { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) { cin >> S[i]; } // A, B vector<num> numV(N); for (int i = 0; i < N; i++) { string s = S[i]; int a = 0, b = 0; for (unsigned int j = 0; j < s.size(); j++) { if (s[j] == '(') b++; else { if (b == 0) a++; else b--; } } num n = {a, b}; numV[i] = n; } sort(numV.begin(), numV.end()); // check ll total_b = 0; for (int i = 0; i < N; i++) { total_b -= ll(numV[i].a); if (total_b < 0) { cout << "No" << endl; return 0; } total_b += ll(numV[i].b); } if (total_b == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
replace
10
11
10
11
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; #define fi first #define se second #define pb push_back #define mp make_pair int n; char a[N]; int l[N], r[N], cnt, vis[N], f[N]; char q[N]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { f[i] = i; cin >> a + 1; cnt = 0; int n = strlen(a + 1); for (int j = 1; j <= n; j++) { if (a[j] == '(') { q[++cnt] = '('; } else { if (q[cnt] == '(') --cnt; else q[++cnt] = ')'; } } for (int j = 1; j <= cnt; j++) { if (q[j] == '(') l[i]++; else r[i]++; } } int L = 0, R = 0; sort(f + 1, f + 1 + n, [](int x, int y) { if (!r[x] && !r[y]) return (int)(l[x] > l[y]); if (!l[x] && !l[y]) return (int)(r[x] < r[y]); if (l[x] >= r[x] && l[y] < r[y]) return 1; if (l[x] < r[x] && l[y] >= r[x]) return 0; if (l[x] >= r[x] && l[y] >= r[y]) return (int)(r[x] < r[y]); if (l[x] <= r[x] && l[y] <= r[y]) return (int)(l[x] > l[y]); }); for (int i = 1; i <= n; i++) { if (L < r[f[i]]) return cout << "No\n", 0; L -= r[f[i]]; L += l[f[i]]; } if (!L) cout << "Yes\n"; else cout << "No\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; #define fi first #define se second #define pb push_back #define mp make_pair int n; char a[N]; int l[N], r[N], cnt, vis[N], f[N]; char q[N]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { f[i] = i; cin >> a + 1; cnt = 0; int n = strlen(a + 1); for (int j = 1; j <= n; j++) { if (a[j] == '(') { q[++cnt] = '('; } else { if (q[cnt] == '(') --cnt; else q[++cnt] = ')'; } } for (int j = 1; j <= cnt; j++) { if (q[j] == '(') l[i]++; else r[i]++; } } int L = 0, R = 0; sort(f + 1, f + 1 + n, [](int x, int y) { if (!r[x] && !r[y]) return (int)(l[x] > l[y]); if (!l[x] && !l[y]) return (int)(r[x] < r[y]); if (l[x] >= r[x] && l[y] < r[y]) return 1; if (l[x] < r[x] && l[y] >= r[y]) return 0; if (l[x] >= r[x] && l[y] >= r[y]) return (int)(r[x] < r[y]); if (l[x] <= r[x] && l[y] <= r[y]) return (int)(l[x] > l[y]); }); for (int i = 1; i <= n; i++) { if (L < r[f[i]]) return cout << "No\n", 0; L -= r[f[i]]; L += l[f[i]]; } if (!L) cout << "Yes\n"; else cout << "No\n"; return 0; }
replace
46
47
46
47
0
p02686
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x.size()) #define pb push_back #define pii pair<int, int> #define print(x) \ for (auto it : x) \ cout << it << ' '; #define endl "\n" // TODO: remove #define int long long const int N = (int)(1e6) + 322; const int inf = (int)(2e9); const int mod = (int)(1e9) + 7; // check modulo pair<int, int> calc(string s) { int bal = 0; int mn = inf, mx = 0; for (auto i : s) { bal += (i == '(' ? 1 : -1); mn = min(mn, bal); } return {bal, mn}; } pair<int, int> bals[N]; string s[N]; void solve() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> s[i]; bals[i] = calc(s[i]); } sort(bals + 1, bals + n + 1, [&](pair<int, int> x, pair<int, int> y) { if ((x.first >= 0) != (y.second >= 0)) return (x.first >= 0); if (x.first >= 0) return x.second > y.second; return x.first + y.second > y.first + x.second; }); int bal = 0; for (int i = 1; i <= n; ++i) { if (bal + bals[i].second < 0) { cout << "No"; return; } bal += bals[i].first; } if (bal != 0) { cout << "No"; return; } cout << "Yes"; } signed main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); // freopen("elevator.in", "r", stdin); // freopen("elevator.out", "w", stdout); // int test; cin >> test; // for(int t = 1; t <= test; ++t) { solve(); // } return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x.size()) #define pb push_back #define pii pair<int, int> #define print(x) \ for (auto it : x) \ cout << it << ' '; #define endl "\n" // TODO: remove #define int long long const int N = (int)(1e6) + 322; const int inf = (int)(2e9); const int mod = (int)(1e9) + 7; // check modulo pair<int, int> calc(string s) { int bal = 0; int mn = inf, mx = 0; for (auto i : s) { bal += (i == '(' ? 1 : -1); mn = min(mn, bal); } return {bal, mn}; } pair<int, int> bals[N]; string s[N]; void solve() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> s[i]; bals[i] = calc(s[i]); } sort(bals + 1, bals + n + 1, [&](pair<int, int> x, pair<int, int> y) { if ((x.first >= 0) != (y.first >= 0)) return (x.first >= 0); if (x.first >= 0) return x.second > y.second; return x.first + y.second > y.first + x.second; }); int bal = 0; for (int i = 1; i <= n; ++i) { if (bal + bals[i].second < 0) { cout << "No"; return; } bal += bals[i].first; } if (bal != 0) { cout << "No"; return; } cout << "Yes"; } signed main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); // freopen("elevator.in", "r", stdin); // freopen("elevator.out", "w", stdout); // int test; cin >> test; // for(int t = 1; t <= test; ++t) { solve(); // } return 0; }
replace
67
68
67
68
0
p02686
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; string S[100000]; bool balanced(string s) { int opened = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') { opened++; } else if (s[i] == ')') { if (opened == 0) { return false; } opened--; } } if (opened != 0) { return false; } return true; } int right_open(string s) { int opened = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') { opened++; } else if (s[i] == ')') { if (opened > 0) { opened--; } } } return opened; } int left_open(string s) { int opened = 0; for (int i = s.size() - 1; i >= 0; i--) { if (s[i] == ')') { opened++; } else if (s[i] == '(') { if (opened > 0) { opened--; } } } return opened; } int main() { int N; cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; } vector<int> right_opens; vector<int> left_opens; vector<pair<int, int>> both_opens_pos; vector<pair<int, int>> both_opens_neg; for (int i = 0; i < N; i++) { int right = right_open(S[i]); int left = left_open(S[i]); if (right == 0 && left == 0) { continue; } if (left == 0) { right_opens.push_back(right); } else if (right == 0) { left_opens.push_back(left); } else { if (right - left >= 0) { both_opens_pos.push_back(make_pair(left, right)); } else { both_opens_neg.push_back(make_pair(left, right)); } } } sort(both_opens_pos.begin(), both_opens_pos.end()); sort(both_opens_neg.begin(), both_opens_neg.end()); reverse(both_opens_neg.begin(), both_opens_neg.end()); int cur_opens = 0; for (int i = 0; i < right_opens.size(); i++) { cur_opens += right_opens[i]; } for (int i = 0; i < both_opens_pos.size(); i++) { cur_opens -= both_opens_pos[i].first; if (cur_opens < 0) { cout << "No" << endl; return 0; } cur_opens += both_opens_pos[i].second; } for (int i = 0; i < both_opens_neg.size(); i++) { cur_opens -= both_opens_neg[i].first; if (cur_opens < 0) { cout << "No" << endl; return 0; } cur_opens += both_opens_neg[i].second; } for (int i = 0; i < left_opens.size(); i++) { cur_opens -= left_opens[i]; } if (cur_opens != 0) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; string S[1000000]; bool balanced(string s) { int opened = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') { opened++; } else if (s[i] == ')') { if (opened == 0) { return false; } opened--; } } if (opened != 0) { return false; } return true; } int right_open(string s) { int opened = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') { opened++; } else if (s[i] == ')') { if (opened > 0) { opened--; } } } return opened; } int left_open(string s) { int opened = 0; for (int i = s.size() - 1; i >= 0; i--) { if (s[i] == ')') { opened++; } else if (s[i] == '(') { if (opened > 0) { opened--; } } } return opened; } int main() { int N; cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; } vector<int> right_opens; vector<int> left_opens; vector<pair<int, int>> both_opens_pos; vector<pair<int, int>> both_opens_neg; for (int i = 0; i < N; i++) { int right = right_open(S[i]); int left = left_open(S[i]); if (right == 0 && left == 0) { continue; } if (left == 0) { right_opens.push_back(right); } else if (right == 0) { left_opens.push_back(left); } else { if (right - left >= 0) { both_opens_pos.push_back(make_pair(left, right)); } else { both_opens_neg.push_back(make_pair(left, right)); } } } sort(both_opens_pos.begin(), both_opens_pos.end()); sort(both_opens_neg.begin(), both_opens_neg.end()); reverse(both_opens_neg.begin(), both_opens_neg.end()); int cur_opens = 0; for (int i = 0; i < right_opens.size(); i++) { cur_opens += right_opens[i]; } for (int i = 0; i < both_opens_pos.size(); i++) { cur_opens -= both_opens_pos[i].first; if (cur_opens < 0) { cout << "No" << endl; return 0; } cur_opens += both_opens_pos[i].second; } for (int i = 0; i < both_opens_neg.size(); i++) { cur_opens -= both_opens_neg[i].first; if (cur_opens < 0) { cout << "No" << endl; return 0; } cur_opens += both_opens_neg[i].second; } for (int i = 0; i < left_opens.size(); i++) { cur_opens -= left_opens[i]; } if (cur_opens != 0) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }
replace
15
16
15
16
0
p02686
C++
Runtime Error
#include <iostream> #include <set> #include <string> #include <utility> using namespace std; string s[200010]; int a[200010], b[200100]; multiset<pair<int, int>> s1, s2, s3; int main() { int i, j, n; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; int cnt = 0; b[i] = 0; for (j = 0; j < s[i].size(); j++) { if (s[i][j] == '(') cnt++; else cnt--; b[i] = min(b[i], cnt); } a[i] = cnt; } int sum = 0; for (i = 0; i < n; i++) { sum += a[i]; } if (sum != 0) { cout << "No" << endl; return 0; } for (i = 0; i < n; i++) { if (a[i] >= 0) { s1.insert({-b[i], a[i]}); } if (a[i] == 0) { s2.insert({b[i], a[i]}); } if (a[i] < 0) { s3.insert({-(b[i] - a[i]), -a[i]}); } } sum = 0; while (s1.size()) { auto it = s1.begin(); pair<int, int> p = *it; if (sum - p.first < 0) { cout << "No" << endl; return 0; } s1.erase(it); sum += p.second; } while (s2.size()) { auto it = s2.begin(); pair<int, int> p = *it; if (sum + p.first < 0) { cout << "No" << endl; return 0; } s2.erase(it); } sum = 0; while (s3.size()) { auto it = s3.begin(); pair<int, int> p = *it; if (sum - p.first < 0) { cout << "No" << endl; return 0; } s3.erase(it); sum += p.second; } cout << "Yes" << endl; }
#include <iostream> #include <set> #include <string> #include <utility> using namespace std; string s[1000010]; int a[1000010], b[1000100]; multiset<pair<int, int>> s1, s2, s3; int main() { int i, j, n; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; int cnt = 0; b[i] = 0; for (j = 0; j < s[i].size(); j++) { if (s[i][j] == '(') cnt++; else cnt--; b[i] = min(b[i], cnt); } a[i] = cnt; } int sum = 0; for (i = 0; i < n; i++) { sum += a[i]; } if (sum != 0) { cout << "No" << endl; return 0; } for (i = 0; i < n; i++) { if (a[i] >= 0) { s1.insert({-b[i], a[i]}); } if (a[i] == 0) { s2.insert({b[i], a[i]}); } if (a[i] < 0) { s3.insert({-(b[i] - a[i]), -a[i]}); } } sum = 0; while (s1.size()) { auto it = s1.begin(); pair<int, int> p = *it; if (sum - p.first < 0) { cout << "No" << endl; return 0; } s1.erase(it); sum += p.second; } while (s2.size()) { auto it = s2.begin(); pair<int, int> p = *it; if (sum + p.first < 0) { cout << "No" << endl; return 0; } s2.erase(it); } sum = 0; while (s3.size()) { auto it = s3.begin(); pair<int, int> p = *it; if (sum - p.first < 0) { cout << "No" << endl; return 0; } s3.erase(it); sum += p.second; } cout << "Yes" << endl; }
replace
5
7
5
7
0
p02686
C++
Runtime Error
#include <algorithm> #include <cstdio> #define maxn 1000010 using namespace std; char s[maxn]; struct node { int l, r; } a[maxn]; int tot; int cmp(node a, node b) { a.l - a.r > b.l - b.r; } int main() { int n, i, j, l, r, ln, rn; ln = rn = 0; scanf("%d", &n); for (i = 1; i <= n; i++) { l = r = 0; scanf("%s", s + 1); for (j = 1; s[j]; j++) { if (s[j] == '(') l++; else if (s[j] == ')') { if (l) l--; else r++; } } if (l && !r) ln += l; else if (!l && r) rn += r; else if (l && r) a[++tot] = (node){l, r}; } sort(a + 1, a + 1 + tot, cmp); for (i = 1; i <= tot; i++) { if (ln < a[i].r) return printf("No\n") * 0; ln -= a[i].r, ln += a[i].l; } if (ln != rn) return printf("No\n") * 0; printf("Yes\n"); return 0; }
#include <algorithm> #include <cstdio> #define maxn 1000010 using namespace std; char s[maxn]; struct node { int l, r; } a[maxn]; int tot; int cmp(node a, node b) { return a.l - a.r > b.l - b.r; } int main() { int n, i, j, l, r, ln, rn; ln = rn = 0; scanf("%d", &n); for (i = 1; i <= n; i++) { l = r = 0; scanf("%s", s + 1); for (j = 1; s[j]; j++) { if (s[j] == '(') l++; else if (s[j] == ')') { if (l) l--; else r++; } } if (l && !r) ln += l; else if (!l && r) rn += r; else if (l && r) a[++tot] = (node){l, r}; } sort(a + 1, a + 1 + tot, cmp); for (i = 1; i <= tot; i++) { if (ln < a[i].r) return printf("No\n") * 0; ln -= a[i].r, ln += a[i].l; } if (ln != rn) return printf("No\n") * 0; printf("Yes\n"); return 0; }
replace
9
10
9
10
0
p02686
C++
Runtime Error
#include "bits/stdc++.h" #define hhh cerr << "hhh" << endl #define see(x) cerr << (#x) << '=' << (x) << endl using namespace std; typedef long long ll; typedef pair<int, int> pr; inline int read() { int x = 0, f = 1; char c = getchar(); while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') f = -1, c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return f * x; } const int maxn = 1e6 + 7; const int inf = 0x3f3f3f3f; const int mod = 998244353; string s[maxn]; vector<pr> v1; struct P { int first, second; P(int f = 0, int s = 0) : first(f), second(s) {} bool operator<(const P &rhs) const { return second + first >= rhs.second + rhs.first; } }; vector<P> v2; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int tot = 0; int c1 = 0, c2 = 0; for (int i = 1; i <= n; ++i) { cin >> s[i]; int tmp = 0, mi = inf; for (int j = 0; j < s[i].size(); ++j) { tot += (s[i][j] == '(' ? 1 : -1); tmp += (s[i][j] == '(' ? 1 : -1); mi = min(mi, tmp); } if (mi >= 0) c1 += tmp; else { if (tmp >= 0) v1.push_back(pr(-mi, tmp)); else v2.push_back(P(-mi, tmp)); } } if (tot != 0) return (cout << "No" << endl), 0; sort(v1.begin(), v1.end()); for (int i = 0; i < v1.size(); ++i) { if (c1 >= v1[i].first) { c1 += v1[i].second; } else return (cout << "No" << endl), 0; } sort(v2.begin(), v2.end()); for (int i = 0; i < v2.size(); ++i) { if (c1 >= v2[i].first) { c1 += v2[i].second; } else return (cout << "No" << endl), 0; } assert(c1 == 0); cout << "Yes" << endl; }
#include "bits/stdc++.h" #define hhh cerr << "hhh" << endl #define see(x) cerr << (#x) << '=' << (x) << endl using namespace std; typedef long long ll; typedef pair<int, int> pr; inline int read() { int x = 0, f = 1; char c = getchar(); while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') f = -1, c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return f * x; } const int maxn = 1e6 + 7; const int inf = 0x3f3f3f3f; const int mod = 998244353; string s[maxn]; vector<pr> v1; struct P { int first, second; P(int f = 0, int s = 0) : first(f), second(s) {} bool operator<(const P &rhs) const { return second + first > rhs.second + rhs.first; } }; vector<P> v2; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int tot = 0; int c1 = 0, c2 = 0; for (int i = 1; i <= n; ++i) { cin >> s[i]; int tmp = 0, mi = inf; for (int j = 0; j < s[i].size(); ++j) { tot += (s[i][j] == '(' ? 1 : -1); tmp += (s[i][j] == '(' ? 1 : -1); mi = min(mi, tmp); } if (mi >= 0) c1 += tmp; else { if (tmp >= 0) v1.push_back(pr(-mi, tmp)); else v2.push_back(P(-mi, tmp)); } } if (tot != 0) return (cout << "No" << endl), 0; sort(v1.begin(), v1.end()); for (int i = 0; i < v1.size(); ++i) { if (c1 >= v1[i].first) { c1 += v1[i].second; } else return (cout << "No" << endl), 0; } sort(v2.begin(), v2.end()); for (int i = 0; i < v2.size(); ++i) { if (c1 >= v2[i].first) { c1 += v2[i].second; } else return (cout << "No" << endl), 0; } assert(c1 == 0); cout << "Yes" << endl; }
replace
30
31
30
31
0
p02686
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; unsigned euclidean_gcd(unsigned a, unsigned b) { if (a < b) return euclidean_gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll ll_gcd(ll a, ll b) { if (a < b) return ll_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } class UnionFind { public: vector<ll> par; vector<ll> siz; UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; 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; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } vector<int> tpsort(vector<vector<int>> &G) { int V = G.size(); vector<int> sorted_vertices; queue<int> que; vector<int> indegree(V); for (int i = 0; i < V; i++) { for (int j = 0; j < G[i].size(); j++) { indegree[G[i][j]]++; } } for (int i = 0; i < V; i++) { if (indegree[i] == 0) { que.push(i); } } while (que.empty() == false) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { int u = G[v][i]; indegree[u] -= 1; if (indegree[u] == 0) que.push(u); } sorted_vertices.push_back(v); } return sorted_vertices; } struct Point { double x; double y; }; struct LineSegment { Point start; Point end; }; double tenkyori(const LineSegment &line, const Point &point) { double x0 = point.x, y0 = point.y; double x1 = line.start.x, y1 = line.start.y; double x2 = line.end.x, y2 = line.end.y; double a = x2 - x1; double b = y2 - y1; double a2 = a * a; double b2 = b * b; double r2 = a2 + b2; double tt = -(a * (x1 - x0) + b * (y1 - y0)); if (tt < 0) return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); else if (tt > r2) return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0)); double f1 = a * (y1 - y0) - b * (x1 - x0); return sqrt((f1 * f1) / r2); } int main() { ll n; cin >> n; vector<pair<ll, ll>> pl; vector<pair<ll, ll>> mn; ll t = 0; string ans = "Yes"; for (int i = 0; i < n; i++) { string s; cin >> s; ll zan = 0; ll zzan = 0; ll czan = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') zan++; else zan--; zzan = min(zan, zzan); czan = min(-zan, czan); } t += zan; if (zan < 0) { zan = 0; zzan = 0; for (int i = n - 1; i > -1; i--) { if (s[i] == ')') zan++; else zan--; zzan = min(zan, zzan); czan = min(-zan, czan); } mn.push_back(make_pair(-zzan, zan)); } else pl.push_back(make_pair(-zzan, zan)); } if (t != 0) ans = "No"; ll zat = 0; sort(mn.begin(), mn.end()); sort(pl.begin(), pl.end()); for (int i = 0; i < pl.size(); i++) { if (zat < pl[i].first) { ans = "No"; break; } zat += pl[i].second; } zat = 0; for (int i = 0; i < mn.size(); i++) { if (zat < mn[i].first) { ans = "No"; break; } zat += mn[i].second; } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; unsigned euclidean_gcd(unsigned a, unsigned b) { if (a < b) return euclidean_gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll ll_gcd(ll a, ll b) { if (a < b) return ll_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } class UnionFind { public: vector<ll> par; vector<ll> siz; UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; 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; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } vector<int> tpsort(vector<vector<int>> &G) { int V = G.size(); vector<int> sorted_vertices; queue<int> que; vector<int> indegree(V); for (int i = 0; i < V; i++) { for (int j = 0; j < G[i].size(); j++) { indegree[G[i][j]]++; } } for (int i = 0; i < V; i++) { if (indegree[i] == 0) { que.push(i); } } while (que.empty() == false) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { int u = G[v][i]; indegree[u] -= 1; if (indegree[u] == 0) que.push(u); } sorted_vertices.push_back(v); } return sorted_vertices; } struct Point { double x; double y; }; struct LineSegment { Point start; Point end; }; double tenkyori(const LineSegment &line, const Point &point) { double x0 = point.x, y0 = point.y; double x1 = line.start.x, y1 = line.start.y; double x2 = line.end.x, y2 = line.end.y; double a = x2 - x1; double b = y2 - y1; double a2 = a * a; double b2 = b * b; double r2 = a2 + b2; double tt = -(a * (x1 - x0) + b * (y1 - y0)); if (tt < 0) return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); else if (tt > r2) return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0)); double f1 = a * (y1 - y0) - b * (x1 - x0); return sqrt((f1 * f1) / r2); } int main() { ll n; cin >> n; vector<pair<ll, ll>> pl; vector<pair<ll, ll>> mn; ll t = 0; string ans = "Yes"; for (int i = 0; i < n; i++) { string s; cin >> s; ll zan = 0; ll zzan = 0; ll czan = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') zan++; else zan--; zzan = min(zan, zzan); czan = min(-zan, czan); } t += zan; if (zan < 0) { zan = 0; zzan = 0; for (int i = s.size() - 1; i > -1; i--) { if (s[i] == ')') zan++; else zan--; zzan = min(zan, zzan); czan = min(-zan, czan); } mn.push_back(make_pair(-zzan, zan)); } else pl.push_back(make_pair(-zzan, zan)); } if (t != 0) ans = "No"; ll zat = 0; sort(mn.begin(), mn.end()); sort(pl.begin(), pl.end()); for (int i = 0; i < pl.size(); i++) { if (zat < pl[i].first) { ans = "No"; break; } zat += pl[i].second; } zat = 0; for (int i = 0; i < mn.size(); i++) { if (zat < mn[i].first) { ans = "No"; break; } zat += mn[i].second; } cout << ans << endl; }
replace
186
187
186
187
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct node { int l, r, i; bool operator<(const node &x) const { if ((l >= r) == (x.l >= x.r)) { if ((l >= r)) return r < x.r; return l > x.l; } return l - r > x.l - x.r; } } arr[200007], brr[200007]; int main() { int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; int l = 0, r = 0; for (int j = 0; j < (int)s.length(); j++) { if (s[j] == '(') l++; else if (l) l--; else r++; } arr[i] = {l, r, i}; brr[i] = {r, l, i}; } sort(arr, arr + n); sort(brr, brr + n); int ll = 0; for (int i = 0; i < n; i++) { if (ll < arr[i].r) { cout << "No" << endl; return 0; } else ll += arr[i].l - arr[i].r; } if (ll == 0) { cout << "Yes" << endl; /* for(int i=0; i<n; i++) cout<<arr[i].i+1<<' '; cout<<endl;*/ } else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct node { int l, r, i; bool operator<(const node &x) const { if ((l >= r) == (x.l >= x.r)) { if ((l >= r)) return r < x.r; return l > x.l; } return l - r > x.l - x.r; } } arr[2000007], brr[2000007]; int main() { int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; int l = 0, r = 0; for (int j = 0; j < (int)s.length(); j++) { if (s[j] == '(') l++; else if (l) l--; else r++; } arr[i] = {l, r, i}; brr[i] = {r, l, i}; } sort(arr, arr + n); sort(brr, brr + n); int ll = 0; for (int i = 0; i < n; i++) { if (ll < arr[i].r) { cout << "No" << endl; return 0; } else ll += arr[i].l - arr[i].r; } if (ll == 0) { cout << "Yes" << endl; /* for(int i=0; i<n; i++) cout<<arr[i].i+1<<' '; cout<<endl;*/ } else cout << "No" << endl; return 0; }
replace
12
13
12
13
0
p02686
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main(int argc, char **argv) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<string> S(n); int N = 0; for (int i = 0; i < n; ++i) { cin >> S[i]; N = max(N, (int)S[i].length()); } vector<vector<int>> T(N + 1); vector<int> reqs(n, 0); vector<int> chgs(n, 0); for (int i = 0; i < n; ++i) { int bal = 0; auto &s = S[i]; int m = s.length(); for (int j = 0; j < m; ++j) { bal += s[j] == '(' ? 1 : -1; reqs[i] = max(reqs[i], -bal); } chgs[i] = bal; T[reqs[i]].push_back(i); } string res; int BAL = 0; int cnt = 0; for (int i = 0; i <= BAL; ++i) { for (auto x : T[i]) { if (chgs[x] >= 0) { BAL += chgs[x]; res += S[x]; ++cnt; } } } priority_queue<pair<int, int>> pq; for (int i = 0; i < n; ++i) { if (chgs[i] < 0) { pq.emplace(reqs[i] + chgs[i], i); } } while (!pq.empty()) { int x = pq.top().second; if (BAL < reqs[x]) { break; } pq.pop(); BAL += chgs[x]; res += S[x]; ++cnt; } if (cnt == n && BAL == 0) { cout << "Yes\n"; } else { cout << "No\n"; } return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main(int argc, char **argv) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<string> S(n); int N = 0; for (int i = 0; i < n; ++i) { cin >> S[i]; N = max(N, (int)S[i].length()); } vector<vector<int>> T(N + 1); vector<int> reqs(n, 0); vector<int> chgs(n, 0); for (int i = 0; i < n; ++i) { int bal = 0; auto &s = S[i]; int m = s.length(); for (int j = 0; j < m; ++j) { bal += s[j] == '(' ? 1 : -1; reqs[i] = max(reqs[i], -bal); } chgs[i] = bal; T[reqs[i]].push_back(i); } string res; int BAL = 0; int cnt = 0; for (int i = 0; i <= BAL && i <= N; ++i) { for (auto x : T[i]) { if (chgs[x] >= 0) { BAL += chgs[x]; res += S[x]; ++cnt; } } } priority_queue<pair<int, int>> pq; for (int i = 0; i < n; ++i) { if (chgs[i] < 0) { pq.emplace(reqs[i] + chgs[i], i); } } while (!pq.empty()) { int x = pq.top().second; if (BAL < reqs[x]) { break; } pq.pop(); BAL += chgs[x]; res += S[x]; ++cnt; } if (cnt == n && BAL == 0) { cout << "Yes\n"; } else { cout << "No\n"; } return 0; }
replace
58
59
58
59
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = (m); i < (int)(n); i++) #define RREP(i, m, n) for (int i = (int)(n - 1); i >= m; i--) #define rep(i, n) REP(i, 0, n) #define rrep(i, n) RREP(i, 0, n) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define fi first #define se second #define debug(...) \ { \ cerr << "[L" << __LINE__ << "] "; \ _debug(__VA_ARGS__); \ } template <typename T1, typename T2> ostream &operator<<(ostream &o, const pair<T1, T2> &p) { return o << "(" << p.first << ", " << p.second << ")"; } template <typename T> string join(const vector<T> &v, string del = ", ") { stringstream s; for (auto x : v) s << del << x; return s.str().substr(del.size()); } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if (v.size()) o << "[" << join(v) << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const vector<vector<T>> &vv) { int l = vv.size(); if (l) { o << endl; rep(i, l) o << (i == 0 ? "[ " : ",\n ") << vv[i] << (i == l - 1 ? " ]" : ""); } return o; } inline void _debug() { cerr << endl; } template <class First, class... Rest> void _debug(const First &first, const Rest &...rest) { cerr << first << " "; _debug(rest...); } typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; const double PI = (1 * acos(0.0)); const double EPS = 1e-9; const int INF = 0x3f3f3f3f; const ll INFL = 0x3f3f3f3f3f3f3f3fLL; const ll mod = 1e9 + 7; inline void finput(string filename) { freopen(filename.c_str(), "r", stdin); } int main() { ios_base::sync_with_stdio(0); // finput("./input"); int n; cin >> n; vector<string> ss(n); rep(i, n) cin >> ss[i]; vector<pii> va; vector<pii> vb; rep(i, n) { string s = ss[i]; int cnt = 0; int mi = 0; rep(j, s.size()) { if (s[j] == '(') cnt++; else cnt--; mi = min(mi, cnt); } if (cnt >= 0) va.emplace_back(-mi, cnt); else vb.emplace_back(-mi, cnt); } sort(all(va)); sort(all(vb), [&](pii a, pii b) { return a.fi + a.se > b.fi + b.se; }); int cnt = 0; auto count = [&](vector<pii> &v) { for (auto p : v) { string s = ss[p.se]; rep(j, s.size()) { if (s[j] == '(') cnt++; else cnt--; if (cnt < 0) return false; } } return true; }; bool can = count(va) && count(vb); if (can & cnt == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = (m); i < (int)(n); i++) #define RREP(i, m, n) for (int i = (int)(n - 1); i >= m; i--) #define rep(i, n) REP(i, 0, n) #define rrep(i, n) RREP(i, 0, n) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define fi first #define se second #define debug(...) \ { \ cerr << "[L" << __LINE__ << "] "; \ _debug(__VA_ARGS__); \ } template <typename T1, typename T2> ostream &operator<<(ostream &o, const pair<T1, T2> &p) { return o << "(" << p.first << ", " << p.second << ")"; } template <typename T> string join(const vector<T> &v, string del = ", ") { stringstream s; for (auto x : v) s << del << x; return s.str().substr(del.size()); } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if (v.size()) o << "[" << join(v) << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const vector<vector<T>> &vv) { int l = vv.size(); if (l) { o << endl; rep(i, l) o << (i == 0 ? "[ " : ",\n ") << vv[i] << (i == l - 1 ? " ]" : ""); } return o; } inline void _debug() { cerr << endl; } template <class First, class... Rest> void _debug(const First &first, const Rest &...rest) { cerr << first << " "; _debug(rest...); } typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; const double PI = (1 * acos(0.0)); const double EPS = 1e-9; const int INF = 0x3f3f3f3f; const ll INFL = 0x3f3f3f3f3f3f3f3fLL; const ll mod = 1e9 + 7; inline void finput(string filename) { freopen(filename.c_str(), "r", stdin); } int main() { ios_base::sync_with_stdio(0); // finput("./input"); int n; cin >> n; vector<string> ss(n); rep(i, n) cin >> ss[i]; vector<pii> va; vector<pii> vb; rep(i, n) { string s = ss[i]; int cnt = 0; int mi = 0; rep(j, s.size()) { if (s[j] == '(') cnt++; else cnt--; mi = min(mi, cnt); } if (cnt >= 0) va.emplace_back(-mi, cnt); else vb.emplace_back(-mi, cnt); } sort(all(va)); sort(all(vb), [&](pii a, pii b) { return a.fi + a.se > b.fi + b.se; }); int cnt = 0; auto count = [&](vector<pii> &v) { for (auto p : v) { if (p.fi > cnt) return false; cnt += p.se; } return true; }; bool can = count(va) && count(vb); if (can & cnt == 0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
replace
95
104
95
98
0
p02686
C++
Runtime Error
#include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int MAXN = 1e6 + 7; const int INF = 1e9; vector<pii> vec; char s[MAXN]; stack<char> stk; int N, a[MAXN], v[MAXN]; #define lson (rt << 1) #define rson (rt << 1 | 1) struct node { int val, pos; } T[MAXN << 2]; node merge(node &x, node &y) { if (x.val > y.val) return x; else return y; } void pushup(int rt) { T[rt] = merge(T[lson], T[rson]); } void build(int rt, int l, int r) { if (l == r) { T[rt] = {v[l], l}; return; } int mid = (l + r) >> 1; build(lson, l, mid); build(rson, mid + 1, r); pushup(rt); } void update(int rt, int l, int r, int pos, int v) { if (l == r) { T[rt] = {v, l}; return; } int mid = (l + r) >> 1; if (pos <= mid) update(lson, l, mid, pos, v); else update(rson, mid + 1, r, pos, v); pushup(rt); } node query(int rt, int l, int r, int L, int R) { if (L <= l && r <= R) return T[rt]; int mid = (l + r) >> 1; node resl = {-INF, -1}, resr = {-INF, -1}; if (L <= mid) resl = query(lson, l, mid, L, R); if (mid < R) resr = query(rson, mid + 1, r, L, R); return merge(resl, resr); } int main() { int n; scanf("%d", &n); int sum1 = 0, sum2 = 0; for (int k = 1; k <= n; k++) { scanf(" %s", s); int len = strlen(s); for (int i = 0; i < len; i++) { if (s[i] == '(') stk.push(s[i]); else { if (stk.size() && stk.top() == '(') stk.pop(); else stk.push(s[i]); } } pii item = {0, 0}; while (stk.size()) { if (stk.top() == '(') item.second++; else item.first++; stk.pop(); } if (item.first == 0) sum1 += item.second; else if (item.second == 0) sum2 += item.first; else vec.push_back(item); } sort(vec.begin(), vec.end()); N = vec.size(); for (int i = 1; i <= N; i++) { a[i] = vec[i - 1].first; v[i] = vec[i - 1].second - vec[i - 1].first; } if (N > 0) build(1, 1, N); for (int i = 1; i <= N; i++) { int p = upper_bound(a + 1, a + 1 + N, sum1) - a - 1; node res = query(1, 1, N, 1, p); if (res.pos == -1 || sum1 < a[res.pos]) { puts("No"); return 0; } sum1 += v[res.pos]; update(1, 1, N, res.pos, -INF); } sum1 == sum2 ? puts("Yes") : puts("No"); return 0; }
#include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int MAXN = 1e6 + 7; const int INF = 1e9; vector<pii> vec; char s[MAXN]; stack<char> stk; int N, a[MAXN], v[MAXN]; #define lson (rt << 1) #define rson (rt << 1 | 1) struct node { int val, pos; } T[MAXN << 2]; node merge(node &x, node &y) { if (x.val > y.val) return x; else return y; } void pushup(int rt) { T[rt] = merge(T[lson], T[rson]); } void build(int rt, int l, int r) { if (l == r) { T[rt] = {v[l], l}; return; } int mid = (l + r) >> 1; build(lson, l, mid); build(rson, mid + 1, r); pushup(rt); } void update(int rt, int l, int r, int pos, int v) { if (l == r) { T[rt] = {v, l}; return; } int mid = (l + r) >> 1; if (pos <= mid) update(lson, l, mid, pos, v); else update(rson, mid + 1, r, pos, v); pushup(rt); } node query(int rt, int l, int r, int L, int R) { if (L <= l && r <= R) return T[rt]; int mid = (l + r) >> 1; node resl = {-INF, -1}, resr = {-INF, -1}; if (L <= mid) resl = query(lson, l, mid, L, R); if (mid < R) resr = query(rson, mid + 1, r, L, R); return merge(resl, resr); } int main() { int n; scanf("%d", &n); int sum1 = 0, sum2 = 0; for (int k = 1; k <= n; k++) { scanf(" %s", s); int len = strlen(s); for (int i = 0; i < len; i++) { if (s[i] == '(') stk.push(s[i]); else { if (stk.size() && stk.top() == '(') stk.pop(); else stk.push(s[i]); } } pii item = {0, 0}; while (stk.size()) { if (stk.top() == '(') item.second++; else item.first++; stk.pop(); } if (item.first == 0) sum1 += item.second; else if (item.second == 0) sum2 += item.first; else vec.push_back(item); } sort(vec.begin(), vec.end()); N = vec.size(); for (int i = 1; i <= N; i++) { a[i] = vec[i - 1].first; v[i] = vec[i - 1].second - vec[i - 1].first; } if (N > 0) build(1, 1, N); for (int i = 1; i <= N; i++) { int p = upper_bound(a + 1, a + 1 + N, sum1) - a - 1; if (p < 1) { puts("No"); return 0; } node res = query(1, 1, N, 1, p); if (res.pos == -1 || sum1 < a[res.pos]) { puts("No"); return 0; } sum1 += v[res.pos]; update(1, 1, N, res.pos, -INF); } sum1 == sum2 ? puts("Yes") : puts("No"); return 0; }
insert
98
98
98
102
0
p02686
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; string shorten(const string &s) { string res; for (const char i : s) { if (res.back() == '(' && i == ')') res.pop_back(); else res.push_back(i); } return res; } struct brace { int left; int right; brace operator+(const brace &other) { int facing = min(this->right, other.left); return brace{this->left + other.left - facing, this->right - facing + other.right}; } }; bool operator<(const brace a, const brace b) { return a.right > b.right; } brace toBrace(const string &s) { brace res = brace{0, 0}; for (char i : s) (i == ')' ? res.left : res.right)++; return res; } int main() { int n; cin >> n; vector<brace> s; for (int i = 0; i < n; ++i) { string S; cin >> S; S = shorten(S); if (S != "") s.push_back(toBrace(S)); } brace rightOpen{0, 0}; brace leftOpen{0, 0}; vector<brace> bothOpen; for (const auto &i : s) { if (i.left == 0) rightOpen.right += i.right; else if (i.right == 0) leftOpen.left += i.left; else bothOpen.push_back(i); } sort(bothOpen.begin(), bothOpen.end()); int cnt = 0; for (int i = 0; i < bothOpen.size(); ++i) { for (auto &j : bothOpen) { if (j.left <= rightOpen.right) { rightOpen = rightOpen + j; j.left = 1145141919; cnt++; break; } } } rightOpen = rightOpen + leftOpen; puts(cnt == bothOpen.size() && rightOpen.left == 0 && rightOpen.right == 0 ? "Yes" : "No"); }
#include <algorithm> #include <iostream> #include <vector> using namespace std; string shorten(const string &s) { string res; for (const char i : s) { if (res.back() == '(' && i == ')') res.pop_back(); else res.push_back(i); } return res; } struct brace { int left; int right; brace operator+(const brace &other) { int facing = min(this->right, other.left); return brace{this->left + other.left - facing, this->right - facing + other.right}; } }; bool operator<(const brace a, const brace b) { return a.right > b.right; } brace toBrace(const string &s) { brace res = brace{0, 0}; for (char i : s) (i == ')' ? res.left : res.right)++; return res; } int main() { int n; cin >> n; vector<brace> s; for (int i = 0; i < n; ++i) { string S; cin >> S; S = shorten(S); if (S != "") s.push_back(toBrace(S)); } brace rightOpen{0, 0}; brace leftOpen{0, 0}; vector<brace> bothOpen; for (const auto &i : s) { if (i.left == 0) rightOpen.right += i.right; else if (i.right == 0) leftOpen.left += i.left; else bothOpen.push_back(i); } sort(bothOpen.begin(), bothOpen.end()); int cnt = 0; for (int i = 0; i < bothOpen.size(); ++i) { if (cnt < i) break; for (auto &j : bothOpen) { if (j.left <= rightOpen.right) { rightOpen = rightOpen + j; j.left = 1145141919; cnt++; break; } } } rightOpen = rightOpen + leftOpen; puts(cnt == bothOpen.size() && rightOpen.left == 0 && rightOpen.right == 0 ? "Yes" : "No"); }
insert
62
62
62
64
TLE
p02686
C++
Runtime Error
#include <bits/stdc++.h> #define ln '\n' #define all(dat) dat.begin(), dat.end() #define loop(i, to) for (int i = 0; i < to; ++i) #define cont(i, to) for (int i = 1; i <= to; ++i) #define circ(i, fm, to) for (int i = fm; i <= to; ++i) #define foreach(i, dat) \ for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i) typedef long long num; using namespace std; const int nsz = int(1e3); int n, sum, pre[nsz + 5], mn[nsz + 5]; pair<int, int> dat[nsz + 5]; string s[nsz + 5]; bool inline cmp(pair<int, int> a, pair<int, int> b) { if (a.first > 0 && b.first > 0) return a.second > b.second; if (a.first < 0 && b.first < 0) return a.second - a.first < b.second - b.first; return a.first > b.first; } int main() { ios::sync_with_stdio(0); cin >> n; cont(i, n) { cin >> s[i]; int cur = 0; loop(j, s[i].size()) { char c = s[i][j]; cur += c == '(' ? +1 : -1; mn[i] = min(mn[i], cur); } pre[i] = cur; sum += cur; dat[i] = make_pair(pre[i], mn[i]); } if (sum != 0) { cout << "No" << ln; return 0; } sort(dat + 1, dat + n + 1, cmp); int cur = 0; cont(i, n) { int a = dat[i].first, b = dat[i].second; if (cur + b < 0) { cout << "No" << ln; return 0; } cur += a; } cout << "Yes" << ln; }
#include <bits/stdc++.h> #define ln '\n' #define all(dat) dat.begin(), dat.end() #define loop(i, to) for (int i = 0; i < to; ++i) #define cont(i, to) for (int i = 1; i <= to; ++i) #define circ(i, fm, to) for (int i = fm; i <= to; ++i) #define foreach(i, dat) \ for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i) typedef long long num; using namespace std; const int nsz = int(1e6); int n, sum, pre[nsz + 5], mn[nsz + 5]; pair<int, int> dat[nsz + 5]; string s[nsz + 5]; bool inline cmp(pair<int, int> a, pair<int, int> b) { if (a.first > 0 && b.first > 0) return a.second > b.second; if (a.first < 0 && b.first < 0) return a.second - a.first < b.second - b.first; return a.first > b.first; } int main() { ios::sync_with_stdio(0); cin >> n; cont(i, n) { cin >> s[i]; int cur = 0; loop(j, s[i].size()) { char c = s[i][j]; cur += c == '(' ? +1 : -1; mn[i] = min(mn[i], cur); } pre[i] = cur; sum += cur; dat[i] = make_pair(pre[i], mn[i]); } if (sum != 0) { cout << "No" << ln; return 0; } sort(dat + 1, dat + n + 1, cmp); int cur = 0; cont(i, n) { int a = dat[i].first, b = dat[i].second; if (cur + b < 0) { cout << "No" << ln; return 0; } cur += a; } cout << "Yes" << ln; }
replace
14
15
14
15
0
p02687
C++
Runtime Error
#include <cstring> #include <iostream> using namespace std; int main() { char a[3]; cin >> a[1] >> a[2] >> a[3]; if (a[2] == 'B') cout << "ARC"; else cout << "ABC"; return 0; }
#include <cstring> #include <iostream> using namespace std; int main() { char a[3]; cin >> a[0] >> a[1] >> a[2]; if (a[1] == 'B') cout << "ARC"; else cout << "ABC"; return 0; }
replace
6
8
6
8
-6
*** stack smashing detected ***: terminated
p02687
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i < (int)(n); i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)-1); i > 0; i--) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) using namespace std; using lint = long long; using p = pair<int, int>; 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 (b < a) { a = b; return 1; } return 0; } int main() { string s; scanf("%s", &s); if (s == "ARC") cout << "ABC" << endl; else cout << "ARC" << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i < (int)(n); i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)-1); i > 0; i--) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) using namespace std; using lint = long long; using p = pair<int, int>; 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 (b < a) { a = b; return 1; } return 0; } int main() { string s; cin >> s; if (s == "ARC") cout << "ABC" << endl; else cout << "ARC" << endl; return 0; }
replace
27
28
27
28
-11
p02687
C++
Runtime Error
#include <stdio.h> int main() { char contest; scanf("%s", &contest); if (contest = 'B') { printf("ARC"); } else if (contest = 'R') { printf("ABC"); } return 0; }
#include <stdio.h> int main() { char S[6]; scanf("%s", &S); if (S[1] == 'B') printf("ARC\n"); else printf("ABC\n"); return 0; }
replace
3
11
3
9
-6
*** stack smashing detected ***: terminated
p02687
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int a, b, k; cin >> k; cin >> a >> b; int max = b / k; bool flag = false; for (int i = 1; i <= max + 2; i++) { if (i * k <= b && i * k >= a) flag = true; } if (flag) cout << "OK" << endl; else cout << "NG" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (s == "ABC") cout << "ARC" << endl; else if (s == "ARC") cout << "ABC" << endl; }
replace
3
17
3
9
-8
p02687
C++
Runtime Error
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> int main(int argc, char **argv) { std::string S = argv[1]; if (S == "ARC") std::cout << "ABC" << std::endl; else std::cout << "ARC" << std::endl; return 0; }
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> int main(int argc, char **argv) { std::string S; std::cin >> S; if (S == "ARC") std::cout << "ABC" << std::endl; else std::cout << "ARC" << std::endl; return 0; }
replace
5
6
5
7
-6
terminate called after throwing an instance of 'std::logic_error' what(): basic_string: construction from null is not valid
p02687
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fast() \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long int #define test() \ ll t; \ cin >> t; \ while (t--) #define lp0(i, begin, end) for (ll i = begin; i < end; i++) #define lp1(i, begin, end) for (ll i = begin; i <= end; i++) #define rlp(i, begin, end) for (ll i = end; i >= begin; i--) #define prec(n) fixed << setprecision(n) #define initial(a, i) memset(a, i, sizeof(a)) #define pb push_back #define PI 3.1415926535897932384626433832795 #define MOD 1000000007 #define F first #define S second #define all(a) (a).begin(), (a).end() #define BPC(x) __builtin_popcountll(x) #define gcd(a, b) __gcd(a, b) ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } ll power(ll x, ll n) { ll result = 1; while (n) { if (n & 1) result = result * x; n = n / 2; x = x * x; } return result; } // Solution Function void solution(ll compte) { // cout<<compte<<"\n"; ll k; cin >> k; ll s, w; cin >> s >> w; for (ll i = s; i < w + 1; i++) { if (i % k == 0) { puts("OK"); return; } } cout << "NG\n"; } // Driver Function int main() { ll compte = 1; // test() //{ solution(compte); compte++; //} return 0; }
#include <bits/stdc++.h> using namespace std; #define fast() \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long int #define test() \ ll t; \ cin >> t; \ while (t--) #define lp0(i, begin, end) for (ll i = begin; i < end; i++) #define lp1(i, begin, end) for (ll i = begin; i <= end; i++) #define rlp(i, begin, end) for (ll i = end; i >= begin; i--) #define prec(n) fixed << setprecision(n) #define initial(a, i) memset(a, i, sizeof(a)) #define pb push_back #define PI 3.1415926535897932384626433832795 #define MOD 1000000007 #define F first #define S second #define all(a) (a).begin(), (a).end() #define BPC(x) __builtin_popcountll(x) #define gcd(a, b) __gcd(a, b) ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } ll power(ll x, ll n) { ll result = 1; while (n) { if (n & 1) result = result * x; n = n / 2; x = x * x; } return result; } // Solution Function void solution(ll compte) { // cout<<compte<<"\n"; string s; cin >> s; if (s == "ABC") puts("ARC"); else puts("ABC"); } // Driver Function int main() { ll compte = 1; // test() //{ solution(compte); compte++; //} return 0; }
replace
46
57
46
52
0
p02687
C++
Runtime Error
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; #define ll long long string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) { const unsigned int pos = replacedStr.find(from); const int len = from.length(); if (pos == std::string::npos || from.empty()) { return replacedStr; } return replacedStr.replace(pos, len, to); } int main() { string S; cin >> S; replaceOtherStr(S, "BC", "RC"); cout << S << endl; }
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; #define ll long long string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) { const unsigned int pos = replacedStr.find(from); const int len = from.length(); if (pos == std::string::npos || from.empty()) { return replacedStr; } return replacedStr.replace(pos, len, to); } int main() { string S; cin >> S; if (S == "ABC") replaceOtherStr(S, "BC", "RC"); else replaceOtherStr(S, "RC", "BC"); cout << S << endl; }
replace
23
24
23
27
0
p02687
C++
Runtime Error
#include <iostream> using namespace std; int main() { char a[5]; cin >> a[5]; if (a[1] == 'B') cout << "ARC"; else cout << "ABC"; return 0; }
#include <iostream> using namespace std; int main() { char a[10]; cin >> a; if (a[0] == 'A' && a[1] == 'B' && a[2] == 'C') cout << "ARC" << endl; else if (a[0] == 'A' && a[1] == 'R' && a[2] == 'C') cout << "ABC" << endl; return 0; }
replace
3
9
3
9
-6
*** stack smashing detected ***: terminated
p02687
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); \ i += 1 - 2 * ((begin) > \ (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it using namespace std; int main() { int n; cin >> n; vector<int> mp(n + 1, 0); rep(i, 1, n) { int a; cin >> a; mp[a]++; } rep(x, 1, n + 1) cout << mp[x] << endl; return 0; }
#include <bits/stdc++.h> #define ll long long #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); \ i += 1 - 2 * ((begin) > \ (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> // {4,3,2,1} // rep(it, end(v), begin(v)) --> *it using namespace std; int main() { string s; cin >> s; cout << (s == "ABC" ? "ARC" : "ABC"); return 0; }
replace
12
21
12
15
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define ULL(...) \ ull __VA_ARGS__; \ in(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define CHR(...) \ char __VA_ARGS__; \ in(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ in(__VA_ARGS__) #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define VEC(type, name, size) \ vector<type> name(size); \ in(name) #define vv(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define VV(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)); \ in(name) #define vvv(type, name, h, w, ...) \ vector<vector<vector<type>>> name( \ h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) inline int scan() { return getchar(); } inline void scan(int &a) { scanf("%d", &a); } inline void scan(unsigned &a) { scanf("%u", &a); } inline void scan(long &a) { scanf("%ld", &a); } inline void scan(long long &a) { scanf("%lld", &a); } inline void scan(unsigned long long &a) { scanf("%llu", &a); } inline void scan(char &a) { cin >> a; } inline void scan(float &a) { scanf("%f", &a); } inline void scan(double &a) { scanf("%lf", &a); } inline void scan(long double &a) { scanf("%Lf", &a); } inline void scan(vector<bool> &vec) { for (unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } } inline void scan(string &a) { cin >> a; } template <class T> inline void scan(vector<T> &vec); template <class T, size_t size> inline void scan(array<T, size> &vec); template <class T, class L> inline void scan(pair<T, L> &p); template <class T, size_t size> inline void scan(T (&vec)[size]); template <class T> inline void scan(vector<T> &vec) { for (auto &i : vec) scan(i); } template <class T, size_t size> inline void scan(array<T, size> &vec) { for (auto &i : vec) scan(i); } template <class T, class L> inline void scan(pair<T, L> &p) { scan(p.first); scan(p.second); } template <class T, size_t size> inline void scan(T (&vec)[size]) { for (auto &i : vec) scan(i); } template <class T> inline void scan(T &a) { cin >> a; } inline void in() {} template <class Head, class... Tail> inline void in(Head &head, Tail &...tail) { scan(head); in(tail...); } inline constexpr ll gcd(ll a, ll b) { if (!a || !b) return 0; while (b) { ll c = b; b = a % b; a = c; } return a; } inline constexpr ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } 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 Graph = vector<vector<int>>; /* 4方向への隣接頂点への移動を表すベクトル */ const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const long long INF = 1LL << 60; int main() { INT(N); INT(K); vec(int, v, N - 1); for (int i = 0; i < K; i++) { INT(d); for (int j = 0; j < d; j++) { int l = 0; cin >> l; v[l - 1]++; } } int ans = 0; for (int i = 0; i < N; i++) { if (v[i] == 0) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define ULL(...) \ ull __VA_ARGS__; \ in(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define CHR(...) \ char __VA_ARGS__; \ in(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ in(__VA_ARGS__) #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define VEC(type, name, size) \ vector<type> name(size); \ in(name) #define vv(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define VV(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)); \ in(name) #define vvv(type, name, h, w, ...) \ vector<vector<vector<type>>> name( \ h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) inline int scan() { return getchar(); } inline void scan(int &a) { scanf("%d", &a); } inline void scan(unsigned &a) { scanf("%u", &a); } inline void scan(long &a) { scanf("%ld", &a); } inline void scan(long long &a) { scanf("%lld", &a); } inline void scan(unsigned long long &a) { scanf("%llu", &a); } inline void scan(char &a) { cin >> a; } inline void scan(float &a) { scanf("%f", &a); } inline void scan(double &a) { scanf("%lf", &a); } inline void scan(long double &a) { scanf("%Lf", &a); } inline void scan(vector<bool> &vec) { for (unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } } inline void scan(string &a) { cin >> a; } template <class T> inline void scan(vector<T> &vec); template <class T, size_t size> inline void scan(array<T, size> &vec); template <class T, class L> inline void scan(pair<T, L> &p); template <class T, size_t size> inline void scan(T (&vec)[size]); template <class T> inline void scan(vector<T> &vec) { for (auto &i : vec) scan(i); } template <class T, size_t size> inline void scan(array<T, size> &vec) { for (auto &i : vec) scan(i); } template <class T, class L> inline void scan(pair<T, L> &p) { scan(p.first); scan(p.second); } template <class T, size_t size> inline void scan(T (&vec)[size]) { for (auto &i : vec) scan(i); } template <class T> inline void scan(T &a) { cin >> a; } inline void in() {} template <class Head, class... Tail> inline void in(Head &head, Tail &...tail) { scan(head); in(tail...); } inline constexpr ll gcd(ll a, ll b) { if (!a || !b) return 0; while (b) { ll c = b; b = a % b; a = c; } return a; } inline constexpr ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } 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 Graph = vector<vector<int>>; /* 4方向への隣接頂点への移動を表すベクトル */ const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const long long INF = 1LL << 60; int main() { INT(N); INT(K); vec(int, v, N); for (int i = 0; i < K; i++) { INT(d); for (int j = 0; j < d; j++) { int l = 0; cin >> l; v[l - 1]++; } } int ans = 0; for (int i = 0; i < N; i++) { if (v[i] == 0) { ans++; } } cout << ans << endl; }
replace
115
116
115
116
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; int d; int e; int c; cin >> N >> K; vector<int> a(N); for (int j = 0; j < K; j++) { a.at(j) = 0; } for (int l = 0; l < K; l++) { cin >> d; for (int i = 0; i < d; i++) { cin >> e; a.at(e - 1) = 1; } } for (int m = 0; m < N; m++) { if (a.at(m) == 0) c++; } cout << c << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; int d; int e; int c; cin >> N >> K; vector<int> a(N); for (int j = 0; j < N; j++) { a.at(j) = 0; } for (int l = 0; l < K; l++) { cin >> d; for (int i = 0; i < d; i++) { cin >> e; a.at(e - 1) = 1; } } for (int m = 0; m < N; m++) { if (a.at(m) == 0) c++; } cout << c << endl; }
replace
9
10
9
10
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> vec(n); int d; for (int i = 0; i < k; ++i) { cin >> d; if (d != 0) { vector<int> a(d); for (int j = 0; j < d; ++j) { cin >> a[i]; vec[a[i] - 1]++; } } } int count = 0; for (int i = 0; i < n; ++i) { if (vec[i] == 0) { count++; } } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> vec(n); int d; for (int i = 0; i < k; ++i) { cin >> d; vector<int> a(d); for (int j = 0; j < d; ++j) { cin >> a[j]; vec[a[j] - 1]++; } } int count = 0; for (int i = 0; i < n; ++i) { if (vec[i] == 0) { count++; } } cout << count << endl; return 0; }
replace
11
17
11
15
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // 型名省略 typedef long long ll; typedef vector<long long> vl; typedef vector<vector<long long>> vvl; typedef vector<char> vc; typedef vector<vector<char>> vvc; typedef vector<string> vs; // マクロ #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define rep2(i, x, n) for (ll i = (ll)x; i < (ll)n; i++) #define all(A) A.begin(), A.end() // 正誤判定 void Yes(bool ans) { cout << (ans ? "Yes" : "No") << endl; } void YES(bool ans) { cout << (ans ? "YES" : "NO") << endl; } // main関数 int main() { ll n, k; cin >> n >> k; vl have(n), d(k); vvl a(n, vl(k)); rep(i, k) { cin >> d[i]; rep(j, d[i]) { cin >> a[i][j]; a[i][j]--; have[a[i][j]]++; } } ll ans = 0; rep(i, n) { if (have[i] == 0) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; // 型名省略 typedef long long ll; typedef vector<long long> vl; typedef vector<vector<long long>> vvl; typedef vector<char> vc; typedef vector<vector<char>> vvc; typedef vector<string> vs; // マクロ #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define rep2(i, x, n) for (ll i = (ll)x; i < (ll)n; i++) #define all(A) A.begin(), A.end() // 正誤判定 void Yes(bool ans) { cout << (ans ? "Yes" : "No") << endl; } void YES(bool ans) { cout << (ans ? "YES" : "NO") << endl; } // main関数 int main() { ll n, k; cin >> n >> k; vl have(n), d(k); vvl a(k, vl(n)); rep(i, k) { cin >> d[i]; rep(j, d[i]) { cin >> a[i][j]; a[i][j]--; have[a[i][j]]++; } } ll ans = 0; rep(i, n) { if (have[i] == 0) ans++; } cout << ans << endl; }
replace
22
23
22
23
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; int d; int a; vector<bool> S(N, true); for (int i = 0; i < K; i++) { cin >> d; for (int i = 0; i < d; i++) { cin >> a; S.at(a) = false; } } int count = 0; for (int i = 0; i < N; i++) { if (S.at(i)) { count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; int d; int a; vector<bool> S(N, true); for (int i = 0; i < K; i++) { cin >> d; for (int i = 0; i < d; i++) { cin >> a; S.at(a - 1) = false; } } int count = 0; for (int i = 0; i < N; i++) { if (S.at(i)) { count++; } } cout << count << endl; }
replace
13
14
13
14
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector<bool>::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; int d[K]; int A[N][N]; int have_bool[N]; for (int i = 0; i < N; i++) { have_bool[i] = false; } for (int i = 0; i < K; ++i) { cin >> d[i]; for (int j = 0; j < d[i]; ++j) { cin >> A[i][j]; have_bool[A[i][j] - 1] = true; } } int cnt = 0; for (int i = 0; i < N; i++) { if (!have_bool[i]) cnt++; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; int d[K]; int A[K][N]; int have_bool[N]; for (int i = 0; i < N; i++) { have_bool[i] = false; } for (int i = 0; i < K; ++i) { cin >> d[i]; for (int j = 0; j < d[i]; ++j) { cin >> A[i][j]; have_bool[A[i][j] - 1] = true; } } int cnt = 0; for (int i = 0; i < N; i++) { if (!have_bool[i]) cnt++; } cout << cnt << endl; return 0; }
replace
7
8
7
8
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> sunuke(N); for (int j = 0; j < K; j++) { int d; cin >> d; for (int i = 0; i < d; i++) { int A; cin >> A; sunuke.at(A) = 1; } } int sum = 0; for (int i = 0; i < N; i++) { sum += sunuke.at(i); } cout << N - sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> sunuke(N); for (int j = 0; j < K; j++) { int d; cin >> d; for (int i = 0; i < d; i++) { int A; cin >> A; sunuke.at(A - 1) = 1; } } int sum = 0; for (int i = 0; i < N; i++) { sum += sunuke.at(i); } cout << N - sum << endl; }
replace
17
18
17
18
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define chmin(a, b) \ if ((a) > (b)) \ (a) = (b); #define chmax(a, b) \ if ((a) < (b)) \ (a) = (b); #define vi vector<int> #define pii pair<int, int> #define all(v) (v).begin(), (v).end() #define allr(v) (v).rbegin(), (v).rend() #define pb push_back #define pf push_front int gcd(int a, int b) { /*a>=0,b>=0,¬(a=b=0)*/ while (min(a, b) > 0) { if (a < b) swap(a, b); a %= b; } return max(a, b); } int dx[] = {0, 1, 0, -1, 1, -1, -1, 1}; int dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int MOD = 1e9 + 7; const int INF = 1e18 + 10; /*----------------------------------------------*/ signed main() { int n, k; cin >> n >> k; vi d(k); vector<vi> a(k, vi(n)); rep(i, k) { cin >> d[i]; rep(j, d[i]) cin >> a[i][j]; } vi cnt(n + 1, 0); rep(i, n) rep(j, d[i]) { cnt[a[i][j]]++; } int ans = 0; FOR(i, 1, n) if (cnt[i] == 0) ans++; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define chmin(a, b) \ if ((a) > (b)) \ (a) = (b); #define chmax(a, b) \ if ((a) < (b)) \ (a) = (b); #define vi vector<int> #define pii pair<int, int> #define all(v) (v).begin(), (v).end() #define allr(v) (v).rbegin(), (v).rend() #define pb push_back #define pf push_front int gcd(int a, int b) { /*a>=0,b>=0,¬(a=b=0)*/ while (min(a, b) > 0) { if (a < b) swap(a, b); a %= b; } return max(a, b); } int dx[] = {0, 1, 0, -1, 1, -1, -1, 1}; int dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int MOD = 1e9 + 7; const int INF = 1e18 + 10; /*----------------------------------------------*/ signed main() { int n, k; cin >> n >> k; vi d(k); vector<vi> a(k, vi(n)); rep(i, k) { cin >> d[i]; rep(j, d[i]) cin >> a[i][j]; } vi cnt(n + 1, 0); rep(i, k) rep(j, d[i]) { cnt[a[i][j]]++; } int ans = 0; FOR(i, 1, n) if (cnt[i] == 0) ans++; cout << ans << endl; return 0; }
replace
42
43
42
43
0
p02688
C++
Runtime Error
// in the name of ALLAH #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n, k; cin >> n >> k; set<int> s; int d[n]; for (int i = 0; i < k; i++) { cin >> d[i]; int a[d[i] + 1]; for (int j = 0; j < d[i]; j++) { cin >> a[j]; s.insert(a[j]); } } cout << n - s.size() << endl; }
// in the name of ALLAH #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n, k; cin >> n >> k; set<int> s; int d[k + 1]; for (int i = 0; i < k; i++) { cin >> d[i]; int a[d[i] + 1]; for (int j = 0; j < d[i]; j++) { cin >> a[j]; s.insert(a[j]); } } cout << n - s.size() << endl; }
replace
8
9
8
9
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); // N人の子供を宣言 // どの子供がどれだけお菓子をもらったかを入力 for (int i = 0; i < K; i++) { int di; // i番目のお菓子をもってる人数 cin >> di; int Ai; // i番目のお菓子を持ってる人の番号 for (int j = 0; j < di; j++) { cin >> Ai; // お菓子を持ってる人の番号を入力 A.at(Ai) += 1; // お菓子をもらった人のお菓子の数を+1 } } // A(N)の値を順に調べていって値が0の人数をカウントする int count = 0; for (int x : A) { // Aの値xをすべて調べる if (x == 0) count++; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); // N人の子供を宣言 // どの子供がどれだけお菓子をもらったかを入力 for (int i = 0; i < K; i++) { int di; // i番目のお菓子をもってる人数 cin >> di; int Ai; // i番目のお菓子を持ってる人の番号 for (int j = 0; j < di; j++) { cin >> Ai; // お菓子を持ってる人の番号を入力 A.at(Ai - 1) += 1; // お菓子をもらった人のお菓子の数を+1 } } // A(N)の値を順に調べていって値が0の人数をカウントする int count = 0; for (int x : A) { // Aの値xをすべて調べる if (x == 0) count++; } cout << count << endl; }
replace
12
14
12
14
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main(void) { int N, K; int d, x; int count = 0; cin >> N >> K; vector<int> sunuke(N); for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> x; sunuke.at(x - 1) = 1; } } for (int i = 0; i < K; i++) { if (sunuke.at(i) == 0) count++; } cout << count; }
#include <bits/stdc++.h> using namespace std; int main(void) { int N, K; int d, x; int count = 0; cin >> N >> K; vector<int> sunuke(N); for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> x; sunuke.at(x - 1) = 1; } } for (int i = 0; i < N; i++) { if (sunuke.at(i) == 0) count++; } cout << count; }
replace
17
18
17
18
0
p02688
C++
Runtime Error
#include <iostream> #include <string> using namespace std; int main(void) { int n, k, p, a, ni = 0; string s; cin >> n >> k; for (int i = 0; i < n; i++) { s[i] = 0; } for (int j = 0; j < k; j++) { cin >> p; for (int z = 0; z < p; z++) { cin >> a; s[a - 1] = 1; } } for (int i = 0; i < n; i++) { if (s[i] == 0) ni++; } cout << ni << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main(void) { int n, k, p, a, ni = 0; int s[100]; cin >> n >> k; for (int i = 0; i < n; i++) { s[i] = 0; } for (int j = 0; j < k; j++) { cin >> p; for (int z = 0; z < p; z++) { cin >> a; s[a - 1] = 1; } } for (int i = 0; i < n; i++) { if (s[i] == 0) ni++; } cout << ni << endl; return 0; }
replace
6
7
6
7
0
p02688
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <iostream> #include <map> #include <stdio.h> #include <stdlib.h> #include <vector> #define INF 100000000000000 using namespace std; typedef long long llong; // int isalpha(char ch): ch がアルファベットなら true を返す // int isdigit(char ch): ch が数字なら true を返す // int islower(char ch): ch が小文字なら true を返す // int isupper(char ch): ch が大文字なら true を返す // int tolower(char ch): ch の小文字を返す // int toupper(char ch): ch の大文字を返す // string型 // size() 文字数を返す // Insert() (指定した場所に)文字・文字列を挿入する // erase() (指定した場所の)文字・文字列を削除する // clear() すべての文字を削除する // substr() 文字列の(指定した)部分文字列を返す // replace() (指定した)部分文字列を新しい文字列に置換する // 文字列の比較は、<=や==などを使え // replace関数を使い、簡単に文字列を置換 // リバース関数:reverse(str.begin(), str.end()); // map<type, type> dict;で宣言 // グラフ理論用変数 // vector<vector<llong> > graph(N); // ソート // 降順sort(v.begin(), v.end(), std::greater<Type>()); // 大文字から小文字へんかん // w[i] = w[i]-'A'+'a'; // vector // assignメソッド 引数:サイズ、値 // 与えられたサイズと値でvectorを初期化する int main() { llong N, K; llong d; llong ans = 0; cin >> N >> K; vector<vector<llong>> Table(N); llong A; llong cnt = 0; for (int i = 0; i < Table.size(); i++) { for (int j = 0; j < K; j++) { Table[i].push_back(0); } } for (int i = 0; i < K; i++) { cin >> d; for (int i = 0; i < d; i++) { cin >> A; Table[A - 1][i] = 1; } } for (int i = 0; i < N; i++) { cnt = 0; for (int j = 0; j < K; j++) { if (Table[i][j] == 1) { cnt++; } } if (cnt == 0) { ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <iostream> #include <map> #include <stdio.h> #include <stdlib.h> #include <vector> #define INF 100000000000000 using namespace std; typedef long long llong; // int isalpha(char ch): ch がアルファベットなら true を返す // int isdigit(char ch): ch が数字なら true を返す // int islower(char ch): ch が小文字なら true を返す // int isupper(char ch): ch が大文字なら true を返す // int tolower(char ch): ch の小文字を返す // int toupper(char ch): ch の大文字を返す // string型 // size() 文字数を返す // Insert() (指定した場所に)文字・文字列を挿入する // erase() (指定した場所の)文字・文字列を削除する // clear() すべての文字を削除する // substr() 文字列の(指定した)部分文字列を返す // replace() (指定した)部分文字列を新しい文字列に置換する // 文字列の比較は、<=や==などを使え // replace関数を使い、簡単に文字列を置換 // リバース関数:reverse(str.begin(), str.end()); // map<type, type> dict;で宣言 // グラフ理論用変数 // vector<vector<llong> > graph(N); // ソート // 降順sort(v.begin(), v.end(), std::greater<Type>()); // 大文字から小文字へんかん // w[i] = w[i]-'A'+'a'; // vector // assignメソッド 引数:サイズ、値 // 与えられたサイズと値でvectorを初期化する int main() { llong N, K; llong d; llong ans = 0; cin >> N >> K; vector<vector<llong>> Table(N); llong A; llong cnt = 0; for (int i = 0; i < Table.size(); i++) { for (int j = 0; j < K; j++) { Table[i].push_back(0); } } for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> A; Table[A - 1][i] = 1; } } for (int i = 0; i < N; i++) { cnt = 0; for (int j = 0; j < K; j++) { if (Table[i][j] == 1) { cnt++; } } if (cnt == 0) { ans++; } } cout << ans << endl; return 0; }
replace
58
59
58
59
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n, k; cin >> n >> k; int d, a; int sum = 0; vector<int> flag(n, 0); rep(i, k) { cin >> d; rep(i, d) { cin >> a; flag.at(a - 1) = 1; } } rep(i, k) { // cout << flag.at(i); if (flag.at(i) == 0) sum += 1; } cout << sum; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n, k; cin >> n >> k; int d, a; int sum = 0; vector<int> flag(n, 0); rep(i, k) { cin >> d; rep(i, d) { cin >> a; flag.at(a - 1) = 1; } } rep(i, n) { // cout << flag.at(i); if (flag.at(i) == 0) sum += 1; } cout << sum; }
replace
22
23
22
23
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K, x = 0; cin >> N >> K; vector<vector<int>> sunuke(N, vector<int>(0)); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int A; cin >> A; sunuke.at(A).push_back(i); } } for (int i = 0; i < N; i++) { if (sunuke.at(i).size() == 0) x++; } cout << x << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K, x = 0; cin >> N >> K; vector<vector<int>> sunuke(N, vector<int>(0)); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int A; cin >> A; sunuke.at(A - 1).push_back(i); } } for (int i = 0; i < N; i++) { if (sunuke.at(i).size() == 0) x++; } cout << x << endl; }
replace
13
14
13
14
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> using namespace std; int main() { int c = 0, i = 0, k, d, n = 0, x, s[1000]; cin >> x >> k; while (k--) { cin >> d; n += d; while (d--) { cin >> s[i++]; } } sort(s, s + n); c = 0; for (i = 0; i < n; i++) { if (s[i] != s[i + 1]) c++; } cout << x - c << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> using namespace std; int main() { int c = 0, i = 0, k, d, n = 0, x, s[10010]; cin >> x >> k; while (k--) { cin >> d; n += d; while (d--) { cin >> s[i++]; } } sort(s, s + n); c = 0; for (i = 0; i < n; i++) { if (s[i] != s[i + 1]) c++; } cout << x - c << endl; return 0; }
replace
4
5
4
5
0
p02688
C++
Time Limit Exceeded
// .----------------. .----------------. .----------------. // .----------------. .----------------. .----------------. // .----------------. .----------------. .----------------. // | .--------------. || .--------------. || .--------------. || // .--------------. || .--------------. || .--------------. || .--------------. // || .--------------. || .--------------. | | | ___ ____ | || | __ | // || | _____ | || | ________ | || | ____ | || | ___ ____ // | || | _____ _____ | || | | || | ____ | | | | |_ ||_ // _| | || | / \ | || | |_ _| | || | | __ _| | || | .' // `. | || | |_ ||_ _| | || ||_ _||_ _|| || | | || | .' // `. | | | | | |_/ / | || | / /\ \ | || | | | | || | |_/ // / / | || | / .--. \ | || | | |_/ / | || | | | | | | || | | // || | / .--. \ | | | | | __'. | || | / ____ \ | || | | | // | || | .'.' _ | || | | | | | | || | | __'. | || | | ' ' // | | || | | || | | | | | | | | | _| | \ \_ | || | _/ / // \ \_ | || | _| |_ | || | _/ /__/ | | || | \ `--' / | || | _| // | \ \_ | || | \ `--' / | || | | || | \ `--' / | | | | // |____||____| | || ||____| |____|| || | |_____| | || | |________| | // || | `.____.' | || | |____||____| | || | `.__.' | || | _______ // | || | `.____.' | | | | | || | | || | | || | // | || | | || | | || | | || | |_______| // | || | | | | '--------------' || '--------------' || // '--------------' || '--------------' || '--------------' || '--------------' // || '--------------' || '--------------' || '--------------' | // '----------------' '----------------' '----------------' // '----------------' '----------------' '----------------' // '----------------' '----------------' '----------------' #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef map<int, int> mii; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef unsigned long long int ulli; #define int ll #define F first #define S second #define endl "\n" #define MP make_pair #define PB push_back #define WL(t) while (t--) #define SZ(x) ((int)(x).size()) #define all(v) v.begin(), v.end() #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i < b; i++) #define FORD(i, a, b) for (int i = a; i >= b; i--) #define REPD(i, n) for (int i = n - 1; i >= 0; i--) #define PRECISION(x) cout << fixed << setprecision(x); #define inrange(i, a, b) ((i > min(a, b)) && (i < max(a, b))) #define FAST_IO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define debug(x) cout << '>' << #x << ':' << x << endl; const int MAXN = 1000005; const int MOD = 1000000007; template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); } template <typename T> T lcm(T a, T b) { return (a * (b / gcd(a, b))); } // typedef unsigned long long int ulli; bool isPrime(int n); // <<< WRITE CODE HERE >>> void solve() { int n, k; cin >> n >> k; mii mp; REP(i, n) { int di; cin >> di; WL(di) { int t; cin >> t; mp[t]++; } } int c = 0; FOR(i, 1, n + 1) if (!(mp[i])) c++; cout << c; } signed main() { FAST_IO int t = 1; // cin>>t; WL(t) { solve(); cout << endl; } return 0; } bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) if (!(n % i)) return false; return true; }
// .----------------. .----------------. .----------------. // .----------------. .----------------. .----------------. // .----------------. .----------------. .----------------. // | .--------------. || .--------------. || .--------------. || // .--------------. || .--------------. || .--------------. || .--------------. // || .--------------. || .--------------. | | | ___ ____ | || | __ | // || | _____ | || | ________ | || | ____ | || | ___ ____ // | || | _____ _____ | || | | || | ____ | | | | |_ ||_ // _| | || | / \ | || | |_ _| | || | | __ _| | || | .' // `. | || | |_ ||_ _| | || ||_ _||_ _|| || | | || | .' // `. | | | | | |_/ / | || | / /\ \ | || | | | | || | |_/ // / / | || | / .--. \ | || | | |_/ / | || | | | | | | || | | // || | / .--. \ | | | | | __'. | || | / ____ \ | || | | | // | || | .'.' _ | || | | | | | | || | | __'. | || | | ' ' // | | || | | || | | | | | | | | | _| | \ \_ | || | _/ / // \ \_ | || | _| |_ | || | _/ /__/ | | || | \ `--' / | || | _| // | \ \_ | || | \ `--' / | || | | || | \ `--' / | | | | // |____||____| | || ||____| |____|| || | |_____| | || | |________| | // || | `.____.' | || | |____||____| | || | `.__.' | || | _______ // | || | `.____.' | | | | | || | | || | | || | // | || | | || | | || | | || | |_______| // | || | | | | '--------------' || '--------------' || // '--------------' || '--------------' || '--------------' || '--------------' // || '--------------' || '--------------' || '--------------' | // '----------------' '----------------' '----------------' // '----------------' '----------------' '----------------' // '----------------' '----------------' '----------------' #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef map<int, int> mii; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef unsigned long long int ulli; #define int ll #define F first #define S second #define endl "\n" #define MP make_pair #define PB push_back #define WL(t) while (t--) #define SZ(x) ((int)(x).size()) #define all(v) v.begin(), v.end() #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i < b; i++) #define FORD(i, a, b) for (int i = a; i >= b; i--) #define REPD(i, n) for (int i = n - 1; i >= 0; i--) #define PRECISION(x) cout << fixed << setprecision(x); #define inrange(i, a, b) ((i > min(a, b)) && (i < max(a, b))) #define FAST_IO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define debug(x) cout << '>' << #x << ':' << x << endl; const int MAXN = 1000005; const int MOD = 1000000007; template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); } template <typename T> T lcm(T a, T b) { return (a * (b / gcd(a, b))); } // typedef unsigned long long int ulli; bool isPrime(int n); // <<< WRITE CODE HERE >>> void solve() { int n, k; cin >> n >> k; mii mp; REP(i, k) { int di; cin >> di; WL(di) { int t; cin >> t; mp[t]++; } } int c = 0; FOR(i, 1, n + 1) if (!(mp[i])) c++; cout << c; } signed main() { FAST_IO int t = 1; // cin>>t; WL(t) { solve(); cout << endl; } return 0; } bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) if (!(n % i)) return false; return true; }
replace
75
76
75
76
TLE
p02688
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int m, n, i, j, x, y, g; bool f[101]; int main() { cin >> m >> n; for (i = 1; i <= n; i++) { cin >> x; for (i = j = 1; j <= x; j++) { cin >> y; f[y] = 1; } } for (i = 1; i <= m; i++) if (f[i] == 0) g++; cout << g; return 0; }
#include <bits/stdc++.h> using namespace std; int m, n, i, j, x, y, g; bool f[101]; int main() { cin >> m >> n; for (i = 1; i <= n; i++) { cin >> x; for (j = 1; j <= x; j++) { cin >> y; f[y] = 1; } } for (i = 1; i <= m; i++) if (f[i] == 0) g++; cout << g; return 0; }
replace
8
9
8
9
TLE
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); vector<int> d(k); for (int i = 0; i < n + 1; i++) a[i] = 0; for (int i = 0; i < k; i++) { cin >> d[i]; for (int j = 0; j < d[i]; j++) { int x; cin >> x; a[x]++; } } int cnt = 0; for (int i = 1; i < n + 1; i++) { if (a[i] == 0) { cnt++; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n + 1); vector<int> d(k); for (int i = 0; i < n + 1; i++) a[i] = 0; for (int i = 0; i < k; i++) { cin >> d[i]; for (int j = 0; j < d[i]; j++) { int x; cin >> x; a[x]++; } } int cnt = 0; for (int i = 1; i < n + 1; i++) { if (a[i] == 0) { cnt++; } } cout << cnt << endl; }
replace
6
7
6
7
0
p02688
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; using P = pair<int, int>; int main() { int n, k; cin >> n >> k; vector<int> have(n); vector<int> d(k); rep(i, k) { int a; cin >> a; rep(j, a) { int b; cin >> b; have.at(b) = 1; } } int count = 0; rep(i, n) { if (have.at(i) == 1) continue; count++; } cout << count; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, k; cin >> n >> k; vector<int> have(n); vector<int> d(k); rep(i, k) { int a; cin >> a; rep(j, a) { int b; cin >> b; have.at(b - 1) = 1; } } int count = 0; rep(i, n) { if (have.at(i) == 1) continue; count++; } cout << count; }
replace
17
18
17
18
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; bitset<100> A; for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int k; cin >> k; A.set(k); } } cout << N - A.count() << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; bitset<100> A; for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int k; cin >> k; A.set(k - 1); } } cout << N - A.count() << endl; }
replace
13
14
13
14
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repe(i, n) for (int i = 1; i <= (int)(n); ++i) #define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit) #define ll long long using namespace std; typedef vector<vector<int>> Graph; int main() { int N, K; cin >> N >> K; vector<bool> exist(N, false); rep(i, K) { int d; cin >> d; rep(j, d) { int A; cin >> A; exist.at(A) = true; } } int cnt = 0; rep(i, N) { if (!exist.at(i)) cnt++; } cout << cnt << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repe(i, n) for (int i = 1; i <= (int)(n); ++i) #define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit) #define ll long long using namespace std; typedef vector<vector<int>> Graph; int main() { int N, K; cin >> N >> K; vector<bool> exist(N, false); rep(i, K) { int d; cin >> d; rep(j, d) { int A; cin >> A; exist.at(A - 1) = true; } } int cnt = 0; rep(i, N) { if (!exist.at(i)) cnt++; } cout << cnt << endl; }
replace
19
20
19
20
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector<bool>::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep0(i, n) for (i = 0; i < n; i++) #define rep1(i, n) for (i = 1; i <= n; i++) #define test(a) cout << "*" << a << endl #define ll long long int main() { int n, k; int d[100]; int A[100][100]; int i, j; bool human[101] = {false}; int humanNo = 0; cin >> n >> k; rep1(i, k) { cin >> d[i]; rep1(j, d[i]) { cin >> A[i][j]; human[A[i][j]] = true; } } rep1(i, n) { if (human[i] == false) { humanNo++; // test(i); } } cout << humanNo << endl; /*rep1(i,k){ test(d[i]); rep1(j,d[i]){ test(A[i][j]); } }*/ }
#include <bits/stdc++.h> using namespace std; #define rep0(i, n) for (i = 0; i < n; i++) #define rep1(i, n) for (i = 1; i <= n; i++) #define test(a) cout << "*" << a << endl #define ll long long int main() { int n, k; int d[101]; int A[101][101]; int i, j; bool human[101] = {false}; int humanNo = 0; cin >> n >> k; rep1(i, k) { cin >> d[i]; rep1(j, d[i]) { cin >> A[i][j]; human[A[i][j]] = true; } } rep1(i, n) { if (human[i] == false) { humanNo++; // test(i); } } cout << humanNo << endl; /*rep1(i,k){ test(d[i]); rep1(j,d[i]){ test(A[i][j]); } }*/ }
replace
8
10
8
10
0
p02688
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int index = 0; int p = k * (k + 1) / 2; int arr[p]; while (k--) { int s; cin >> s; for (int i = 0; i < s; i++) { cin >> arr[index]; index++; } } sort(arr, arr + index); int count = 1; for (int i = 1; i < index; i++) { if (arr[i] != arr[i - 1]) count++; } cout << n - count; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int index = 0; int arr[10000]; while (k--) { int s; cin >> s; for (int i = 0; i < s; i++) { cin >> arr[index]; index++; } } sort(arr, arr + index); int count = 1; for (int i = 1; i < index; i++) { if (arr[i] != arr[i - 1]) count++; } cout << n - count; return 0; }
replace
7
9
7
9
0
p02688
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<vector<int>> vec(K, vector<int>(N, 0)); // おかしを持っているかどうかに印を付ける// for (int i = 0; i < K; i++) { int T; // Tは持ってる人間の数、i番目のおかしの数// cin >> T; for (int j = 0; j < T; j++) { int f; // fが持ってる人間の番号// cin >> f; vec.at(i).at(f - 1) = 1; // 持っている人間を1と置く(持っている判定にする)// } } // 作成した表を用いて持っていない人間を判定する// int count = 0; for (int i = 0; i < N; i++) { // N人について、1番から順に確かめる// for (int j = 0; j < K; j++) { if (vec.at(j).at(i) == 1) { break; } else if (j = K - 1 && vec.at(j).at(i) == 0) { count++; } } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<vector<int>> vec(K, vector<int>(N, 0)); // おかしを持っているかどうかに印を付ける// for (int i = 0; i < K; i++) { int T; // Tは持ってる人間の数、i番目のおかしの数// cin >> T; for (int j = 0; j < T; j++) { int f; // fが持ってる人間の番号// cin >> f; vec.at(i).at(f - 1) = 1; // 持っている人間を1と置く(持っている判定にする)// } } // 作成した表を用いて持っていない人間を判定する// int count = 0; for (int i = 0; i < N; i++) { // N人について、1番から順に確かめる// for (int j = 0; j < K; j++) { if (vec.at(j).at(i) == 1) { break; } else if (j == K - 1 && vec.at(j).at(i) == 0) { count++; } } } cout << count << endl; }
replace
25
26
25
26
TLE
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base ::sync_with_stdio(false); \ cin.tie(NULL); int main() { FAST; int N, K, d, A; cin >> N >> K; vector<int> X(N, 1); for (int i = 0; i < K; i++) { cin >> d; for (int i = 0; i < d; i++) { cin >> A; X.at(A - 1) = 0; } } int ans = 0; for (int i = 0; i < K; i++) { ans += X.at(i); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base ::sync_with_stdio(false); \ cin.tie(NULL); int main() { FAST; int N, K, d, A; cin >> N >> K; vector<int> X(N, 1); for (int i = 0; i < K; i++) { cin >> d; for (int i = 0; i < d; i++) { cin >> A; X.at(A - 1) = 0; } } int ans = 0; for (int i = 0; i < N; i++) { ans += X.at(i); } cout << ans << endl; }
replace
19
20
19
20
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> p_ll; typedef vector<pair<ll, ll>> vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i) #define ture ture #define flase false #define falg flag #define REP(i, x) for (ll i = 0; i < (ll)(x); i++) #define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++) #define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--) #define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--) #define all(x) (x).begin(), (x).end() const ll MOD = pow(10, 9) + 7; const ll LLINF = pow(2, 61) - 1; // llの最大9*10^18 const int INF = pow(2, 30) - 1; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll N, K; cin >> N >> K; vector<ll> d(K); vector<vector<ll>> A(K, vector<ll>(K)); REP(i, K) { cin >> d.at(i); REP(j, d.at(i)) { cin >> A.at(i).at(j); } } vector<ll> vec; vec.push_back(0); REP(i, K) { REP(j, d.at(i)) { vec.push_back(A.at(i).at(j)); } } sort(vec.begin(), vec.end()); // cout << vec.size() << endl; ll tmp = 0; REP(i, vec.size() - 1) { if (!(vec.at(i) == vec.at(i + 1))) { tmp++; } // cout << tmp<<endl; } cout << N - tmp << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> p_ll; typedef vector<pair<ll, ll>> vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i) #define ture ture #define flase false #define falg flag #define REP(i, x) for (ll i = 0; i < (ll)(x); i++) #define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++) #define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--) #define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--) #define all(x) (x).begin(), (x).end() const ll MOD = pow(10, 9) + 7; const ll LLINF = pow(2, 61) - 1; // llの最大9*10^18 const int INF = pow(2, 30) - 1; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll N, K; cin >> N >> K; vector<ll> d(K); vector<vector<int>> A(K, vector<int>(N)); REP(i, K) { cin >> d.at(i); REP(j, d.at(i)) { cin >> A.at(i).at(j); } } vector<ll> vec; vec.push_back(0); REP(i, K) { REP(j, d.at(i)) { vec.push_back(A.at(i).at(j)); } } sort(vec.begin(), vec.end()); // cout << vec.size() << endl; ll tmp = 0; REP(i, vec.size() - 1) { if (!(vec.at(i) == vec.at(i + 1))) { tmp++; } // cout << tmp<<endl; } cout << N - tmp << endl; }
replace
33
34
33
34
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[n]; for (int i = 0; i < k; i++) { arr[i] = 0; } for (int i = 0; i < k; i++) { int n1; cin >> n1; for (int j = 0; j < n1; j++) { int x; cin >> x; arr[x - 1]++; } } int ans = 0; for (int i = 0; i < n; i++) { if (arr[i] == 0) { ans++; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[n]; for (int i = 0; i < n; i++) { arr[i] = 0; } for (int i = 0; i < k; i++) { int n1; cin >> n1; for (int j = 0; j < n1; j++) { int x; cin >> x; arr[x - 1]++; } } int ans = 0; for (int i = 0; i < n; i++) { if (arr[i] == 0) { ans++; } } printf("%d\n", ans); return 0; }
replace
9
10
9
10
0
p02688
C++
Runtime Error
#include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; int d[N]; int A[K][N]; for (int k = 0; k < K; k++) for (int i = 0; i < N; i++) A[k][i] = 0; for (int k = 0; k < K; k++) { cin >> d[k]; for (int i = 0; i < d[k]; i++) { cin >> A[k][i]; } } bool holder[N]; for (int i = 0; i < N; i++) holder[i] = false; for (int k = 0; k < K; k++) { for (int i = 0; i < d[k]; i++) { if (A[k][i] != 0) holder[A[k][i] - 1] = true; } } int cnt = 0; for (int i = 0; i < N; i++) { if (holder[i]) cnt++; } cout << N - cnt << endl; }
#include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; int d[K]; int A[K][N]; for (int k = 0; k < K; k++) for (int i = 0; i < N; i++) A[k][i] = 0; for (int k = 0; k < K; k++) { cin >> d[k]; for (int i = 0; i < d[k]; i++) { cin >> A[k][i]; } } bool holder[N]; for (int i = 0; i < N; i++) holder[i] = false; for (int k = 0; k < K; k++) { for (int i = 0; i < d[k]; i++) { if (A[k][i] != 0) holder[A[k][i] - 1] = true; } } int cnt = 0; for (int i = 0; i < N; i++) { if (holder[i]) cnt++; } cout << N - cnt << endl; }
replace
7
8
7
8
0
p02688
Python
Runtime Error
N, K = map(int, input().split()) have_snack = [0 for i in range(N)] for k in range(K): hito_len = int(input()) have_hito = map(int, input().split()) for hh in range(have_hito): have_snack[hh - 1] = 1 print(have_snack.count(0))
N, K = map(int, input().split()) have_snack = [0 for i in range(N)] for k in range(K): hito_len = int(input()) have_hito = list(map(int, input().split())) for hh in have_hito: have_snack[hh - 1] = 1 print(have_snack.count(0))
replace
6
8
6
8
TypeError: 'map' object cannot be interpreted as an integer
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02688/Python/s059895942.py", line 8, in <module> for hh in range(have_hito): TypeError: 'map' object cannot be interpreted as an integer
p02688
Python
Runtime Error
def main(n, a): indexes = {i + 1 for i in range(n)} reduced = set() for s in a: reduced |= s return len(indexes - reduced) if __name__ == "__main__": S = input().rstrip() N, K = map(int, input().split()) A = [] for _ in range(K): input() A.append(set(tuple(map(int, input().split(" "))))) print(main(N, A))
def main(n, a): indexes = {i + 1 for i in range(n)} reduced = set() for s in a: reduced |= s return len(indexes - reduced) if __name__ == "__main__": N, K = map(int, input().split()) A = [] for _ in range(K): input() A.append(set(tuple(map(int, input().split(" "))))) print(main(N, A))
delete
9
10
9
9
ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02688/Python/s616845508.py", line 11, in <module> N, K = map(int, input().split()) ValueError: not enough values to unpack (expected 2, got 1)
p02688
Python
Runtime Error
N, K = map(int, input().split()) check = [0] * N for i in range(K): d_i = int(input()) A_i = map(int, input().split()) for j in A_i: check[j] = 1 print(sum(1 for x in check if x == 0))
N, K = map(int, input().split()) check = [0] * N for i in range(K): d_i = int(input()) A_i = map(int, input().split()) for j in A_i: check[j - 1] = 1 print(sum(1 for x in check if x == 0))
replace
8
9
8
9
IndexError: list assignment index out of range
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02688/Python/s661360641.py", line 9, in <module> check[j] = 1 IndexError: list assignment index out of range
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec(N, 0); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec.at(a - 1)++; } } int ans = 0; for (int i = 0; i < K; i++) { if (vec.at(i) == 0) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec(N, 0); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec.at(a - 1)++; } } int ans = 0; for (int i = 0; i < N; i++) { if (vec.at(i) == 0) { ans++; } } cout << ans << endl; }
replace
18
19
18
19
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec(N); for (int i = 0; i < K; i++) { int d; cin >> d; vector<int> vec2(d); for (int j = 0; j < d; j++) { cin >> vec2.at(j); vec.at(vec.at(j) - 1)++; } } int ans = 0; for (int i = 0; i < N; i++) { if (vec.at(i) == 0) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec(N); for (int i = 0; i < K; i++) { int d; cin >> d; vector<int> vec2(d); for (int j = 0; j < d; j++) { cin >> vec2.at(j); vec.at(vec2.at(j) - 1)++; } } int ans = 0; for (int i = 0; i < N; i++) { if (vec.at(i) == 0) { ans++; } } cout << ans << endl; }
replace
16
17
16
17
-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 3)
p02688
C++
Runtime Error
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) static const ll MAX = 1000000000000000; static const int NIL = -1; using namespace std; const long double EPS = 0.0000000001; const long double PI = (acos(-1)); const int MOD = 1000000007; int main() { ll n, k, d, i, j, a_tmp, cnt = 0; cin >> n >> k; vector<ll> a(n, false); for (i = 0; i < k; ++i) { cin >> d; for (j = 0; j < d; ++j) { cin >> a_tmp; a[a_tmp - 1] = true; } } for (i = 0; i < k; ++i) { if (a[i] == false) cnt++; } cout << cnt << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) static const ll MAX = 1000000000000000; static const int NIL = -1; using namespace std; const long double EPS = 0.0000000001; const long double PI = (acos(-1)); const int MOD = 1000000007; int main() { ll n, k, d, i, j, a_tmp, cnt = 0; cin >> n >> k; vector<ll> a(n, false); for (i = 0; i < k; ++i) { cin >> d; for (j = 0; j < d; ++j) { cin >> a_tmp; a[a_tmp - 1] = true; } } for (i = 0; i < n; ++i) { if (a[i] == false) cnt++; } cout << cnt << endl; }
replace
22
23
22
23
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long ll; #define _GLIBCXX_DEBUG typedef vector<int> vec; typedef vector<ll> lvec; typedef vector<char> cvec; typedef pair<ll, ll> LP; typedef tuple<ll, ll, ll> LT; typedef pair<int, int> P; typedef tuple<int, int, int> T; int main() { int n, k; cin >> n >> k; vector<int> d(k), b(n); vector<vector<int>> a(k, vector<int>(k)); rep(i, k) { cin >> d[i]; rep(j, d[i]) { cin >> a[i][j]; a[i][j]--; b[a[i][j]]++; } } int ans = 0; rep(i, n) { if (b[i] == 0) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long ll; #define _GLIBCXX_DEBUG typedef vector<int> vec; typedef vector<ll> lvec; typedef vector<char> cvec; typedef pair<ll, ll> LP; typedef tuple<ll, ll, ll> LT; typedef pair<int, int> P; typedef tuple<int, int, int> T; int main() { int n, k; cin >> n >> k; vector<int> d(k), b(n); vector<vector<int>> a(k, vector<int>(n)); rep(i, k) { cin >> d[i]; rep(j, d[i]) { cin >> a[i][j]; a[i][j]--; b[a[i][j]]++; } } int ans = 0; rep(i, n) { if (b[i] == 0) ans++; } cout << ans << endl; }
replace
18
19
18
19
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef vector<string> VS; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define LB(a, x) lower_bound((a).begin(), (a).end(), x) - (a).begin() #define UB(a, x) upper_bound((a).begin(), (a).end(), x) - (a).begin() #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) #define en "\n" constexpr double EPS = 1e-9; constexpr double PI = 3.141592653589793238462643383279; constexpr int INF = 2147483647; constexpr long long LINF = 1LL << 60; constexpr long long MOD = 1000000007; // 998244353 #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N, K; cin >> N >> K; VVI A(N); REP(i, K) { int d; cin >> d; A[i].resize(d); REP(j, d) cin >> A[i][j]; } VI s(N, 0); REP(i, K) REP(j, A[i].size()) { s[A[i][j] - 1]++; } int ans = 0; REP(i, N) if (s[i] == 0) ans++; cout << ans << en; return 0; }
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef vector<string> VS; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define LB(a, x) lower_bound((a).begin(), (a).end(), x) - (a).begin() #define UB(a, x) upper_bound((a).begin(), (a).end(), x) - (a).begin() #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) #define en "\n" constexpr double EPS = 1e-9; constexpr double PI = 3.141592653589793238462643383279; constexpr int INF = 2147483647; constexpr long long LINF = 1LL << 60; constexpr long long MOD = 1000000007; // 998244353 #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main(void) { int N, K; cin >> N >> K; VVI A(K); REP(i, K) { int d; cin >> d; A[i].resize(d); REP(j, d) cin >> A[i][j]; } VI s(N, 0); REP(i, K) REP(j, A[i].size()) { s[A[i][j] - 1]++; } int ans = 0; REP(i, N) if (s[i] == 0) ans++; cout << ans << en; return 0; }
replace
66
67
66
67
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n, 0); for (int i = 0; i < k; i++) { int d; cin >> d; vector<int> b(d); for (int j = 0; j < d; j++) { cin >> b[j]; a[b[j]] = 1; } } int ans = 0; for (int i = 0; i < n; i++) { if (a[i] == 0) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n, 0); for (int i = 0; i < k; i++) { int d; cin >> d; vector<int> b(d); for (int j = 0; j < d; j++) { cin >> b[j]; a[b[j] - 1] = 1; } } int ans = 0; for (int i = 0; i < n; i++) { if (a[i] == 0) ans++; } cout << ans << endl; }
replace
14
15
14
15
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; int main() { ll N, K; cin >> N >> K; vector<ll> vec(N, 0); for (ll i = 0; i < K; i++) { ll a; cin >> a; for (ll j = 0; j < a; j++) { ll b; cin >> b; vec.at(b - 1) = 1; } } ll c = 0; for (ll i = 0; i < K; i++) { if (vec.at(i) == 0) { c += 1; } } cout << c << endl; }
#include <bits/stdc++.h> #include <math.h> using namespace std; using ll = long long; int main() { ll N, K; cin >> N >> K; vector<ll> vec(N, 0); for (ll i = 0; i < K; i++) { ll a; cin >> a; for (ll j = 0; j < a; j++) { ll b; cin >> b; vec.at(b - 1) = 1; } } ll c = 0; for (ll i = 0; i < N; i++) { if (vec.at(i) == 0) { c += 1; } } cout << c << endl; }
replace
18
19
18
19
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<bool> chk(N, false); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int A; cin >> A; chk.at(A - 1) = true; } } int ans = 0; for (int i = 0; i < K; i++) { if (!chk.at(i)) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<bool> chk(N, false); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int A; cin >> A; chk.at(A - 1) = true; } } int ans = 0; for (int i = 0; i < N; i++) { if (!chk.at(i)) { ans++; } } cout << ans << endl; }
replace
19
20
19
20
0
p02688
C++
Runtime Error
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; int d[n]; int a[n][n]; for (int i = 0; i < k; i++) { cin >> d[i]; for (int j = 0; j < d[i]; j++) { cin >> a[i][j]; a[i][j]--; } } bool judge[n]; for (int i = 0; i < n; i++) { judge[i] = false; } for (int i = 0; i < k; i++) { for (int j = 0; j < d[i]; j++) { for (int p = 0; p < n; p++) { if (a[i][j] == p) { judge[p] = true; } } } } int count = 0; for (int i = 0; i < n; i++) { if (judge[i] == false) count++; } cout << count << endl; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; int d[100]; int a[100][100]; for (int i = 0; i < k; i++) { cin >> d[i]; for (int j = 0; j < d[i]; j++) { cin >> a[i][j]; a[i][j]--; } } bool judge[n]; for (int i = 0; i < n; i++) { judge[i] = false; } for (int i = 0; i < k; i++) { for (int j = 0; j < d[i]; j++) { for (int p = 0; p < n; p++) { if (a[i][j] == p) { judge[p] = true; } } } } int count = 0; for (int i = 0; i < n; i++) { if (judge[i] == false) count++; } cout << count << endl; }
replace
8
10
8
10
0
p02688
C++
Runtime Error
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <cstring> #include <deque> // deque #include <iostream> // cout, endl, cin #include <map> // map #include <numeric> #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef unsigned long long ll; int main() { int N, K; cin >> N >> K; vector<int> d(N); set<int> S; vector<vector<int>> A(101, vector<int>(101)); rep(i, K) { cin >> d[i]; rep(j, d[i]) { cin >> A[i][j]; S.insert(A[i][j]); } } int count = 0; for (int i = 1; i <= N; i++) { if (S.count(i)) { count++; } } cout << N - count << endl; }
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <cstring> #include <deque> // deque #include <iostream> // cout, endl, cin #include <map> // map #include <numeric> #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef unsigned long long ll; int main() { int N, K; cin >> N >> K; vector<int> d(101); set<int> S; vector<vector<int>> A(101, vector<int>(101)); rep(i, K) { cin >> d[i]; rep(j, d[i]) { cin >> A[i][j]; S.insert(A[i][j]); } } int count = 0; for (int i = 1; i <= N; i++) { if (S.count(i)) { count++; } } cout << N - count << endl; }
replace
27
28
27
28
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int n, m, q; vector<int> a, b, c, d; int ans; template <typename T> void printVec(vector<T> &vec) { cout << ""; for (auto it = vec.begin(); it != vec.end(); ++it) { cout << *it << " "; } cout << endl; } int main() { int n, k; cin >> n >> k; vector<int> sunuke(n, 0); for (int i = 0; i < k; i++) { int d; cin >> d; vector<int> a(d); for (int j = 0; j < d; j++) { cin >> a[i]; sunuke[a[i] - 1] = 1; } } int ans = 0; for (int i = 0; i < n; i++) { if (sunuke[i] == 0) { ans = ans + 1; } } // printVec(sunuke); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int n, m, q; vector<int> a, b, c, d; int ans; template <typename T> void printVec(vector<T> &vec) { cout << ""; for (auto it = vec.begin(); it != vec.end(); ++it) { cout << *it << " "; } cout << endl; } int main() { int n, k; cin >> n >> k; vector<int> sunuke(n, 0); for (int i = 0; i < k; i++) { int d; cin >> d; vector<int> a(d); for (int j = 0; j < d; j++) { cin >> a[j]; sunuke[a[j] - 1] = 1; } } int ans = 0; for (int i = 0; i < n; i++) { if (sunuke[i] == 0) { ans = ans + 1; } } // printVec(sunuke); cout << ans << endl; return 0; }
replace
28
30
28
30
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; int d[100]; cin >> n >> k; vector<int> A(n, 0); int nu[100][100]; for (int i = 0; i < k; i++) { cin >> d[i]; for (int j = 0; j < d[i]; j++) { cin >> nu[i][j]; } } for (int i = 0; i < k; i++) { for (int j = 0; j < d[i]; j++) { A.at(nu[i][j])++; } } int sum = 0; for (int i = 0; i < n; i++) { if (A.at(i) == 0) sum++; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; int d[100]; cin >> n >> k; vector<int> A(n, 0); int nu[100][100]; for (int i = 0; i < k; i++) { cin >> d[i]; for (int j = 0; j < d[i]; j++) { cin >> nu[i][j]; } } for (int i = 0; i < k; i++) { for (int j = 0; j < d[i]; j++) { A.at(nu[i][j] - 1)++; } } int sum = 0; for (int i = 0; i < n; i++) { if (A.at(i) == 0) sum++; } cout << sum << endl; return 0; }
replace
21
22
21
22
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> sunu(n, 0); int d; int a; for (int i = 0; i < k; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> a; sunu.at(a) = 1; } } int sum = 0; for (int i = 0; i < n; i++) { if (sunu.at(i) == 0) { sum++; } } cout << sum; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> sunu(n, 0); int d; int a; for (int i = 0; i < k; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> a; sunu.at(a - 1) = 1; } } int sum = 0; for (int i = 0; i < n; i++) { if (sunu.at(i) == 0) { sum++; } } cout << sum; }
replace
12
13
12
13
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k, d, a[1000], i, f[1000] = {0}, k1 = 0, p[1000] = {0}; map<int, int> m; cin >> n >> k; int j = 0; while (k--) { cin >> d; for (i = 0; i < d; i++) { cin >> a[i]; p[j] = a[i]; j++; } } for (i = 0; i < j; i++) { // cout<<p[i]<<endl; f[p[i]]++; } for (i = 0; i < j; i++) { if (f[p[i]] != 0) { // cout<<p[i]<<" "<<f[p[i]]<<endl; k1++; f[p[i]] = 0; } } cout << n - k1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k, d, a[10000], i, f[100000] = {0}, k1 = 0, p[100000] = {0}; map<int, int> m; cin >> n >> k; int j = 0; while (k--) { cin >> d; for (i = 0; i < d; i++) { cin >> a[i]; p[j] = a[i]; j++; } } for (i = 0; i < j; i++) { // cout<<p[i]<<endl; f[p[i]]++; } for (i = 0; i < j; i++) { if (f[p[i]] != 0) { // cout<<p[i]<<" "<<f[p[i]]<<endl; k1++; f[p[i]] = 0; } } cout << n - k1 << endl; }
replace
5
6
5
6
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<bool> vec(n); for (int i = 0; i < n; i++) { vec.at(i) = false; } for (int i = 0; i < k; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec.at(a) = true; } } int cnt = 0; for (int i = 0; i < n; i++) { if (vec.at(i) == false) { cnt++; } } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<bool> vec(n); for (int i = 0; i < n; i++) { vec.at(i) = false; } for (int i = 0; i < k; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec.at(a - 1) = true; } } int cnt = 0; for (int i = 0; i < n; i++) { if (vec.at(i) == false) { cnt++; } } cout << cnt << endl; }
replace
17
18
17
18
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector<bool>::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <iostream> #include <set> #include <string> #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; set<int> s; for (ll i = 1; i <= k; i++) { int d; cin >> d; while (d) { ll t; cin >> t; s.insert(t); } } cout << n - s.size() << endl; return 0; }
#include <bits/stdc++.h> #include <iostream> #include <set> #include <string> #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; set<int> s; for (ll i = 1; i <= k; i++) { int d; cin >> d; while (d) { ll t; cin >> t; s.insert(t); d--; } } cout << n - s.size() << endl; return 0; }
insert
17
17
17
18
TLE
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec(N); for (int i = 0; i < N; i++) { vec.at(i) = 0; } for (int i = 0; i < K; i++) { int j; cin >> j; for (int k = 0; k < j; k++) { int l; cin >> l; vec.at(l)++; } } int A = 0; for (int i = 0; i < N; i++) { if (vec.at(i) == 0) { A++; } } cout << A; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec(N); for (int i = 0; i < N; i++) { vec.at(i) = 0; } for (int i = 0; i < K; i++) { int j; cin >> j; for (int k = 0; k < j; k++) { int l; cin >> l; vec.at(l - 1) = vec.at(l - 1) + 1; } } int A = 0; for (int i = 0; i < N; i++) { if (vec.at(i) == 0) { A++; } } cout << A; }
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 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<bool> s(n, false); for (int i = 0; i < k; i++) { int d; cin >> d; vector<int> a(d); for (int j = 0; j < d; j++) cin >> a.at(j); for (int j = 0; j < d; j++) { s.at(a.at(j)) = true; } } int count = 0; for (int i = 0; i < n; i++) { if (s.at(i) == false) count++; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<bool> s(n, false); for (int i = 0; i < k; i++) { int d; cin >> d; vector<int> a(d); for (int j = 0; j < d; j++) cin >> a.at(j); for (int j = 0; j < d; j++) { s.at(a.at(j) - 1) = true; } } int count = 0; for (int i = 0; i < n; i++) { if (s.at(i) == false) count++; } cout << count << endl; }
replace
17
18
17
18
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector<bool>::_M_range_check: __n (which is 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; const unsigned int M = 1000000007; int main() { int n, k; cin >> n >> k; vector<int> d(k); rep(i, k) { int m; cin >> m; rep(j, m) { int a; cin >> a; d[a - 1] = 1; } } int ans = 0; rep(i, n) if (d[i] == 0)++ ans; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; const unsigned int M = 1000000007; int main() { int n, k; cin >> n >> k; vector<int> d(n); rep(i, k) { int m; cin >> m; rep(j, m) { int a; cin >> a; d[a - 1] = 1; } } int ans = 0; rep(i, n) if (d[i] == 0)++ ans; cout << ans << endl; return 0; }
replace
7
8
7
8
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> vec(n, 1); for (int i = 0; i < k; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec.at(a) = 0; } } int ans = 0; for (int i = 0; i < n; i++) { ans += vec.at(i); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> vec(n, 1); for (int i = 0; i < k; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec.at(a - 1) = 0; } } int ans = 0; for (int i = 0; i < n; i++) { ans += vec.at(i); } cout << ans << 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 3) >= this->size() (which is 3)
p02688
C++
Runtime Error
#include "bits/stdc++.h" #include <cstring> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { int n, k; int ans = 0; cin >> n >> k; vector<int> flag_n(n); rep(i, k) { flag_n[i] = 0; } rep(i, k) { int tcnt; cin >> tcnt; rep(j, tcnt) { int temp; cin >> temp; if (flag_n[temp - 1] == 0) flag_n[temp - 1] = 1; } } rep(i, n) { if (flag_n[i] == 0) ans++; } cout << ans << endl; return 0; }
#include "bits/stdc++.h" #include <cstring> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { int n, k; int ans = 0; cin >> n >> k; vector<int> flag_n(n); rep(i, n) { flag_n[i] = 0; } rep(i, k) { int tcnt; cin >> tcnt; rep(j, tcnt) { int temp; cin >> temp; if (flag_n[temp - 1] == 0) flag_n[temp - 1] = 1; } } rep(i, n) { if (flag_n[i] == 0) ans++; } cout << ans << endl; return 0; }
replace
11
12
11
12
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { /* Input */ int N, K; cin >> N >> K; vector<bool> snukes(N); rep(i, N) snukes.at(i) = false; rep(i, K) { int d; cin >> d; rep(j, d) { int a; cin >> a; snukes.at(a - 1) = true; } } int ans = 0; rep(i, K) if (!snukes.at(i)) ans++; /* Output */ cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { /* Input */ int N, K; cin >> N >> K; vector<bool> snukes(N); rep(i, N) snukes.at(i) = false; rep(i, K) { int d; cin >> d; rep(j, d) { int a; cin >> a; snukes.at(a - 1) = true; } } int ans = 0; rep(i, N) if (!snukes.at(i)) ans++; /* Output */ cout << ans << endl; return 0; }
replace
22
23
22
23
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; void Main() { int n, k; cin >> n >> k; int d[k]; int a[n][n]; int count = 0; for (int i = 0; i < k; i++) { cin >> d[i]; // printf("%d\n", d[i]); for (int j = 0; j < d[i]; j++) { cin >> a[i][j]; // printf("%d ", a[i][j]); } } int s[n]; for (int i = 0; i < n; i++) { s[i] = i + 1; } for (int i = 0; i < k; i++) { for (int j = 0; j < d[i]; j++) { for (int l = 0; l < n; l++) { if (a[i][j] == s[l]) { s[l] = 0; } } } } for (int i = 0; i < n; i++) { if (s[i] != 0) count++; } printf("%d", count); } int main() { std::cout << std::fixed << std::setprecision(15); Main(); }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; void Main() { int n, k; cin >> n >> k; int d[k]; int a[k][n]; int count = 0; for (int i = 0; i < k; i++) { cin >> d[i]; // printf("%d\n", d[i]); for (int j = 0; j < d[i]; j++) { cin >> a[i][j]; // printf("%d ", a[i][j]); } } int s[n]; for (int i = 0; i < n; i++) { s[i] = i + 1; } for (int i = 0; i < k; i++) { for (int j = 0; j < d[i]; j++) { for (int l = 0; l < n; l++) { if (a[i][j] == s[l]) { s[l] = 0; } } } } for (int i = 0; i < n; i++) { if (s[i] != 0) count++; } printf("%d", count); } int main() { std::cout << std::fixed << std::setprecision(15); Main(); }
replace
13
14
13
14
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) v.begin(), v.end() #define PRINT(V) \ for (auto v : (V)) \ cout << v << " " const long long INF = 1LL << 60; using namespace std; void debug_out() { cout << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); } #ifdef _DEBUG #define debug(...) debug_out(__VA_ARGS__) #else #define debug(...) #endif int main() { int n, k; cin >> n >> k; vector<int> x(n); rep(i, n) { x[i] = 0; } rep(i, k) { int d; cin >> d; vector<int> a(d); rep(i, d) { cin >> a[i]; x[a[i]] = 1; } } int cnt = 0; rep(i, n) { if (x[i] == 0) { cnt++; } } cout << cnt; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) v.begin(), v.end() #define PRINT(V) \ for (auto v : (V)) \ cout << v << " " const long long INF = 1LL << 60; using namespace std; void debug_out() { cout << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); } #ifdef _DEBUG #define debug(...) debug_out(__VA_ARGS__) #else #define debug(...) #endif int main() { int n, k; cin >> n >> k; vector<int> x(n); rep(i, n) { x[i] = 0; } rep(i, k) { int d; cin >> d; vector<int> a(d); rep(i, d) { cin >> a[i]; x[a[i] - 1] = 1; } } int cnt = 0; rep(i, n) { if (x[i] == 0) { cnt++; } } cout << cnt; return 0; }
replace
31
32
31
32
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec1(N, 0); for (int i = 0; i < K; i++) { int d; cin >> d; vector<int> vec2(d); for (int j = 0; j < d; j++) { cin >> vec2.at(j); } for (int j = 0; j < d; j++) { vec1.at(vec2.at(j) - 1)++; } } int count = 0; for (int i = 0; i < K; i++) { if (vec1.at(i) == 0) { count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> vec1(N, 0); for (int i = 0; i < K; i++) { int d; cin >> d; vector<int> vec2(d); for (int j = 0; j < d; j++) { cin >> vec2.at(j); } for (int j = 0; j < d; j++) { vec1.at(vec2.at(j) - 1)++; } } int count = 0; for (int i = 0; i < N; i++) { if (vec1.at(i) == 0) { count++; } } cout << count << endl; }
replace
26
27
26
27
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b; vector<int> m(a + 1, 0); m[0] = 1; for (int i = 0; i < b; i++) { cin >> c; vector<int> n(c); for (int j = 0; j < c; j++) { cin >> n[i]; m[n[i]]++; } } int p = 0; for (int k = 0; k < a + 1; k++) { if (m[k] == 0) p++; } cout << p << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b; vector<int> m(a + 1, 0); m[0] = 1; for (int i = 0; i < b; i++) { cin >> c; vector<int> n(c); for (int j = 0; j < c; j++) { cin >> n[j]; m[n[j]]++; } } int p = 0; for (int k = 0; k < a + 1; k++) { if (m[k] == 0) p++; } cout << p << endl; }
replace
11
13
11
13
0
p02688
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; #define MOD 1000000007 // #define MOD 998244353 const double EPS = 1e-9; #define INF (1LL << 60) #define D double #define fs first #define sc second #define int long long #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i) #define REP(i, n) FOR(i, 0, (n)) #define RREP(i, n) RFOR(i, 0, (n)) #define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair<int, int> P; typedef vector<int> vec; typedef vector<vector<int>> mat; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.precision(20); int n, k; cin >> n >> k; vec d(k); mat a(k); REP(i, k) { cin >> d[k]; REP(j, d[k]) { int t; cin >> t; t--; a[i].push_back(t); } } vec b(n, 0); REP(i, a.size()) REP(j, a[i].size()) { b[a[i][j]]++; } int ans = 0; REP(i, n) { if (b[i] == 0) ans++; } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; #define MOD 1000000007 // #define MOD 998244353 const double EPS = 1e-9; #define INF (1LL << 60) #define D double #define fs first #define sc second #define int long long #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i) #define REP(i, n) FOR(i, 0, (n)) #define RREP(i, n) RFOR(i, 0, (n)) #define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair<int, int> P; typedef vector<int> vec; typedef vector<vector<int>> mat; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.precision(20); int n, k; cin >> n >> k; vec d(k); mat a(k); REP(i, k) { cin >> d[i]; REP(j, d[i]) { int t; cin >> t; t--; a[i].push_back(t); } } vec b(n, 0); REP(i, a.size()) REP(j, a[i].size()) { b[a[i][j]]++; } int ans = 0; REP(i, n) { if (b[i] == 0) ans++; } cout << ans << endl; return 0; }
replace
33
35
33
35
0
p02688
C++
Runtime Error
#include <cstdlib> #include <iostream> #include <vector> int main() { int N, K; std::cin >> N >> K; std::vector<int> okashi(N - 1, 0); for (int i = 0; i < K; i++) { int d; std::cin >> d; for (int j = 0; j < d; j++) { int A; std::cin >> A; okashi[A - 1]++; } } int ninzuu = 0; for (int i = 0; i < N; i++) { if (okashi[i] == 0) { ninzuu++; } } std::cout << ninzuu << std::endl; }
#include <cstdlib> #include <iostream> #include <vector> int main() { int N, K; std::cin >> N >> K; std::vector<int> okashi(N, 0); for (int i = 0; i < K; i++) { int d; std::cin >> d; for (int j = 0; j < d; j++) { int A; std::cin >> A; okashi[A - 1]++; } } int ninzuu = 0; for (int i = 0; i < N; i++) { if (okashi[i] == 0) { ninzuu++; } } std::cout << ninzuu << std::endl; }
replace
7
8
7
8
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; struct fast_ios { fast_ios() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) int main() { int n, k; char dat[n]; REP(i, n) { dat[i] = 0; } cin >> n >> k; REP(i, k) { int d; cin >> d; int a; REP(j, d) { cin >> a; dat[a - 1] = 1; } } int res = 0; REP(i, n) { if (dat[i] == 0) { res++; } } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; struct fast_ios { fast_ios() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) int main() { int n, k; char dat[10000]; REP(i, n) { dat[i] = 0; } cin >> n >> k; REP(i, k) { int d; cin >> d; int a; REP(j, d) { cin >> a; dat[a - 1] = 1; } } int res = 0; REP(i, n) { if (dat[i] == 0) { res++; } } cout << res << endl; }
replace
23
24
23
24
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main(void) { int N, K; cin >> N >> K; int d, a; int count = 0; vector<int> sunuke(N, 0); for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> a; sunuke.at(a - 1)++; } } for (int i = 0; i < K; i++) { if (sunuke.at(i) == 0) { count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { int N, K; cin >> N >> K; int d, a; int count = 0; vector<int> sunuke(N, 0); for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> a; sunuke.at(a - 1)++; } } for (int i = 0; i < N; i++) { if (sunuke.at(i) == 0) { count++; } } cout << count << endl; }
replace
15
16
15
16
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; // int choose2(ll x){ // return x*(x-1)/2;} const int INF = 1001001001; int main() { int N, K; int ans = 0; cin >> N >> K; vector<int> d(N); vector<int> A(N); vector<int> B(N); rep(i, N) B[i] = 0; rep(i, K) { cin >> d[i]; rep(j, d[i]) { cin >> A[j]; B[A[j] - 1]++; } } rep(i, N) { if (B[i] == 0) ans++; } cout << ans; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; // int choose2(ll x){ // return x*(x-1)/2;} const int INF = 1001001001; int main() { int N, K; int ans = 0; cin >> N >> K; vector<int> d(K); vector<int> A(N); vector<int> B(N); rep(i, N) B[i] = 0; rep(i, K) { cin >> d[i]; rep(j, d[i]) { cin >> A[j]; B[A[j] - 1]++; } } rep(i, N) { if (B[i] == 0) ans++; } cout << ans; }
replace
14
15
14
15
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0, N, K, d, a; cin >> N >> K; vector<bool> people(N, 1); for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> a; if (people.at(a - 1)) people.at(a - 1) = 0; } } for (int i = 0; i < K; i++) { if (people.at(i)) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0, N, K, d, a; cin >> N >> K; vector<bool> people(N, 1); for (int i = 0; i < K; i++) { cin >> d; for (int j = 0; j < d; j++) { cin >> a; if (people.at(a - 1)) people.at(a - 1) = 0; } } for (int i = 0; i < N; i++) { if (people.at(i)) ans++; } cout << ans << endl; }
replace
16
17
16
17
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> children; for (int i = 0; i < N; i++) children.at(i) = i + 1; for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int num; cin >> num; for (int k = 0; k < children.size(); k++) { if (children.at(k) == num) children.at(k) = 0; } } } int count; for (int i = 0; i < children.size(); i++) { if (children.at(i) != 0) count++; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> children(N); for (int i = 0; i < N; i++) children.at(i) = i + 1; for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int num; cin >> num; for (int k = 0; k < children.size(); k++) { if (children.at(k) == num) children.at(k) = 0; } } } int count; for (int i = 0; i < children.size(); i++) { if (children.at(i) != 0) count++; } cout << count << endl; }
replace
7
8
7
8
-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)
p02688
C++
Runtime Error
#include <iostream> #include <map> #include <math.h> #include <stdio.h> using namespace std; int N, K; int main() { cin >> N >> K; int d[K], A[K][N]; int su[N + 1]; int sum = 0; for (int i = 1; i <= N; i++) { su[i] = 1; } for (int i = 1; i <= K; i++) { cin >> d[i]; for (int j = 1; j <= d[i]; j++) { cin >> A[i][j]; } } for (int i = 1; i <= K; i++) { for (int j = 1; j <= d[i]; j++) { su[A[i][j]] = 0; } } for (int i = 1; i <= N; i++) { sum += su[i]; } cout << sum << endl; }
#include <iostream> #include <map> #include <math.h> #include <stdio.h> using namespace std; int N, K; int main() { cin >> N >> K; int d[K + 1], A[K + 1][N + 1]; int su[N + 1]; int sum = 0; for (int i = 1; i <= N; i++) { su[i] = 1; } for (int i = 1; i <= K; i++) { cin >> d[i]; for (int j = 1; j <= d[i]; j++) { cin >> A[i][j]; } } for (int i = 1; i <= K; i++) { for (int j = 1; j <= d[i]; j++) { su[A[i][j]] = 0; } } for (int i = 1; i <= N; i++) { sum += su[i]; } cout << sum << endl; }
replace
11
12
11
12
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> d(k); vector<int> ansv(n, 1); for (int i = 0; i < k; i++) { cin >> d.at(i); vector<int> a(d.at(i)); for (int j = 0; j < d.at(i); j++) { cin >> a.at(j); } for (int j = 0; j < d.at(i); j++) { ansv.at(a.at(j) - 1) = 0; } } int ans = 0; for (int i = 0; i < k; i++) { ans += ansv.at(i); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> d(k); vector<int> ansv(n, 1); for (int i = 0; i < k; i++) { cin >> d.at(i); vector<int> a(d.at(i)); for (int j = 0; j < d.at(i); j++) { cin >> a.at(j); } for (int j = 0; j < d.at(i); j++) { ansv.at(a.at(j) - 1) = 0; } } int ans = 0; for (int i = 0; i < n; i++) { ans += ansv.at(i); } cout << ans << endl; }
replace
22
23
22
23
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<bool> cnt(N); int d; int count = 0; for (int i = 0; i < K; i++) { cin >> d; vector<int> A(d); for (int j = 0; j < d; j++) { cin >> A.at(j); cnt.at(A.at(j) - 1) = true; } } for (int i = 0; i < K; i++) { if (cnt.at(i) == false) { count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<bool> cnt(N); int d; int count = 0; for (int i = 0; i < K; i++) { cin >> d; vector<int> A(d); for (int j = 0; j < d; j++) { cin >> A.at(j); cnt.at(A.at(j) - 1) = true; } } for (int i = 0; i < N; i++) { if (cnt.at(i) == false) { count++; } } cout << count << endl; }
replace
16
17
16
17
0
p02688
C++
Runtime Error
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; int d[k]; int ans = 0; map<int, int> mp; rep(i, n) { cin >> d[i]; int tmp[d[i]]; rep(j, d[i]) { cin >> tmp[j]; mp[tmp[j] - 1]++; } } for (auto p : mp) { ans++; } cout << n - ans; }
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; int d[k]; int ans = 0; map<int, int> mp; rep(i, k) { cin >> d[i]; int tmp[d[i]]; rep(j, d[i]) { cin >> tmp[j]; mp[tmp[j] - 1]++; } } for (auto p : mp) { ans++; } cout << n - ans; }
replace
20
21
20
21
-11
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const int mod = 1000000007; int main() { int n, k, i, d, j, x, c = 0; cin >> n >> k; int f[k]; for (i = 0; i < n; i++) f[i] = 0; for (i = 0; i < k; i++) { cin >> d; for (j = 0; j < d; j++) { cin >> x; f[x - 1] = 1; } } for (i = 0; i < n; i++) { if (f[i] == 0) c++; } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const int mod = 1000000007; int main() { int n, k, i, d, j, x, c = 0; cin >> n >> k; int f[n]; for (i = 0; i < n; i++) f[i] = 0; for (i = 0; i < k; i++) { cin >> d; for (j = 0; j < d; j++) { cin >> x; f[x - 1] = 1; } } for (i = 0; i < n; i++) { if (f[i] == 0) c++; } cout << c; return 0; }
replace
13
14
13
14
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define put(i) cout << fixed << i << endl using namespace std; using ll = long long; int main() { int n, k; cin >> n >> k; vector<int> d(k); map<int, int> mp; rep(i, k) { cin >> d[i]; int a[k][d[k]]; rep(j, d[i]) { cin >> a[i][j]; mp[a[i][j]]++; } } put(n - mp.size()); }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define put(i) cout << fixed << i << endl using namespace std; using ll = long long; int main() { int n, k; cin >> n >> k; vector<int> d(k); map<int, int> mp; rep(i, k) { cin >> d[i]; int a[k][d[i]]; rep(j, d[i]) { cin >> a[i][j]; mp[a[i][j]]++; } } put(n - mp.size()); }
replace
14
15
14
15
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll int64_t #define ALL(a) (a).begin(), (a).end() const ll mod = 1000000007; const ll LINF = 1e13; const ll LLINF = 1e18; const ll ALPHABET = 26; template <class T> void Swap(T &r, T &l) { T tmp = r; r = l; l = tmp; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; // for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい return is; } ll bi(ll num) { if (num == 1) return 1; ll ret = bi(num - 1); ret = (ret * num) % mod; return ret; } int main() { ll n, k; cin >> n >> k; vector<ll> d(n); // vector<vector<ll>> a(k); vector<ll> s(n, 0); for (ll i = 0; i < k; i++) { cin >> d[i]; for (ll j = 0; j < d[i]; j++) { ll a; cin >> a; s[a - 1]++; } } ll ans = 0; for (ll i = 0; i < n; i++) { if (s[i] == 0) ans++; } cout << ans; }
#include <bits/stdc++.h> using namespace std; #define ll int64_t #define ALL(a) (a).begin(), (a).end() const ll mod = 1000000007; const ll LINF = 1e13; const ll LLINF = 1e18; const ll ALPHABET = 26; template <class T> void Swap(T &r, T &l) { T tmp = r; r = l; l = tmp; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; // for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい return is; } ll bi(ll num) { if (num == 1) return 1; ll ret = bi(num - 1); ret = (ret * num) % mod; return ret; } int main() { ll n, k; cin >> n >> k; vector<ll> d(k); // vector<vector<ll>> a(k); vector<ll> s(n, 0); for (ll i = 0; i < k; i++) { cin >> d[i]; for (ll j = 0; j < d[i]; j++) { ll a; cin >> a; s[a - 1]++; } } ll ans = 0; for (ll i = 0; i < n; i++) { if (s[i] == 0) ans++; } cout << ans; }
replace
33
34
33
34
0
p02688
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K, ans = 0; cin >> N >> K; vector<int> vec(K + 1, 0); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec[a - 1] = 1; } } for (int i = 0; i < N; i++) { if (vec[i] == 0) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, K, ans = 0; cin >> N >> K; vector<int> vec(N, 0); for (int i = 0; i < K; i++) { int d; cin >> d; for (int j = 0; j < d; j++) { int a; cin >> a; vec[a - 1] = 1; } } for (int i = 0; i < N; i++) { if (vec[i] == 0) { ans++; } } cout << ans << endl; }
replace
6
7
6
7
0