Submission #1276324

#TimeUsernameProblemLanguageResultExecution timeMemory
1276324otariusWorld Map (IOI25_worldmap)C++20
72 / 100
68 ms9492 KiB
#include "worldmap.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngl(chrono::steady_clock::now().time_since_epoch().count());

// #define int long long
// #define int unsigned long long

// #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>

// const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll inf = 1e9;
const ll biginf = 1e18;
const int maxN = 45;

bool used[maxN];
vector<int> g[maxN], ord;
void dfs(int v) {
    ord.pb(v); used[v] = 1;
    for (int u : g[v])
        if (!used[u]) dfs(u), ord.pb(v);
}
vector<vector<int>> create_map(int n, int m, vector<int> a, vector<int> b) {
    if (n == 1) return {{1, 1}, {1, 1}};
    for (int i = 0; i < m; i++) {
        g[a[i]].pb(b[i]); g[b[i]].pb(a[i]);
    } dfs(1);

    vector<int> cur;
    vector<vector<int>> v;
    bool did[n + 1]{};

    for (int i : ord) {
        for (int j = 1; j < 4 * n; j++) cur.pb(i);
        v.pb(cur); cur.clear();

        if (did[i]) continue;
        did[i] = 1;

        cur.resize(4 * n - 1);
        for (int j = 1; j < 4 * n - 1; j += 2) cur[j] = i;
        for (int j = 0; j < 4 * n - 1; j += 2)
            cur[j] = g[i][((j - 1) / 2) % g[i].size()];
        v.pb(cur); cur.clear();

        for (int j = 1; j <= 4 * n - 1; j++) cur.pb(i);
        v.pb(cur); cur.clear();
    }

    for (int i = 1; i <= n; i++) g[i].clear(), used[i] = 0;
    ord.clear();
    return v;
}
// int main() {
//   int T;
//   assert(1 == scanf("%d", &T));

//   std::vector<int> Nt(T), Mt(T);
//   std::vector<std::pair<std::vector<int>, std::vector<int>>> AB;

//   for (int t = 0; t < T; ++t) {
//     assert(2 == scanf("%d %d", &Nt[t], &Mt[t]));

//     int M = Mt[t];
//     std::vector<int> A(M), B(M);

//     for (int i = 0; i < Mt[t]; i++) {
//       assert(2 == scanf("%d %d", &A[i], &B[i]));
//     }
//     AB.push_back(make_pair(A, B));
//   }

//   fclose(stdin);

//   std::vector<std::vector<std::vector<int>>> Ct;

//   for (int t = 0; t < T; t++) {
//     int N = Nt[t], M = Mt[t];
//     std::vector<int> A = AB[t].first, B = AB[t].second;

//     auto C = create_map(N, M, A, B);
//     Ct.push_back(C);
//   }

//   for (int t = 0; t < T; t++) {
//     auto& C = Ct[t];
//     int P = (int)C.size();

//     std::vector<int> Q(P);
//     for (int i = 0; i < P; ++i)
//       Q[i] = (int)C[i].size();

//     printf("%d\n", P);
//     for (int i = 0; i < P; ++i)
//       printf("%d%c", Q[i], " \n"[i + 1 == P]);
//     printf("\n");
//     for (int i = 0; i < P; i++) {
//       for (int j = 0; j < Q[i]; j++) {
//         printf("%d%c", C[i][j], " \n"[j + 1 == Q[i]]);
//       }
//     }
//     if (t < T - 1)
//       printf("\n");
//   }

//   fclose(stdout);

//   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...