Submission #899612

#TimeUsernameProblemLanguageResultExecution timeMemory
899612marvinthangLockpicking (IOI23_lockpicking)C++17
100 / 100
7 ms3416 KiB
#include "lockpicking.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define left ___left #define right ___right #define ALL(v) (v).begin(), (v).end() #define REP(i, n) for (int _n = (n), i = 0; i < _n; ++i) #define REPD(i, n) for (int i = (n); i-- > 0; ) #define FOR(i, a, b) for (int _b = (b), i = (a); i < _b; ++i) #define FORD(i, b, a) for (int _a = (a), i = (b); i-- > _a; ) #define FORE(i, a, b) for (int _b = (b), i = (a); i <= _b; ++i) #define FORDE(i, b, a) for (int _a = (a), i = (b); i >= _a; --i) #define print_op(...) ostream & operator << (ostream &out, const __VA_ARGS__ &u) template <class U, class V> print_op(pair <U, V>) { return out << '(' << u.fi << ", " << u.se << ')'; } template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ')'; else return print_tuple_utils <i + 1, T>(out << (!i ? "(" : ", ") << get<i>(tup), tup); } template <class ...T> print_op(tuple <T...>) { return print_tuple_utils <0, tuple <T...>> (out, u); } template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream &>::type operator << (ostream &out, const Con &con) { out << '{'; for (auto it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; } vector <string> vec_splitter(string s) { s += ", "; vector <string> res; while (!s.empty()) { size_t p = s.find(", "); res.push_back(s.substr(0, p)); s = s.substr(p + 2); } return res; } template <class ...T> void debug_out(int line, vector <string> v, T&&... args) { cerr << "L" << line << ": "; int i = 0; (..., (cerr << "[" << v[i++] << " = " << args << "]")); cerr << '\n'; } #define debug(...) debug_out(__LINE__, vec_splitter(#__VA_ARGS__), __VA_ARGS__) void construct_card(int N, vector <int> A, vector <vector <int>> S) { int M = 1; vector B(N * N + 5, -1); vector T(N * N + 5, vector(2, -1)); B[0] = A[0]; vector <int> visited(N); REP(s, N) { int i = s, j = 0; int cnt = 0; while (T[j][A[i]] != -1) { int x = A[i], y = B[j]; i = S[i][y]; j = T[j][x]; if (++cnt == N) break; } if (cnt == N) continue; int x = A[i], y = B[j]; i = S[i][y]; j = T[j][x] = M++; fill(ALL(visited), -1); REP(love, N) { // while (visited[i] == -1) { int x = A[i]; B[j] = x; i = S[i][x]; visited[i] = j = T[j][x] = M++; } B[j] = A[i]; T[j][A[i]] = visited[S[i][A[i]]]; } B.resize(M); T.resize(M); REP(i, M) { REP(j, 2) if (T[i][j] == -1) T[i][j] = 0; if (B[i] == -1) B[i] = 0; } define_states(M, B, T, 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...