r/icpc

Cheating Email
▲ 176 r/icpc+1 crossposts

Cheating Email

I received email from ICPC regarding Withdrawal I wanna know everybody received the email? or its just some of them cuz there is no mention of my team / members or anyone its written like they are just pointing us and saying to withdraw

Plz Everyone Do Respond

u/Icy-Consequence-4713 — 11 days ago
▲ 2 r/icpc

guyss in icpc how many ppl solved ques E side hustle with this logic??

#include <bits/stdc++.h>
using namespace std;

using int64 = long long;

int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);

int T;
cin >> T;

while (T--) {
int n;
int64 c;
cin >> n >> c;

vector<int> p(n + 1);
for (int i = 1; i <= n; i++)
cin >> p[i];

vector<int64> a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i];

vector<int> vis(n + 1, 0);
int64 ans = 0;

for (int i = 1; i <= n; i++) {
if (vis[i]) continue;

vector<int> cycle;
int cur = i;

while (!vis[cur]) {
vis[cur] = 1;
cycle.push_back(cur);
cur = p[cur];
}

int L = cycle.size();

int64 sum = 0;
int64 partial = 0;

for (int v : cycle) {
sum += a[v];
partial += max(0LL, a[v] - c);
}

int64 full = sum - 1LL * (L - 1) * c;

ans += max({0LL, partial, full});
}

cout << ans << '\n';
}
}

reddit.com
u/Excellent-Finding-70 — 11 days ago