Submission #51071291
Source Code Expand
Copy
// फल की चिंता मत करो बालक, बस करते जाओ ||#include <bits/stdc++.h>#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/tree_policy.hpp>using namespace std;using namespace __gnu_pbds;#define int long long#define v64 vector<int>#define vp64 vector<pair<int, int>>#define forn(i, a, b) for (int i = a; i < b; i++)#define pqmin priority_queue<int, vector<int>, greater<int>>#define pqmax priority_queue<int>#define ln "\n"#define yy cout << "Yes" << ln#define nn cout << "No" << ln#define pi 3.14159265358979323846const int mod = 1e9 + 7;#define dbg cout << "debug" << ln;tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> T;// Ordered set functions user less_equal for multiset// it=s.find_by_order(x) (for index)
// फल की चिंता मत करो बालक, बस करते जाओ || #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define v64 vector<int> #define vp64 vector<pair<int, int>> #define forn(i, a, b) for (int i = a; i < b; i++) #define pqmin priority_queue<int, vector<int>, greater<int>> #define pqmax priority_queue<int> #define ln "\n" #define yy cout << "Yes" << ln #define nn cout << "No" << ln #define pi 3.14159265358979323846 const int mod = 1e9 + 7; #define dbg cout << "debug" << ln; tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> T; // Ordered set functions user less_equal for multiset // it=s.find_by_order(x) (for index) // s.order_of_key(x)(no of elements smaller than x) int fac[1000001]; void factorial() { fac[0] = fac[1] = 1; forn(i, 2, 1000001) { fac[i] = (fac[i - 1] * i) % mod; } } int pows[1000001]; bool done = 0; int power10(int n) { if (!done) { pows[0] = 1; for (int i = 1; i <= 1000000; i++) pows[i] = (pows[i - 1] * 10LL) % mod; done = 1; } return pows[n]; } vector<int> prime; void sieve() { prime.resize(1e6 + 1); for (int i = 0; i < prime.size(); i++) { prime[i] = i; } for (int i = 2; i <= 1e6; i++) { if (prime[i] == i) { for (int j = 2 * i; j <= 1e6; j += i) { prime[j] = i; } } } } v64 primefac(int n) { v64 res; while (n != prime[n]) { res.push_back(prime[n]); n /= prime[n]; } if (n != 1) res.push_back(n); return res; } int fastexpo(int a, int b, int m) { a %= m; int res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } int fastpow(int a, int b) { if (b == 0) return 1; int t = fastpow(a, b / 2); if (b % 2 == 0) return t * t; else return a * (t * t); } int inv(int n) { return fastexpo(n, mod - 2, mod); } int ncr(int n, int r) { if (r > n) return 0; // on factorial fun from main int a = fac[n]; int b = (fac[r] * fac[n - r]) % mod; int b1 = inv(b); return (a * b1) % mod; } // for inverse modulo (k^mod-2)%mod // by inforkc => don't use hashing instead use set and map #define itr list<int>::iterator void inforkc() { // Using linkedList or list stl int n; cin >> n; list<int> v; unordered_map<int, itr> mp; forn(i, 0, n) { int x; cin >> x; v.push_back(x); auto itr1 = prev(v.end()); mp[x] = itr1; } int q; cin >> q; while (q--) { int t, a, b; cin >> t; if (t == 1) { cin >> a >> b; itr x1 = mp[a]; // push next to x1 iterator itr it = v.emplace(++x1, b); mp[b] = it; } else { cin >> a; // delete a from list v.erase(mp[a]); mp.erase(a); } } for (auto i : v) { cout << i << " "; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // sieve(); // factorial(); int t_e_s_t = 1; while (t_e_s_t--) { inforkc(); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Insert or Erase |
User | invictus109 |
Language | C++ 20 (gcc 12.2) |
Score | 475 |
Code Size | 3774 Byte |
Status | AC |
Exec Time | 287 ms |
Memory | 34356 KB |
Compile Error
Main.cpp: In function ‘void sieve()’: Main.cpp:49:23: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] 49 | for (int i = 0; i < prime.size(); i++) | ~~^~~~~~~~~~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 475 / 475 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
min.txt | AC | 1 ms | 3524 KB |
random_01.txt | AC | 287 ms | 33528 KB |
random_02.txt | AC | 157 ms | 21236 KB |
random_03.txt | AC | 172 ms | 25456 KB |
random_04.txt | AC | 62 ms | 10940 KB |
random_05.txt | AC | 221 ms | 18420 KB |
random_06.txt | AC | 96 ms | 8852 KB |
random_07.txt | AC | 196 ms | 18332 KB |
random_08.txt | AC | 65 ms | 10432 KB |
random_09.txt | AC | 132 ms | 18352 KB |
random_10.txt | AC | 52 ms | 9024 KB |
random_11.txt | AC | 139 ms | 18252 KB |
random_12.txt | AC | 13 ms | 4168 KB |
random_13.txt | AC | 249 ms | 33536 KB |
random_14.txt | AC | 142 ms | 18424 KB |
random_15.txt | AC | 139 ms | 18248 KB |
random_16.txt | AC | 219 ms | 33660 KB |
random_17.txt | AC | 133 ms | 18300 KB |
random_18.txt | AC | 141 ms | 18324 KB |
random_19.txt | AC | 40 ms | 10668 KB |
random_20.txt | AC | 89 ms | 34356 KB |
random_21.txt | AC | 44 ms | 18380 KB |
sample_01.txt | AC | 1 ms | 3524 KB |
sample_02.txt | AC | 1 ms | 3440 KB |