Submission #981628

#TimeUsernameProblemLanguageResultExecution timeMemory
981628c2zi6Mars (APIO22_mars)C++17
14 / 100
10 ms4276 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "mars.h" void dfs(int i, int j, VVI& a, VVI& vis) { int n = a.size(); vis[i][j] = true; if (i && !vis[i-1][j] && a[i-1][j]) dfs(i-1, j, a, vis); if (i+1<n && !vis[i+1][j] && a[i+1][j]) dfs(i+1, j, a, vis); if (j && !vis[i][j-1] && a[i][j-1]) dfs(i, j-1, a, vis); if (j+1<n && !vis[i][j+1] && a[i][j+1]) dfs(i, j+1, a, vis); } int compcnt(VVI& a) { int n = a.size(); VVI vis(n, VI(n)); int ret = 0; rep(i, n) rep(j, n) if (!vis[i][j] && a[i][j]) { dfs(i, j, a, vis); ret++; } return ret; } string tobin(int x) { string ret; while (x) { ret.pb('0' + (x&1)); x >>= 1; } return ret; } string lracnel(string s) { while (s.size() < 100) s.pb('0'); return s; } string answer(VVI& a) { return lracnel(tobin(compcnt(a))); } void fillsq(VVI& table, string s, int i, int j, int n) { int cur = 0; replr(i1, i, i+n-1) replr(j1, j, j+n-1) { table[i1][j1] = s[cur++]-'0'; } } string process(vector<vector<string>> a, int i, int j, int k, int n) { if (n == 1) { VVI table(3, VI(3)); rep(i, 3) rep(j, 3) table[i][j] = a[i][j][0]-'0'; return answer(table); } if (n == 2) { if (k == 0) { string ret; rep(i, 3) rep(j, 3) ret.pb(a[i][j][0]); return lracnel(ret); } else { VVI table(5, VI(5)); rep(i, 3) rep(j, 3) { fillsq(table, a[i][j], i, j, 3); } return answer(table); } } if (n == 3) { if (k == 0) { string ret; rep(i, 3) rep(j, 3) ret.pb(a[i][j][0]); return lracnel(ret); } else if (k == 1) { VVI table(5, VI(5)); rep(i, 3) rep(j, 3) { fillsq(table, a[i][j], i, j, 3); } string ret; rep(i, 5) rep(j, 5) ret.pb(table[i][j] + '0'); return lracnel(ret); } else { VVI table(7, VI(7)); rep(i, 3) rep(j, 3) { fillsq(table, a[i][j], i, j, 5); } return answer(table); } } if (n == 4) { if (k == 0) { string ret; rep(i, 3) rep(j, 3) ret.pb(a[i][j][0]); return lracnel(ret); } else if (k == 1) { VVI table(5, VI(5)); rep(i, 3) rep(j, 3) { fillsq(table, a[i][j], i, j, 3); } string ret; rep(i, 5) rep(j, 5) ret.pb(table[i][j] + '0'); return lracnel(ret); } else if (k == 2) { VVI table(7, VI(7)); rep(i, 3) rep(j, 3) { fillsq(table, a[i][j], i, j, 5); } string ret; rep(i, 7) rep(j, 7) ret.pb(table[i][j] + '0'); return lracnel(ret); } else { VVI table(9, VI(9)); rep(i, 3) rep(j, 3) { fillsq(table, a[i][j], i, j, 7); } return answer(table); } } return lracnel(""); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...