Submission #941934

# Submission time Handle Problem Language Result Execution time Memory
941934 2024-03-09T18:32:33 Z Maite_Morale Robot (JOI21_ho_t4) C++14
0 / 100
100 ms 27040 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 100005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
 
ll  m,n,ans=oo;
vll pass[MAX],node[MAX];
vector<pair<pll,pll>> v[MAX];
ll distra(ll x,ll y){
    priority_queue<pair<ll,pll>> q;
    q.push({0,{x,-1}});
    while(!q.empty()){
        pair<ll,pll> u=q.top();q.pop();
       // if(u.S.S>=0)cout<<u.S.F<<" "<<v[u.S.F][u.S.S].F.F<<": "<<pass[u.S.F][u.S.S]<<" "<<-u.F<<"\n";
        //else        cout<<u.S.F<<"-1 :0 "<<-u.F<<"\n";
        if(u.S.S>=0 && pass[u.S.F][u.S.S]!=0)continue;
        if(u.S.S>=0)pass[u.S.F][u.S.S]=1;
        if(u.S.F==y)return -u.F; 
        ll c=0;
        for(auto w : v[u.S.F]){
            if(u.S.S==c){c++;continue;}
            if(pass[w.F.F][node[u.S.F][c]]!=0){c++;continue;}
          //  cout<<"    "<<w.F.F<<" "<<v[w.F.F][node[u.S.F][c]].F.F<<" ";
            if(u.S.S>=0 && v[u.S.F][u.S.S].F.S==w.F.S){
                q.push({u.F-min(w.S.F,w.S.S-w.S.F-v[u.S.F][u.S.S].S.F),{w.F.F,node[u.S.F][c]}});
                cout<<-u.F+min(w.S.F,w.S.S-w.S.F-v[u.S.F][u.S.S].S.F)<<"\n";
            }
            else {
                q.push({u.F-min(w.S.F,w.S.S-w.S.F),{w.F.F,node[u.S.F][c]}});
             //   cout<<-u.F+min(w.S.F,w.S.S-w.S.F)<<".\n";
            }                                     
            c++;
        }
    }
return -1;
}
int main(){
    cin>>n>>m;ll a1,a2,a3,a4;
    for(int i=0;i<m;i++){
        cin>>a1>>a2>>a3>>a4;
        v[a1].push_back({{a2,a3},{a4,0}});
        v[a2].push_back({{a1,a3},{a4,0}});
        node[a1].push_back(v[a2].size()-1);
        node[a2].push_back(v[a1].size()-1);
    }
    for(int i=1;i<=n;i++){
        pass[i].assign(v[i].size()+5,0);
        map<ll,ll> mp;
        for(auto w : v[i]){
            mp[w.F.S]+=w.S.F;
        }
        for(int j=0;j<v[i].size();j++){
            v[i][j].S.S=mp[v[i][j].F.S];
        }
    }
    cout<<distra(1,n);
return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int j=0;j<v[i].size();j++){
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 2 ms 7260 KB Output is correct
3 Incorrect 2 ms 7260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 27040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 2 ms 7260 KB Output is correct
3 Incorrect 2 ms 7260 KB Output isn't correct
4 Halted 0 ms 0 KB -