답안 #1006874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006874 2024-06-24T09:27:25 Z De3b0o 봉쇄 시간 (IOI23_closing) C++17
0 / 100
1000 ms 26448 KB
#include "closing.h"
#include<bits/stdc++.h>
#include<random>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll n , x , y , k;
vector<pll> adj[200009];
ll vis[200009];
ll xx[200009];
ll yy[200009];
ll mx[200009];

int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    n=N;
    x=X;
    y=Y;
    k=K;
    for(int i = 0 ; n>i ; i++)
    {
        adj[i].clear();
        vis[i]=0;
    }
    for(int i = 0 ; n-1>i ; i++)
    {
        adj[U[i]].pb({V[i],W[i]});
        adj[V[i]].pb({U[i],W[i]});
    }
    ll d = 0;
    for(int i = x ; i>=0 ; i--)
    {
        xx[i]=d;
        if(i)
            d+=W[i-1];
    }
    d=0;
    for(int i = y ; n>i ; i++)
    {
        yy[i]=d;
        if(i<n-1)
            d+=W[i];
    }
    d=0;
    for(int i = x ; n>i ; i++)
    {
        xx[i]=d;
        if(i<n-1)
            d+=W[i];
    }
    d=0;
    for(int i = y ; i>=0 ; i--)
    {
        yy[i]=d;
        if(i)
            d+=W[i-1];
    }
    for(int i = 0 ; n>i ; i++)
        mx[i]=max(xx[i],yy[i]);
    for(int i = 1 ; n>i ; i++)
    {
        xx[i]+=xx[i-1];
        yy[i]+=yy[i-1];
        mx[i]+=mx[i-1];
        if(i==x)
            xx[i]=0;
        if(i==y)
            yy[i]=0;
    }
    ll ans = 0;
    for(int i = x ; n>i ; i++)
    {
        for(int j = y ; j>=0 ; j--)
        {
            for(int i1 = x ; i1>=0 ; i1--)
            {
                ll cost = 0;
                ll ans1 = i-i1+1 + y-j+1;
                if(i>y)
                    ans1+=i-y;
                if(j>=x)
                {
                    if(j<=i)
                    {
                        cost+=mx[i];
                        if(j)
                            cost-=mx[j-1];
                        if(y>i)
                        {
                            cost+=yy[y-1];
                            cost-=yy[i];
                        }
                        if(j>x)
                            cost+=xx[j-1];
                    }
                    else
                    {
                        cost+=xx[i];
                        cost+=yy[y-1];
                        if(j)
                            cost-=yy[j-1];
                    }
                    if(x)
                    {
                        cost+=xx[x-1];
                        if(i1)
                            cost-=xx[i1-1];
                    }
                }
                else
                {
                    cost+=mx[i];
                    if(j)
                        cost-=mx[j-1];
                    if(j)
                    {
                        cost+=xx[j-1];
                        ll idxl = min(i1,j);
                        if(idxl)
                            cost-=xx[idxl];
                    }
                    if(y>i)
                    {
                        cost+=yy[y-1];
                        cost-=yy[i];
                    }
                }
                if(cost>k)
                    continue;
                ll l = max(i+1,int(y+1)) , r = n-1;
                ll le = l-1;
                ll re = k-cost;
                while(l<=r)
                {
                    if(yy[mid]-yy[le]>re)
                        r=mid-1;
                    else
                        l=mid+1;
                }
                le++;
                ans1+=l-le;
                ans=max(ans,ans1);
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1047 ms 26448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 11100 KB Output is correct
2 Incorrect 2 ms 11196 KB 1st lines differ - on the 1st token, expected: '30', found: '32'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 11100 KB Output is correct
2 Incorrect 2 ms 11196 KB 1st lines differ - on the 1st token, expected: '30', found: '32'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 11100 KB Output is correct
2 Incorrect 2 ms 11196 KB 1st lines differ - on the 1st token, expected: '30', found: '32'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -