Submission #66359711
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 500010
int n,m,a[N],b[N],c[N],fa[N];
int getFa(int x){
return x==fa[x] ? x : fa[x] = getFa(fa[x]);
}
int main(){
cin >> n >> m;
for(int i=1;i<=m;i++){
scanf("%d %d %d",&a[i],&b[i],&c[i]);
}
int ans = (1<<30)-1;
for(int i=29;i>=0;i--){
int f = ans - (1<<i);
for(int j=1;j<=n;j++){
fa[j] = j;
}
for(int j=1;j<=m;j++){
if((c[j] | f) == f){
fa[getFa(a[j])] = getFa(b[j]);
}
}
if(getFa(1) == getFa(n)) ans = f;
}
cout << ans;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Minimum OR Path |
| User | stone0629 |
| Language | C++ 20 (gcc 12.2) |
| Score | 450 |
| Code Size | 682 Byte |
| Status | AC |
| Exec Time | 105 ms |
| Memory | 6764 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d %d %d",&a[i],&b[i],&c[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 450 / 450 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3884 KiB |
| 00_sample_01.txt | AC | 1 ms | 3680 KiB |
| 00_sample_02.txt | AC | 1 ms | 3696 KiB |
| 01_handmade_00.txt | AC | 1 ms | 3712 KiB |
| 01_handmade_01.txt | AC | 2 ms | 3696 KiB |
| 01_handmade_02.txt | AC | 40 ms | 5980 KiB |
| 01_handmade_03.txt | AC | 40 ms | 5856 KiB |
| 01_handmade_04.txt | AC | 1 ms | 3700 KiB |
| 01_handmade_05.txt | AC | 1 ms | 3768 KiB |
| 01_handmade_06.txt | AC | 1 ms | 3664 KiB |
| 01_handmade_07.txt | AC | 59 ms | 6424 KiB |
| 01_handmade_08.txt | AC | 59 ms | 6368 KiB |
| 01_handmade_09.txt | AC | 60 ms | 6492 KiB |
| 02_random_00.txt | AC | 63 ms | 5664 KiB |
| 02_random_01.txt | AC | 48 ms | 5360 KiB |
| 02_random_02.txt | AC | 32 ms | 4928 KiB |
| 02_random_03.txt | AC | 63 ms | 6004 KiB |
| 02_random_04.txt | AC | 70 ms | 5968 KiB |
| 02_random_05.txt | AC | 61 ms | 5632 KiB |
| 02_random_06.txt | AC | 59 ms | 5720 KiB |
| 02_random_07.txt | AC | 74 ms | 6452 KiB |
| 02_random_08.txt | AC | 104 ms | 6492 KiB |
| 02_random_09.txt | AC | 63 ms | 5456 KiB |
| 02_random_10.txt | AC | 85 ms | 6376 KiB |
| 02_random_11.txt | AC | 101 ms | 6396 KiB |
| 02_random_12.txt | AC | 80 ms | 6304 KiB |
| 02_random_13.txt | AC | 84 ms | 6640 KiB |
| 02_random_14.txt | AC | 97 ms | 6600 KiB |
| 02_random_15.txt | AC | 53 ms | 5960 KiB |
| 02_random_16.txt | AC | 55 ms | 5548 KiB |
| 02_random_17.txt | AC | 62 ms | 5476 KiB |
| 02_random_18.txt | AC | 61 ms | 5400 KiB |
| 02_random_19.txt | AC | 91 ms | 6700 KiB |
| 02_random_20.txt | AC | 105 ms | 6716 KiB |
| 02_random_21.txt | AC | 101 ms | 6764 KiB |