Submission #1159094

#TimeUsernameProblemLanguageResultExecution timeMemory
1159094crai0nSpring cleaning (CEOI20_cleaning)C++20
0 / 100
37 ms8776 KiB
/* Bismillahir rahmanir rahim Allahu akbar Alhamdulillah Subhanallah Rabbi a’inni wa-la tu’in ‘alayya, wa-nsurni wa-la tansur ‘alayya, wa-mkur-li wa-la tamkur alayya, wa-hdini wa-yassir-il-huda ilayya, wa-nsurni ‘ala man bagha ‘alayya Ya Hayyu Ya Qayyum, birahmatika astaghitsu, aslih li sha'ni kullahu, wa la takilni ila nafsi tarfata ‘aini */ #include <bits/stdc++.h> #define ll long long #define int long long #define pb(x) push_back(x) #define sor(x) sort(x.begin(), x.end()) #define rsor(x) sort(x.rbegin(), x.rend()) #define yes cout << "YES\n"; #define no cout << "NO\n"; #pragma pack(1) using namespace std; const int N = 2e5 + 55; const int MOD = 1e9 + 7; const bool T = false; ll bp(ll a, ll n) { if(n == 0) { return 1; } if (n & 1) { return bp(a, n - 1) * a % MOD; } else { ll temp = bp(a, n / 2); return temp * temp % MOD; } } vector<ll> g[N]; void hippopotomonstrosesquipedaliophobia() { ll n, q; cin >> n >> q; bool f1, f2; f1 = f2 = 1; for (int i = 1; i < n; i++) { ll x, y; cin >> x >> y; g[x].pb(y); g[y].pb(x); if(x != y + 1 and y != x + 1) { f1 = 0; } if(x != 1 and y != 1) { f2 = 0; } } if(f2 == 1) { for (int i = 0; i < q; i++) { ll d; ll as = n - 1 + (g[1].size() == 1); cin >> d; for (int j = 0; j < d; j++) { ll x; cin >> x; if(x == 1) { as++; } } if(as % 2 == 1) { cout << -1 << '\n'; } else { cout << as + 1 << '\n'; } } return; } if(f1 == 1) { for (int i = 1; i <= q; i++) { ll d; cin >> d; ll x = 2; ll dist = n - 1; vector<ll> vc; for (int j = 0; j < d; j++) { ll u; cin >> u; x++; vc.pb(u); } if(x % 2 == 1) { cout << -1 << '\n'; } else { sor(vc); for (int i = 0; i < vc.size(); i+=2) { dist += abs(vc[i] - vc[i + 1]); } } } return; } for (int i = 1; i <= q; i++) { ll d; cin >> d; for (int j = 0; j < d; j++) { ll x; cin >> x; } } } signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int time = 1; if (T) { cin >> time; } while (time--) { hippopotomonstrosesquipedaliophobia(); } return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...