답안 #1019479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019479 2024-07-10T23:13:40 Z SiliconSquared 봉쇄 시간 (IOI23_closing) C++17
0 / 100
1000 ms 25120 KB
using namespace std;
#include "closing.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#define ll long long
#define ld long double
#define INF 1000000000000000000

struct urcity{
    vector<pair<int,int>> v;
    urcity(){}
};
int sub1(int n,int x,int y,ll k,vector<int> U,vector<int> V, vector<int> W){
    vector<urcity> v;
    v.clear();
    v.resize(n);
    for (int i=0;i<n-1;i++){
        v[U[i]].v.push_back({V[i],W[i]});
        v[V[i]].v.push_back({U[i],W[i]});
    }
    int z=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    q.push({0,x});
    q.push({0,y});
    pair<ll,int> p;
    set<int> s;
    while (!q.empty()&&q.top().first<=k){
        p=q.top();
        q.pop();
        if (s.find(p.second)!=s.end()){continue;}
        s.insert(p.second);
        k-=p.first;
        z++;
        for (auto i:v[p.second].v){
            q.push({p.first+i.second,i.first});
        }
    }
    return z;
}

struct city{
    ll dl,dr;
    city(){}
};
int max_score(int n,int l,int r,ll m,vector<int> U,vector<int> V, vector<int> w){
    int z=sub1(n,l,r,m,U,V,w);
    if (l>r){swap(l,r);}
    vector<city> v;
    v.resize(n);
    v[l].dl=0;
    v[r].dr=0;
    for (int i=l+1;i<n;i++){v[i].dl=v[i-1].dl+w[i-1];}
    for (int i=r+1;i<n;i++){v[i].dr=v[i-1].dr+w[i-1];}
    for (int i=l-1;i>=0;i--){v[i].dl=v[i+1].dl+w[i];}
    for (int i=r-1;i>=0;i--){v[i].dr=v[i+1].dr+w[i];}
    vector<ll> g;
    g.push_back(0);
    for (int i=0;i<l;i++){g.push_back(v[i].dl);}
    for (int i=r+1;i<n;i++){g.push_back(v[i].dr);}
    sort(g.begin(),g.end());
    for (int i=2;i<(int)g.size();i++){g[i]=g[i-1]+g[i];}
    vector<ll> gg;
    for (int i=0;i<l;i++){gg.push_back(v[i].dr-v[i].dl);}
    for (int i=r+1;i<n;i++){gg.push_back(v[i].dl-v[i].dr);}
    sort(gg.begin(),gg.end());
    for (int i:gg){
        g.push_back(i+g[g.size()-1]);
    }
    for (int i=l;i<=r;i++){
        ll x=0;
        int k=g.size()-1;
        for (int j=l;j<i;j++){x+=v[j].dl;}
        for (int j=i;j<=r;j++){x+=v[j].dr;}
        for (int j=i;j<=r;j++){
            x-=v[j].dr;
            x+=max(v[j].dl,v[j].dr);
            while ((k>=0)&&((x+g[k])>m)){k--;}
            if (k==-1){break;}
            z=max(z,(r-l+1)+(j-i+1)+k);
        }
    }
    return z;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 25120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '19'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '19'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '19'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -