| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1348213 | thesentro | Migrations (IOI25_migrations) | C++20 | 21 ms | 584 KiB |
#include "migrations.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>dp(3e4, 0);
ll l = 0, id = 0;
vector<ll>bit;
ll find(ll N)
{
ll mx = 0;
for (int i=0 ; i<N ; i++)
mx = max(mx, dp[i]);
for (int i=0 ; i<N ; i++)
{
if (mx==dp[i])
return i;
}
}
int send_message(int N, int i, int Pi) {
dp[i] = dp[Pi] + 1;
if (i==9950)
{
ll val = find(N);
l = val;
for (int j=0 ; j<15 ; j++)
{
if ((1<<j)&val)
bit.push_back(1);
else
bit.push_back(0);
}
}
if (i>=9950 and i<=9964)
return bit[id++];
if (i==9965)
{
ll val = find(N);
ll f = val-l;
bit.clear();
id = 0;
l = val;
for (int j=0 ; j<4 ; j++)
{
if ((1<<j)&f)
bit.push_back(1);
else
bit.push_back(0);
}
}
if (i>=9965 and i<=9968)
return bit[id++];
if (i>=9969)
{
ll val = find(N);
ll f = val-l;
l = val;
return f;
}
return 0;
}
std::pair<int, int> longest_path(std::vector<int> S) {
ll res = 0;
for (int i=9950 ; i<=9964 ; i++)
{
if (S[i]) res += (1<<(i-9950));
}
for (int i=9965 ; i<=9968 ; i++)
{
if (S[i]) res += (1<<(i-9965));
}
for (int i=9969 ; i<=9999 ; i++)
res += S[i];
return make_pair(0, res);
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
