Submission #981664

#TimeUsernameProblemLanguageResultExecution timeMemory
981664c2zi6Mars (APIO22_mars)C++17
0 / 100
0 ms332 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) { /* cout << "FAZA " << k << endl; */ int m = 2 * (n - k - 1); if (k == n-1) { int sz = 2*n+1; VVI table(sz, VI(sz)); table[0][0] = a[0][0][0] - '0'; table[0][1] = a[0][1][0] - '0'; table[1][0] = a[1][0][0] - '0'; table[1][1] = a[1][1][0] - '0'; for (int j = 2; j < sz; j++) table[0][j] = a[0][2][j-2] - '0'; for (int j = 2; j < sz; j++) table[1][j] = a[1][2][j-2] - '0'; for (int i = 2; i < sz; i++) table[i][0] = a[2][0][i-2] - '0'; for (int i = 2; i < sz; i++) table[i][1] = a[2][1][i-2] - '0'; fillsq(table, a[2][2], 2, 2, 2*k+1); cout << endl; rep(i, sz) { rep(j, sz) cout << table[i][j]; cout << endl; } cout << endl; return answer(table); } if (i < m && j < m) return a[0][0]; if (i == m && j != m) { string ret; ret += a[0][0].substr(0, 1); ret += a[0][1].substr(0, 1); ret += a[0][2].substr(0, 1+k*2); return lracnel(ret); } if (i != m && j == m) { string ret; ret += a[0][0].substr(0, 1); ret += a[1][0].substr(0, 1); ret += a[2][0].substr(0, 1+k*2); return lracnel(ret); } int sz = 2*(k+1)+1; VVI table(sz, VI(sz)); table[0][0] = a[0][0][0] - '0'; table[0][1] = a[0][1][0] - '0'; table[1][0] = a[1][0][0] - '0'; table[1][1] = a[1][1][0] - '0'; for (int j = 2; j < sz; j++) table[0][j] = a[0][2][j-2] - '0'; for (int j = 2; j < sz; j++) table[1][j] = a[1][2][j-2] - '0'; for (int i = 2; i < sz; i++) table[i][0] = a[2][0][i-2] - '0'; for (int i = 2; i < sz; i++) table[i][1] = a[2][1][i-2] - '0'; fillsq(table, a[2][2], 2, 2, 2*k+1); string ret; rep(i, sz) rep(j, sz) ret.pb(table[i][j] + '0'); return lracnel(ret); }
#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...