提出 #66362019


ソースコード 拡げる

#include<fstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<cmath>
#include<numbers>
#include<algorithm>
#include<string>
#include<set>
#include<stack>
#include<random>
#include<bitset>
#include<cassert>
#include<exception>

using namespace std;
using ll=long long;
using uset=unordered_set<long long>;

int H,W;
vector<string> strs;

struct point{
	int x,y;
	point():x(0),y(0){}
	point(int x,int y):x(x),y(y){}
	point operator+(const point& a){
		return point(a.x+x,a.y+y);
	}
	bool rangeCheck(){
		return 0<=x&&x<W&&0<=y&&y<H;
	}
	bool mapCheck(){
		return rangeCheck()&&strs[y][x]=='.';
	}
};

template<typename T>
bool chmax(T& a,const T& b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<typename T>
bool chmin(T& a,const T& b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

int main(){
	int N,M;
	cin>>N>>M;

	vector<vector<pair<int,int>>> graph(N);
	for(int i=0;i<M;i++){
		int u,v,w;
		cin>>u>>v>>w;
		u--;v--;
		graph[u].emplace_back(v, w);
		graph[v].emplace_back(u, w);
	}
	int ans=0;
	unsigned int temp=(unsigned int)-1;

	for(int i=29;i>=0;i--){
		queue<int> queue;
		vector<bool> dist(N,false);

		queue.push(0);
		while(queue.size()>0){
			auto v = queue.front();
			queue.pop();
			if(!dist[v]){
				dist[v]=true;
				for(auto g:graph[v]){
					if((g.second&(~ans)&(temp<<i))==0){
						queue.push(g.first);
					}
				}
			}
		}
		if(!dist[N-1])ans=ans|(1<<i);
	}
	cout<<ans<<endl;
	return 0;
}

提出情報

提出日時
問題 E - Minimum OR Path
ユーザ Satsuki15
言語 C++ 20 (gcc 12.2)
得点 450
コード長 1628 Byte
結果 AC
実行時間 486 ms
メモリ 14420 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 35
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3492 KiB
00_sample_01.txt AC 1 ms 3484 KiB
00_sample_02.txt AC 1 ms 3456 KiB
01_handmade_00.txt AC 1 ms 3488 KiB
01_handmade_01.txt AC 1 ms 3612 KiB
01_handmade_02.txt AC 94 ms 7072 KiB
01_handmade_03.txt AC 98 ms 7792 KiB
01_handmade_04.txt AC 1 ms 3484 KiB
01_handmade_05.txt AC 1 ms 3552 KiB
01_handmade_06.txt AC 1 ms 3552 KiB
01_handmade_07.txt AC 155 ms 9760 KiB
01_handmade_08.txt AC 153 ms 9696 KiB
01_handmade_09.txt AC 154 ms 9740 KiB
02_random_00.txt AC 92 ms 10496 KiB
02_random_01.txt AC 89 ms 8952 KiB
02_random_02.txt AC 73 ms 6792 KiB
02_random_03.txt AC 136 ms 9984 KiB
02_random_04.txt AC 131 ms 10476 KiB
02_random_05.txt AC 102 ms 9192 KiB
02_random_06.txt AC 114 ms 9296 KiB
02_random_07.txt AC 140 ms 11684 KiB
02_random_08.txt AC 145 ms 13528 KiB
02_random_09.txt AC 88 ms 10032 KiB
02_random_10.txt AC 148 ms 12088 KiB
02_random_11.txt AC 239 ms 13000 KiB
02_random_12.txt AC 149 ms 11620 KiB
02_random_13.txt AC 208 ms 13884 KiB
02_random_14.txt AC 230 ms 13416 KiB
02_random_15.txt AC 126 ms 8504 KiB
02_random_16.txt AC 87 ms 9884 KiB
02_random_17.txt AC 262 ms 9836 KiB
02_random_18.txt AC 170 ms 9756 KiB
02_random_19.txt AC 155 ms 14272 KiB
02_random_20.txt AC 486 ms 14420 KiB
02_random_21.txt AC 311 ms 14152 KiB