Submission #1248806

#TimeUsernameProblemLanguageResultExecution timeMemory
1248806lrnnz자리 배치 (IOI18_seats)C++20
5 / 100
4096 ms40328 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <queue> #include <random> #include "seats.h" using namespace std; #define all(a) (a).begin(), (a).end() #define ll long long #define ld long double #define ui uint64_t #define cont(set, element) ((set).find(element) != (set).end()) #define pb push_back #define chmin(x, y) (x = min(x, y)) #define chmax(x, y) (x = max(x, y)) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z){ for (const T& x : Z) cout << x << ' '; cout << "\n"; } void printVariable(const any& var) { if (!var.has_value()) { cout << "null"; return; } if (var.type() == typeid(int)) { cout << any_cast<int>(var); } else if (var.type() == typeid(double)) { cout << any_cast<double>(var); } else if (var.type() == typeid(float)) { cout << any_cast<float>(var); } else if (var.type() == typeid(char)) { cout << any_cast<char>(var); } else if (var.type() == typeid(bool)) { cout << (any_cast<bool>(var) ? "true" : "false"); } else if (var.type() == typeid(string)) { cout << any_cast<string>(var); } else if (var.type() == typeid(const char*)) { cout << any_cast<const char*>(var); } else if (var.type() == typeid(long long)) { cout << any_cast<long long>(var); } else { cout << "[unknown type]"; } } template<typename... Args> void outval(Args... args) { vector<any> variables = {args...}; for (size_t i = 0; i < variables.size(); ++i) { printVariable(variables[i]); if (i != variables.size() - 1) { cout << " "; } } cout << "\n"; } #define sp << " " << #define fi first #define se second /********* DEBUG *********/ const ll MOD2 = 1e9 + 7; const ll MOD = 998244353; const ll inf = 1e18; vector<vector<ll>> grid; vector<pair<ll,ll>> inG; ll n,m; bool calc(ll u, ll d, ll l, ll r){ ll hi = 0, pos = (d-u+1)*(r-l+1); for (int i = u; i <= d; i++){ for (int j = l; j <= r; j++){ chmax(hi, grid[i][j]); if (hi >= pos) return false; } } return true; } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { grid.resize(H, vector<ll>(W)); inG.clear(); n=H; m=W; for (int i = 0; i < H*W; i++){ grid[R[i]][C[i]] = i; inG.pb({R[i], C[i]}); } } int swap_seats(int a, int b) { swap(inG[a], inG[b]); grid[inG[a].fi][inG[a].se] = a; grid[inG[b].fi][inG[b].se] = b; int ans = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ for (int tr = i; tr < n; tr++){ for (int br = j; br < m; br++){ ans += calc(i, tr, j, br); } } } } return ans; }
#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...