Submission #382027

#TimeUsernameProblemLanguageResultExecution timeMemory
382027kartelVepar (COCI21_vepar)C++14
30 / 70
149 ms77932 KiB
#include <bits/stdc++.h> #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) //#include <time.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #define F first #define S second #define pb push_back //#define M ll(1e9 + 7) #define M ll(998244353) #define sz(x) (int)x.size() #define re return #define oo ll(1e18) #define el '\n' #define pii pair <int, int> #define all(x) (x).begin(), (x).end() #define arr_all(x, n) (x + 1), (x + 1 + n) #define vi vector<int> #define eps (ld)1e-9 using namespace std; typedef long long ll; //using namespace __gnu_pbds; //typedef tree <ll, null_type, less_equal <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef double ld; typedef unsigned long long ull; typedef short int si; const int N = 1e5 + 50; vector <int> primes; int pr[N]; struct tree { tree *L, *R; int sum; tree () { L = R = NULL; sum = 0; } void upd(int l, int r, int ps, int val) { if (l == r) { sum = val; } else { int md = (l + r) >> 1; if (ps <= md) { if (L == NULL) { L = new tree(); } L -> upd(l, md, ps, val); } else { if (R == NULL) { R = new tree(); } R -> upd(md + 1, r, ps, val); } sum = 0; if (L != NULL) { sum += L -> sum; } if (R != NULL) { sum += R -> sum; } } } int get(int l, int r, int tl, int tr) { if (l == tl && r == tr) { return sum; } if (l > r || tl > tr || tl > r || l > tr) { return 0; } int md = (l + r) >> 1; int cur = 0; if (L != NULL) { cur += L -> get(l, md, tl, min(md, tr)); } if (R != NULL) { cur += R -> get(md + 1, r, max(md + 1, tl), tr); } return cur; } }; tree t[(int)7e5]; void solve() { int a, b, c, d; cin >> a >> b >> c >> d; bool good = 1; for (int i = 0; i < sz(primes); i++) { int inab = t[i].get(1, (int)1e5, a, b); if (inab == 0) { continue; } int incd = t[i].get(1, (int)1e5, c, d); if (incd < inab) { good = 0; break; } } cout << (good ? "DA" : "NE") << el; } int main() { // mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // in("toys.in"); // out("toys.out"); // in("input.txt"); // out("output.txt"); // cerr.precision(9); cerr << fixed; // clock_t tStart = clock(); for (int i = 2; i <= (int)1e5; i++) { if (pr[i]) { continue; } primes.pb(i); for (ll j = i * 1ll * i; j <= (int)1e5; j += i) { pr[j] = 1; } } for (int i = 0; i < sz(primes); i++) { int x = primes[i]; for (int j = x; j <= (int)1e5; j += x) { int y = j, cnt = 0; while (y % x == 0) { y /= x; cnt++; } t[i].upd(1, 1e5, j, cnt); } } int q; cin >> q; while (q--) { solve(); } } /* 7 4 6 7 2 3 1 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...