제출 #844843

#제출 시각아이디문제언어결과실행 시간메모리
8448438pete8Robot (JOI21_ho_t4)C++17
100 / 100
520 ms64240 KiB
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<unordered_map> #include <queue> #include<cstring> #include<limits.h> #include<cmath> #include<set> #include<algorithm> #include<bitset> //#include "supertrees.h" using namespace std; #define ll long long #define f first #define endl "\n" #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define pb push_back #define all(x) x.begin(),x.end() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); using namespace std; #define int long long const int mxn=1e5,mod=998244353,lg=20,root=80,inf=1e18; void setIO(string name) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } map<int,int>mp[mxn+10]; map<int,int>mn[mxn+10]; vector<ppii>adj[mxn+10]; int dist[mxn+10]; bitset<mxn+10>vis; int t[mxn+10]; int32_t main(){ fastio int n,m;cin>>n>>m; for(int i=0;i<m;i++){ int u,v,c,w;cin>>u>>v>>c>>w; adj[u].pb({v,{c,w}}); adj[v].pb({u,{c,w}}); mp[u][c]+=w; mp[v][c]+=w; } fill(dist,dist+n+1,inf); priority_queue<pii,vector<pii>,greater<pii>>pq; pq.push({0,1}); dist[1]=0; pii tmp; while(!pq.empty()){ int cur=pq.top().s; if(vis[cur]){ pq.pop(); continue; } vis[cur]=true; pq.pop(); //cout<<cur<<'\n'; for(auto i:adj[cur]){ if(mn[i.f].find(i.s.f)==mn[i.f].end())mn[i.f][i.s.f]=dist[cur]; int cost=dist[cur]; if(mn[cur].find(i.s.f)!=mn[cur].end())cost=mn[cur][i.s.f]; cost+=(mp[cur][i.s.f]-i.s.s); cost=min(cost,dist[cur]+i.s.s); if(dist[i.f]>cost){ dist[i.f]=cost; pq.push({dist[i.f],i.f}); } } } cout<<((dist[n]==inf)?-1:dist[n]); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:32:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:33:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...