제출 #1128448

#제출 시각아이디문제언어결과실행 시간메모리
1128448cbnhtmanhElection Campaign (JOI15_election_campaign)C++20
10 / 100
56 ms11848 KiB
#include <bits/stdc++.h> #define fi(i, a, b) for( int i = a; i <= b; i++ ) #define fid(i, a, b) for( int i = a; i >= b; i-- ) #define getbit(x, i) ((x>>i)&1) #define ll long long #define pb push_back #define pii pair<int,int> #define pli pair<ll,int> #define pll pair<ll,ll> #define st first #define nd second #define mp make_pair #define HTManh "" #define maxn 100009 #define endl '\n' using namespace std; int n; vector<int> a[100009]; int m; struct dl { int u, v; int c; } tv[100009]; bool check() { fi(u,1,n) for(int v: a[u]) if (u < v && u != v-1) return 0; return 1; } vector<pii> truyvan[100009]; ll mx[100009]; void sub23() { //cout << "gay" << endl; fi(i,1,m) { int u = tv[i].u, v = tv[i].v, c = tv[i].c; if (u > v) swap(u, v); truyvan[v].pb({u, c}); } fi(i,1,n) { ll gt = 0; for(pii tg: truyvan[i]) { gt = max(gt, mx[tg.st - 1] + tg.nd); } mx[i] = max(mx[i-1], gt); } cout << mx[n] << endl; } void sub1() { } void subac() { } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); if (fopen(HTManh".inp", "r")) { freopen(HTManh".inp", "r", stdin); freopen(HTManh".out", "w", stdout); } cin >> n; fi(i,1,n-1) { int x, y; cin >> x >> y; a[x].pb(y); a[y].pb(x); } cin >> m; fi(i,1,m) cin >> tv[i].u >> tv[i].v >> tv[i].c; if (check()) sub23(); else { if (m <= 15) sub1(); else subac(); } }

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

election_campaign.cpp: In function 'int main()':
election_campaign.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen(HTManh".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
election_campaign.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen(HTManh".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...