Submission #995943

# Submission time Handle Problem Language Result Execution time Memory
995943 2024-06-10T05:13:48 Z irmuun Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 20828 KB
#include<bits/stdc++.h>
#include "closing.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int max_score(int N,int X,int Y,ll K,vector<int>U,vector<int>V,vector<int>W){
    if(X>Y) swap(X,Y);
    vector<pair<int,int>>adj[N];
    for(int i=0;i<N-1;i++){
        adj[U[i]].pb({V[i],W[i]});
        adj[V[i]].pb({U[i],W[i]});
    }
    ll D[N];
    D[0]=0;
    for(int i=1;i<N;i++){
        for(auto [j,w]:adj[i]){
            if(j==i-1){
                D[i]=D[i-1]+w;
            }
        }
    }
    function <ll(int,int)> calc=[&](int i,int j){
        if(i>j) swap(i,j);
        return D[j]-D[i];
    };
    // check all interval that is reacheble from both
    vector<ll>v;
    int ans=0;
    for(int l=0;l<N;l++){
        for(int r=l;r<N;r++){
            if(r<X||l>Y) continue;//not possible
            ll total=0;
            int cnt=0;
            bool ok=true;
            for(int i=l;i<=r;i++){
                total+=max(calc(i,X),calc(i,Y));
                cnt+=2;
                if(total>K) ok=false;
            }
            for(int i=X;i<l;i++){
                total+=calc(i,X);
                cnt++;
                if(total>K) ok=false;
            }
            for(int i=Y;i>r;i--){
                total+=calc(i,Y);
                cnt++;
                if(total>K) ok=false;
            }
            if(!ok){
                continue;
            }
            for(int i=0;i<min(X,l)-1;i++){
                v.pb(calc(X,i));
            }
            for(int i=max(r,Y)+1;i<N;i++){
                v.pb(calc(Y,i));
            }
            sort(all(v));
            for(int i=0;i<v.size();i++){
                if(total+v[i]<=K){
                    total+=v[i];
                    cnt++;
                }
            }
            ans=max(ans,cnt);
            v.clear();
        }
    }
    for(int i=0;i<N;i++){
        v.pb(min(calc(i,X),calc(i,Y)));
    }
    sort(all(v));
    int cnt=0;
    ll total=0;
    for(int i=0;i<N;i++){
        if(total+v[i]<=K){
            total+=v[i];
            cnt++;
        }
    }
    ans=max(ans,cnt);
    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:67:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             for(int i=0;i<v.size();i++){
      |                         ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 1093 ms 20828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '74', found: '73'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '74', found: '73'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '74', found: '73'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 0 ms 348 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 0 ms 348 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 0 ms 348 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 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -