結果
| 問題 | 
                            No.1320 Two Type Min Cost Cycle
                             | 
                    
| コンテスト | |
| ユーザー | 
                             vjudge1
                         | 
                    
| 提出日時 | 2025-09-30 12:33:11 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,166 bytes | 
| コンパイル時間 | 3,681 ms | 
| コンパイル使用メモリ | 284,320 KB | 
| 実行使用メモリ | 34,684 KB | 
| 最終ジャッジ日時 | 2025-09-30 12:33:20 | 
| 合計ジャッジ時間 | 8,188 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 29 WA * 28 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
int T,ans=1e18,n,m;
struct aaaa{
	int u,t;
	bool operator <(const aaaa &a)const{
		return t<a.t;
	}
	bool operator >(const aaaa &a)const{
		return t>a.t;
	}
};
vector<int>v[2010];
int d[2010][2010];
int dis[2010],mp[2010];
priority_queue<aaaa,vector<aaaa>,greater<aaaa> >q;
void dij(int st){
	while(!q.empty())q.pop();
	for(int x=1;x<=n;x++){
		dis[x]=1e15;mp[x]=0;
	}
	dis[st]=0;
	q.push({st,0});
	while(!q.empty()){
		aaaa sx=q.top();
		q.pop();
		if(mp[sx.u]==1)continue;
		mp[sx.u]=1;
		for(auto y:v[sx.u]){
			if(d[sx.u][y]==0)continue;
			int val=d[sx.u][y];
			if(dis[sx.u]+val<dis[y]){
				dis[y]=dis[sx.u]+val;
				q.push({y,dis[y]});
			}
		}
	}
}
signed main(){
	cin>>T;
	cin>>n>>m;
	for(int x=1;x<=m;x++){
		int u,w,t;
		cin>>u>>w>>t;
		if(T==0){
			d[u][w]=d[w][u]=t;
			v[u].push_back(w);
			v[w].push_back(u);
		}
		else{
			v[u].push_back(w);
			d[u][w]=t;
		}
	}
	for(int x=1;x<=n;x++){
		for(int y=1;y<=n;y++){
			if(d[x][y]!=0){
				int p=d[y][x],qq=d[x][y];
				d[y][x]=d[x][y]=0;
				dij(y);
				ans=min(ans,dis[x]+qq);
				d[y][x]=p,d[x][y]=qq;
			}
		}
	}
	cout<<ans<<endl;
}
            
            
            
        
            
vjudge1