답안 #568779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568779 2022-05-26T07:57:50 Z zaneyu Reconstruction Project (JOI22_reconstruction) C++14
7 / 100
2049 ms 27980 KB
/*input
3 4
1 2 1
1 2 4
2 3 2
2 3 4
4
1
2
3
4
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=5e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-6;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<P.f<<' '<<P.s;
    return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
    REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?" ":"");
    return out;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    a%=MOD;
    if(a==0) return 0;
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
int par[maxn];
int find(int u){
    if(par[u]==u) return u;
    return par[u]=find(par[u]);
}
void merge(int a,int b){
    a=find(a),b=find(b);
    if(a==b) return;
    par[a]=b;
}
vector<int> vv[maxn];
bool flp[maxn];
int cur[maxn];
int main(){
    int n,m;
    cin>>n>>m;
    REP(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        vv[a].pb(c);
    }
    vector<pii> turn;
    ll s=0;
    REP(i,n-1){
        sort(ALL(vv[i]));
        REP(j,sz(vv[i])){
            turn.pb({vv[i][j],i});
            if(j!=sz(vv[i])-1){
                turn.pb({(vv[i][j]+vv[i][j+1]+1)/2,i});
            }
        }
        s+=vv[i][0];
    }
    sort(ALL(turn));
    int q;
    cin>>q;
    int p=0;
    ll tot=-(n-1);
    while(q--){
        int x;
        cin>>x;
        while(p<sz(turn) and turn[p].f<=x){
            int z=turn[p].s;
            if(flp[z]){
                s+=vv[z][cur[z]];
                cur[z]++;
                s+=vv[z][cur[z]];
                tot-=2;
            }
            else{
                s-=2*vv[z][cur[z]];
                tot+=2;
            }
            flp[z]=!flp[z];
            ++p;
        }
        cout<<s+tot*x<<'\n';
    }
} 
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12060 KB Output is correct
2 Correct 7 ms 11972 KB Output is correct
3 Correct 7 ms 11988 KB Output is correct
4 Correct 1857 ms 25396 KB Output is correct
5 Correct 1845 ms 25828 KB Output is correct
6 Correct 1783 ms 25828 KB Output is correct
7 Correct 1864 ms 27840 KB Output is correct
8 Correct 1790 ms 27908 KB Output is correct
9 Correct 1932 ms 27712 KB Output is correct
10 Correct 2049 ms 25848 KB Output is correct
11 Correct 1974 ms 27980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -