제출 #1093001

#제출 시각아이디문제언어결과실행 시간메모리
1093001PieArmyRobot (JOI21_ho_t4)C++17
34 / 100
3063 ms323448 KiB
typedef long long ll; ll pie(ll army){return (1ll<<army);} #include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define endl '\n' #define mid ((left+right)>>1) const ll inf=2000000000000000005; const int sonsuz=2000000005; using namespace std; ll fpow(ll x,ll y,ll m=0){if(y<0){cout<<"powError";return -1;}if(m)x%=m;ll res=1;while(y>0){if(y&1)res*=x;x*=x;if(m){x%=m;res%=m;}y>>=1;}return res;} struct adj{ int x,c,idx; ll p; adj(int X,int C,int P,int IDX){ x=X; c=C; p=P; idx=IDX; } }; int n,m; int C[200001],P[200001]; set<pair<pair<int,ll>,pair<int,int>>>komsu[100001]; map<int,ll>mp[100001]; ll vis[300001]; void code(){ cin>>n>>m; for(int i=1;i<=m;i++){ int x,y; cin>>x>>y>>C[i]>>P[i]; komsu[x].insert({{y,P[i]},{C[i],i}}); komsu[y].insert({{x,P[i]},{C[i],i}}); mp[x][C[i]]+=P[i]; mp[y][C[i]]+=P[i]; } for(ll &x:vis) x=-1; priority_queue<pair<ll,pair<int,int>>>pq; pq.push({0,{1,0}}); while(pq.size()){ ll cos=-pq.top().fr; int pos=pq.top().sc.fr,idx=pq.top().sc.sc; pq.pop(); if(idx){ if(vis[n+idx]!=-1)continue; vis[n+idx]=cos; } else{ if(vis[pos]!=-1)continue; vis[pos]=cos; } if(pos==n){ cout<<cos; return; } vector<pair<pair<int,ll>,pair<int,int>>>sil; for(auto x:komsu[pos]){ if(idx==x.sc.sc)continue; if(vis[x.fr.fr]==-1){ pq.push({-(cos+mp[pos][x.sc.fr]-(C[idx]==x.sc.fr?P[idx]:0)-x.fr.sc),{x.fr.fr,0}}); } else{ sil.pb(x); } if(vis[n+x.sc.sc]!=-1){ if(sil.size()==0||sil.back()!=x){ sil.pb(x); } continue; } pq.push({-(cos+x.fr.sc),{x.fr.fr,x.sc.sc}}); } for(auto x:sil){ komsu[pos].erase(x); } } cout<<-1; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);} int t=1; if(!t)cin>>t; while(t--){code();cout<<endl;} return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:87:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |  bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:87:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |  bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...