제출 #1296799

#제출 시각아이디문제언어결과실행 시간메모리
1296799Dreamy_lovesperAutići (COCI22_autici)C++20
30 / 50
104 ms12908 KiB
// I also thought that there was a small chance that she likes me back. #include <bits/stdc++.h> using namespace std; // Do you think you'll ever remember me someday, or will I just fade away from your memory? #define LIFESUCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define str string #define mll map<ll, ll> #define vll vector<ll> #define pll pair<ll, ll> #define fi first #define se second #define all(c) c.begin(), c.end() #define pb push_back #define sz(s) s.size() #define debug cout << "I Love You\n"; #define fu(i, a, b) for (ll i = a; i <= b; i++) #define fd(i, b, a) for (ll i = b; i >= a; i--) #define Bisave(msk, j) ((msk >> j) & 1) #define _log(x) 31 - __builtin_clz(x) #define LoveTime chrono::steady_clock::now().time_since_epoch().count() const ll Mod = 998244353; const ll inf = (1ll << 30); const ll lnf = (1ll << 60); // When time passes and things change... will you still remember someone like me? int64_t add(ll& a, ll b) { a += b; if (a >= Mod) a %= Mod; while (a < 0) a += Mod; return a; } int64_t mul(ll a, ll b) { a = 1ll * a * b % Mod; return a; } template <class X, class Y> bool minimize(X& x, Y y) { X eps = 1e-9; if (x > y + eps) { x = y; return 1; } return 0; } template <class X, class Y> bool maximize(X& x, Y y) { X eps = 1e-9; if (x + eps < y) { x = y; return 1; } return 0; } // I wonder… will I just become a distant memory to you one day? #define mxn 100'007 ll n, g[mxn]; namespace Love1 { bool check () { fu(i, 2, n) if(g[i] != g[i - 1]) return 0; return 1; } void DreamyLove () { cout << (g[2] + g[1]) * (n - 1); // } } namespace Love2 { bool check () { return (n <= 1000); } struct DisjointSetUnion { vll par; DisjointSetUnion(ll _n = 0): par(_n + 7, 0) {} ll find(ll v) {return !par[v]? v: par[v] = find(par[v]); } bool suion(ll u, ll v) { u = find(u); v = find(v); if(u == v) return 0; par[v] = u; return 1; } }; struct Edge { ll u, v, w; bool operator<(const Edge& other) const { return w > other.w; } }; void DreamyLove () { priority_queue<Edge> Q; fu(i, 1, n) fu(j, i + 1, n) Q.push({i, j, g[i] + g[j]}); DisjointSetUnion dsu(n); ll sad = 0; while(!Q.empty()) { auto[u, v, w] = Q.top(); Q.pop(); if(dsu.suion(u, v)) sad += w; } cout << sad; // } } // The world is still beautiful, only it’s a pity that you are no longer among the living. void lovesper(const ll& TestCase) { cin >> n; fu(i, 1, n) cin >> g[i]; if(Love2::check()) { Love2::DreamyLove(); return; } if(Love1::check()) { Love1::DreamyLove(); return; } } // In the future, each of us will have our own path.. // ...But no matter where we go, we will always be a beautiful part of each other’s memories. signed main() { LIFESUCK #define name "lovesper" // freopen(name".inp", "r", stdin); // freopen(name".out", "w", stdout); ll Test = 1; // cin >> Test; fu(i, 1, Test) { lovesper(i); if (i < Test) cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...