Submission #980002

# Submission time Handle Problem Language Result Execution time Memory
980002 2024-05-11T19:09:40 Z vjudge1 Closing Time (IOI23_closing) C++17
0 / 100
742 ms 2097152 KB
#include "closing.h"
using namespace std;
#include <bits/stdc++.h>
#define pb push_back

using lli=long long;
#define deb(x) cout<<#x<<": "<<x<<endl;
int  max_score(int N, int X, int Y, long long K,
              vector<int> U, vector<int> V, vector<int> W)
{
      lli ans=0;
    vector<vector<pair<lli,lli>>> adj (N);
    vector<vector<lli>> mat (N, vector<lli> (N, -1));
    for(lli i=0; i<N-1; ++i){
        adj[U[i]].pb({V[i], W[i]});
        adj[V[i]].pb({U[i], W[i]});
        mat[U[i]][V[i]]=W[i];
        mat[V[i]][U[i]]=W[i];
    }
   
    lli init=0;
    lli last=0;
    lli ant=0;
    while(adj[init].size()==2){
        if(adj[init][0].first!=ant){
            ant=init;
            init=adj[init][0].first;
        }
        else{
            ant=init;
            init=adj[init][1].first;
        }
    }
    ant=init;/*
    last=adj[init][0].first;
    while(adj[last].size()==2){
        if(adj[last][0].first!=ant){
            ant=last;
            last=adj[last][0].first;
        }
        else{
            ant=last;
            last=adj[last][1].first;
        }
    }
    
    vector<lli> ord;
    lli rec=init;
    ant=init; 
    while(rec!=last){
    //    cout<<"rec: "<<rec<<endl;
        ord.pb(rec);
        if(adj[rec][0].first!=ant){
            ant=rec;
            rec=adj[rec][0].first;
        }
        else{
            ant=rec;
            rec=adj[rec][1].first;
        }
    }
    ord.pb(rec);
    vector<lli> numb(N);
    for(lli i=0; i<N; ++i){
        numb[ord[i]]=i;
    }
    if(numb[X]>numb[Y]){
        swap(X,Y);
    }
  
 
    for(lli i=numb[X]; i>=0; --i){
        vector<lli> values (N, 0);
        lli cont=K;
       
        for(lli a=numb[X]-1; a>=i; --a){
            values[a]=values[a+1]+mat[ord[a+1]][ord[a]];
            cont-=values[a];
         
            
        }
        if(cont<0) break;
        lli ayuda=cont;
        for(lli j=numb[X]; j<N; ++j){
          
            cont=ayuda;
            
            for(lli a=numb[X]+1; a<=j; ++a){
               
                values[a]=values[a-1]+mat[ord[a-1]][ord[a]];
                
                
                cont-=values[a];
              
            }
            if(cont<0) break;
            lli aux=j-i+1;
            priority_queue<pair<lli,lli>, vector<pair<lli,lli>>, greater<pair<lli,lli>>> pq;
            vector<bool> visited (N, false);
            pq.push({0, numb[Y]});
            
            while(!pq.empty()){
                lli a=pq.top().first;
                lli b=pq.top().second;
           
                pq.pop();
                if(visited[b]) continue;
                visited[b]=true;
                if(cont>=a){
                    cont-=a;
                    aux++;
                    if(b+1<N && !visited[b+1]){
                        pq.push({max(a+mat[ord[b]][ord[b+1]]-values[b+1],0ll), b+1});
                    }
                    if(b-1>=0 && !visited[b-1]){
                        pq.push({max(a+mat[ord[b]][ord[b-1]]-values[b-1],0ll), b-1});
                    }
                }
                else{
                    break;
                }
            }
           
            ans=max(ans, aux);
          
        }
     
    }*/
   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:22:9: warning: unused variable 'last' [-Wunused-variable]
   22 |     lli last=0;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 742 ms 2097152 KB Execution killed with signal 9
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: '3', found: '0'
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: '3', found: '0'
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: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -