#include<bits/stdc++.h>
using namespace std;
#define NAME "DRIVERS"
#define nl '\n'
#define allofa(x,sz) x,x+sz+1
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,val) memset(x,val,sizeof(x))
#define couf(x) cout << fixed << setprecision(x)
template<class T> T Abs(T &x) {return (x>=0 ? x : -x);};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b) {a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b) {a=b;return true;}return false;};
typedef long long ll;
typedef pair<ll,int> pli;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e15;
const int INF = (int)1e9;
const int MAXN = (int)2e5+5;
vector<pli> graph[MAXN];
set<int> isSub1;
int n,m,q;
void ccps() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(NAME".inp","r")) {
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
}
namespace subtask1 {
const int N = (int)1e4+5;
bool check() {
return (int)isSub1.size()==1 and 1<=n and n<=1e4 and 1<=m and m<=1e4;
}
struct DSU {
int power[MAXN],parent[MAXN];
void makeSet(int n) {
for (int i = 1; i<=n; i++) {
parent[i]=i;
power[i]=1;
}
}
int find(int u) {
if(u==parent[u]) return u;
return parent[u] = find(parent[u]);
}
bool Union(int u, int v) {
u=find(u);v=find(v);
if(u==v) return false;
if(power[u]<power[v]) swap(u,v);
parent[v]=u;
power[u]+=power[v];
return true;
}
} dsu;
void sol() {
int w = *isSub1.begin();
dsu.makeSet(n);
while(q--) {
int x,y,t;
if(w>t) {
cout << "NE" << nl;
continue;
}
if(dsu.Union(x,y)) cout << "TEIP" << nl;
else cout << "NE" << nl;
}
}
}
signed main() {
ccps();
cin >> n >> m >> q;
for (int i = 1; i<=m; i++) {
int u,v; ll w; cin >> u >> v >> w;
graph[u].push_back({w,v});
graph[v].push_back({w,u});
isSub1.insert(w);
}
if(subtask1::check()) subtask1::sol();
else cout << "NE";
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void ccps()':
Main.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | freopen(NAME".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | freopen(NAME".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |