제출 #572909

#제출 시각아이디문제언어결과실행 시간메모리
572909Theo830Stranded Far From Home (BOI22_island)C++17
0 / 100
139 ms22384 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define ull unsigned ll #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training ll sum[2000005]; ll par[2000005]; ll find_par(ll x){ if(par[x] == x){ return x; } return par[x] = find_par(par[x]); } void enose(ll a,ll b){ ll p1 = find_par(a); ll p2 = find_par(b); if(p1 != p2){ par[p1] = p2; sum[p2] += sum[p1]; sum[p1] = 0; } } int main(void){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,m; cin>>n>>m; f(i,1,n+1){ par[i] = i; } ll s[n]; vector<ii>exo; ll maxxi = 0; f(i,0,n){ cin>>s[i]; sum[i+1] = s[i]; maxxi = max(maxxi,s[i]); exo.pb(ii(s[i],i+1)); } vector<iii>edges; f(i,0,m){ ll a,b; cin>>a>>b; if(s[a-1] > s[b-1]){ swap(a,b); } edges.pb(iii(s[b-1],ii(a,b))); } sort(all(edges)); sort(all(exo)); ll pos = 0; ll posa[n]; ll maxi[n+5] = {0}; ll p[n]; ll next[n+5]; bool ok[n]; for(auto x:exo){ while(pos < m && edges[pos].F <= x.F){ maxi[find_par(edges[pos].S.F)] = edges[pos].F; next[find_par(edges[pos].S.F)] = edges[pos].S.F - 1; enose(edges[pos].S.F,edges[pos].S.S); pos++; } posa[x.S - 1] = sum[find_par(x.S)]; p[x.S - 1] = find_par(x.S); } reverse(all(exo)); for(auto x:exo){ if(x.F != maxxi){ ok[x.S - 1] = ok[next[p[x.S - 1]]] * (posa[x.S - 1] >= maxi[p[x.S - 1]]); } else{ ok[x.S - 1] = true; } } f(i,0,n){ cout<<ok[i]; } }

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

island.cpp: In function 'int main()':
island.cpp:90:48: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   90 |             ok[x.S - 1] = ok[next[p[x.S - 1]]] * (posa[x.S - 1] >= maxi[p[x.S - 1]]);
      |                           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...