답안 #322038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
322038 2020-11-13T23:57:20 Z fivefourthreeone Job Scheduling (IOI19_job) C++17
7 / 100
252 ms 13796 KB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(auto i=(a);i<(b); ++i)
#define uwu(i,a, b) for(auto i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = atan(1);
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
vector<int> adj[mxN];
int p[mxN];
int n;
int dsu[mxN];
bool done[mxN];
bool bad[mxN];
bool cmp(array<int, 3> a, array<int, 3> b) {
    if(a[0]*b[1]==a[1]*b[0]) {
        return a[2] < b[2];
    }
    return a[0]*b[1] > a[1]*b[0];
}
int find(int a) {
    return a==dsu[a] ? a : dsu[a] = find(dsu[a]);
}
bool merge(int a, int b) {
    a = find(a);
    b = find(b);
    if(a==b)return false;
    dsu[b] = a;
    bad[b] = true;
    return true;
}
ll scheduling_cost(vector<int> par, vector<int> u, vector<int> d) {
    n = par.size();
    iota(dsu, dsu+n, 0);
    priority_queue<array<int, 3>, vector<array<int, 3>>, decltype(&cmp)> pq(cmp);
    owo(i, 0, n) {
        pq.push({d[i], u[i], i});
    }
    ll res = 0;
    ll curr = 0;
    while(!pq.empty()) {
        auto[t, cst, id] = pq.top();
        pq.pop();
        //cout<<t<<" "<<cst<<" "<<id<<endl;
        if(tie(t, cst)!=tie(d[id], u[id]) || done[id] || bad[id])continue;
        if(par[id]==-1 || done[find(par[id])]) {
            curr+=t;
            res+=cst*curr;
            done[id] = true;
            continue;
        }
        int nxt = find(par[id]);
        res-=t*u[nxt];
        u[nxt]+=cst;
        d[nxt]+=t;
        merge(nxt, id);
        pq.push({d[nxt], u[nxt], nxt});
    }
    return res;
}
/*vector<int> PAR, U, D;
int N;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>N;
    PAR.resize(N);
    U.resize(N);
    D.resize(N);
    owo(i, 0, N) {
        cin>>PAR[i];
    }
    owo(i, 0, N) {
        cin>>U[i];
    }
    owo(i, 0, N) {
        cin>>D[i];
    }
    cout<<scheduling_cost(PAR, U, D);
    return 0;
}*/

Compilation message

job.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
job.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Correct 4 ms 4972 KB Output is correct
3 Incorrect 4 ms 4972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Correct 4 ms 4972 KB Output is correct
3 Correct 4 ms 4972 KB Output is correct
4 Correct 143 ms 13796 KB Output is correct
5 Correct 149 ms 13796 KB Output is correct
6 Correct 151 ms 13796 KB Output is correct
7 Correct 154 ms 13668 KB Output is correct
8 Correct 145 ms 13688 KB Output is correct
9 Correct 148 ms 13668 KB Output is correct
10 Correct 138 ms 13668 KB Output is correct
11 Correct 145 ms 13796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Correct 4 ms 4972 KB Output is correct
3 Correct 4 ms 4972 KB Output is correct
4 Correct 4 ms 5100 KB Output is correct
5 Incorrect 9 ms 5612 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Incorrect 252 ms 13796 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4972 KB Output is correct
2 Correct 4 ms 4972 KB Output is correct
3 Incorrect 4 ms 4972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Correct 4 ms 4972 KB Output is correct
3 Incorrect 4 ms 4972 KB Output isn't correct
4 Halted 0 ms 0 KB -