답안 #381988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381988 2021-03-26T08:39:49 Z kartel Vepar (COCI21_vepar) C++14
0 / 70
1500 ms 78828 KB
#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 = 1e7 + 50;

vector <int> v;
int pr[N];
int cnt[N], cnt2[N], t[N], T[N];

int upd1(int v, int val) {for (; v < N; v = (v | (v + 1))) t[v] += val;}
int upd2(int v, int val) {for (; v < N; v = (v | (v + 1))) T[v] += val;}

int get1(int v) {int res = 0; for (; v >= 0; v = (v & (v + 1)) - 1) res += t[v]; return res;}
int get2(int v) {int res = 0; for (; v >= 0; v = (v & (v + 1)) - 1) res += T[v]; return res;}

int calc2(int l, int r) {
    return (get2(r) - get2(l - 1));
}

int calc1(int l, int r) {
    return (get1(r) - get1(l - 1));
}

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (calc1(a, b) > calc1(c, d)) {
        cout << "NE" << el;
        return;
    }

    if (calc2(a, b) > calc2(c, d)) {
        cout << "NE" << el;
        return;
    }

    cout << "DA" << 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();

    int q;
    cin >> q;

    for (int i = 2; i <= 1e7; i++) {
        if (pr[i]) {
            continue;
        }

        cnt[i] = 1;
        cnt2[i] = 1;

        for (ll j = i * 2; j <= 1e7; j += i) {
            cnt[j]++;
            cnt2[j] += j / i;
        }
    }

    for (int i = 2; i <= 1e7; i++) {
        upd1(i, cnt[i]);
        upd2(i, cnt2[i]);
    }

    while (q--) {
        solve();
    }
}


/*

7
4 6 7 2 3 1 5
*/

Compilation message

Main.cpp: In function 'int upd1(int, int)':
Main.cpp:38:72: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | int upd1(int v, int val) {for (; v < N; v = (v | (v + 1))) t[v] += val;}
      |                                                                        ^
Main.cpp: In function 'int upd2(int, int)':
Main.cpp:39:72: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | int upd2(int v, int val) {for (; v < N; v = (v | (v + 1))) T[v] += val;}
      |                                                                        ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1591 ms 78572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1582 ms 78572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1585 ms 78572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1588 ms 78700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1572 ms 78828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 78572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1595 ms 78572 KB Time limit exceeded
2 Halted 0 ms 0 KB -