Submission #1006780

# Submission time Handle Problem Language Result Execution time Memory
1006780 2024-06-24T08:32:07 Z De3b0o Closing Time (IOI23_closing) C++17
9 / 100
1000 ms 1244660 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];
vector<pll> v , xx , yy;
vector<ll> c;

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;
    v.clear();
    xx.clear();
    yy.clear();
    c.clear();
    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.pb({d,x-i+1});
        if(i)
            d+=W[i-1];
    }
    d=0;
    for(int i = y ; n>i ; i++)
    {
        yy.pb({d,i-y+1});
        if(i<n-1)
            d+=W[i];
    }
    for(auto it1 : xx)
        for(auto it2 : yy)
            v.pb({it1.F+it2.F,it1.S+it2.S});
    sort(v.begin(),v.end());
    ll mx = 0;
    for(auto it : v)
    {
        mx=max(mx,it.S);
        c.pb(mx);
    }
    ll ans = 0;
    ll fcost = 0;
    for(int i = x ; n>i ; i++)
    {
        for(int j = y ; j>=0 ; j--)
        {
            for(int i1 = x ; i1>=0 ; i1--)
            {
                for(int i2 = y ; n>i2 ; i2++)
                {
                    ll vs[n];
                    memset(vs,-1,sizeof(vs));
                    d=0;
                    for(int h = x ; i>=h ; h++)
                    {
                        vs[h]=max(vs[h],d);
                        if(h<n-1)
                            d+=W[h];
                    }
                    d=0;
                    for(int h = y ; h>=j ; h--)
                    {
                        vs[h]=max(vs[h],d);
                        if(h)
                            d+=W[h-1];
                    }
                    d=0;
                    for(int h = x ; h>=i1 ; h--)
                    {
                        vs[h]=max(vs[h],d);
                        if(h)
                            d+=W[h-1];
                    }
                    d=0;
                    for(int h = y ; i2>=h ; h++)
                    {
                        vs[h]=max(vs[h],d);
                        if(h<n-1)
                            d+=W[h];
                    }
                    ll cost = 0;
                    ll ans1 = i-i1+1 + i2-j+1;
                    for(int i = 0 ; n>i ; i++)
                    {
                        if(vs[i]!=-1)
                        {
                            cost+=vs[i];
                        }
                    }
                    if(cost>k)
                        continue;
                    ans=max(ans,ans1);
                }
            }
        }
    }
    return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:75:8: warning: unused variable 'fcost' [-Wunused-variable]
   75 |     ll fcost = 0;
      |        ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 1244660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 41 ms 6492 KB Output is correct
7 Correct 41 ms 6492 KB Output is correct
8 Correct 12 ms 6492 KB Output is correct
9 Correct 4 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 41 ms 6492 KB Output is correct
7 Correct 41 ms 6492 KB Output is correct
8 Correct 12 ms 6492 KB Output is correct
9 Correct 4 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 162 ms 6492 KB Output is correct
13 Correct 121 ms 6548 KB Output is correct
14 Correct 336 ms 6492 KB Output is correct
15 Correct 123 ms 6532 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 12 ms 6748 KB Output is correct
19 Execution timed out 1026 ms 8144 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 41 ms 6492 KB Output is correct
7 Correct 41 ms 6492 KB Output is correct
8 Correct 12 ms 6492 KB Output is correct
9 Correct 4 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 162 ms 6492 KB Output is correct
13 Correct 121 ms 6548 KB Output is correct
14 Correct 336 ms 6492 KB Output is correct
15 Correct 123 ms 6532 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 12 ms 6748 KB Output is correct
19 Execution timed out 1026 ms 8144 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -