제출 #1038449

#제출 시각아이디문제언어결과실행 시간메모리
1038449Shayan86사다리꼴 (balkan11_trapezoid)C++14
100 / 100
114 ms26304 KiB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// Ofast, O0, O1, O2, O3, unroll-loops, fast-math, trapv

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define Mp          make_pair
#define sep         ' '
#define endl        '\n'
#define F	        first
#define S	        second
#define pb          push_back
#define SZ(x)       (int)x.size()
#define all(x)      (x).begin(),(x).end()
#define kill(res)	cout << res << '\n', exit(0);
#define set_dec(x)	cout << fixed << setprecision(x);
#define fast_io     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io     freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 2e5 + 50;
const ll Mod = 30013;

ll n;
pll res[N], fen[N];

vector<pair<pii, pii>> vec;
vector<int> up, down;
vector<pii> qu[N][2], bit;

pii merg(pii a, pii b){
    if(a.F > b.F) return a;
    else if(a.F < b.F) return b;
    else{
        int sum = a.S + b.S;
        if(sum >= Mod) sum -= Mod;
        return {a.F, sum};
    }
}

void upd(int x, pii y){
    for(; x <= n; x += x & (-x)) fen[x] = merg(fen[x], y);
}

pii get(int x){
    pii out = {0, 1};
    for(; x; x -= x & (-x)) out = merg(out, fen[x]);
    return out;
}

int main(){
    fast_io;
    
    cin >> n;

    for(int i = 0; i < n; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        vec.pb({{a, b}, {c, d}});
        up.pb(a); up.pb(b);
        down.pb(c); down.pb(d);
    }

    sort(all(up));
    up.resize(unique(all(up)) - up.begin());

    sort(all(down));
    down.resize(unique(all(down)) - down.begin());

    bit.pb({0, 0});
    for(int i = 0; i < n; i++){
        vec[i].F.F = lower_bound(all(up), vec[i].F.F) - up.begin() + 1;
        vec[i].F.S = lower_bound(all(up), vec[i].F.S) - up.begin() + 1;
        vec[i].S.F = lower_bound(all(down), vec[i].S.F) - down.begin() + 1;
        vec[i].S.S = lower_bound(all(down), vec[i].S.S) - down.begin() + 1;
        qu[vec[i].F.F][0].pb({vec[i].S.F, i});
        qu[vec[i].F.S][1].pb({vec[i].S.S, i});
        bit.pb({vec[i].S.S, vec[i].F.S});
    }

    sort(all(bit));

    for(int i = 0; i < N; i++){
        for(auto [x, id]: qu[i][0]){
            pii y = {x, 0};
            int idx = lower_bound(all(bit), y) - bit.begin();
            res[id] = get(idx - 1); res[id].F++;
        }
        for(auto [x, id]: qu[i][1]){
            pii y = {x, i};
            int idx = lower_bound(all(bit), y) - bit.begin();
            upd(idx, res[id]);
        }
    }

    pii ans = {0, 0};
    for(int i = 0; i < n; i++) ans = merg(ans, res[i]);

    cout << ans.F << sep << ans.S;

}

컴파일 시 표준 에러 (stderr) 메시지

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:90:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   90 |         for(auto [x, id]: qu[i][0]){
      |                  ^
trapezoid.cpp:95:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   95 |         for(auto [x, id]: qu[i][1]){
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...