Submission #645942

#TimeUsernameProblemLanguageResultExecution timeMemory
645942MadokaMagicaFanGardening (RMI21_gardening)C++14
5 / 100
78 ms892 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; #define forn(i,n) for(int i = 0; i < n; ++i) #define pb push_back #define sz(v) ((int)((v).size())) void doframe(int t, int x, int y, int w, int h, vector<vi> &a) { for (int i = 0; i < w; ++i) { a[x+i][y] = t; a[x+i][y+h-1] = t; } for (int i = 0; i < h; ++i) { a[x][y+i] = t; a[x+w-1][y+i] = t; } return; } void solve() { int n, m, k; cin >> n >> m >> k; bool t = 0; vector<vi> ans; int v, c; int w, h; int o= 0; int oy, ox; int tval; if (n & 1) goto untrue; if (m & 1) goto untrue; n >>= 1; m >>= 1; if (n > k) goto untrue; if (m > k) goto untrue; for (int i = 0; i < n && i <= m; ++i) { if (k % (n-i) == i && (k/(n-i)) <= m-i && (k/(n-i)) * (n-i) >= m-i) { t = 1; v = 0; c = i; break; } } for (int i = 0; i < m && i <= n; ++i) { if (k % (m-i) == i && (k/(m-i)) <= n-i && (k/(m-i)) * (m-i) >= n-i) { v = 1; c = i; t = 1; break; } } if (!t) goto untrue; cout << "YES\n"; if (!v) swap(n,m); ans.assign(n<<1,{}); for (int i = 0; i < (n<<1); ++i) { ans[i].assign(m<<1,0); } for (int i = 0; i < c; ++i) { doframe(i+1, i, i, (n-i)<<1, (m-i)<<1, ans); } w = n - c; h = m - c; k -= c; o = c; oy = c; ox = c; for (int i = 0; i < k/h; ++i) { o = min(w+i-k/h, h-1); /* if (w > ((k/h) - i)) { */ for (int j = 0; j < o; ++j) { doframe(i*h + c+1 +j, ox+j, oy+j, (o-j+1)<<1, (h-j)<<1, ans); } /* } */ for (int j = o; j < h; ++j) { doframe(i*h+c+1+j, ox+o, oy-o+2*j, 2, 2, ans); } w -= (1 + o); ox += ((1 + o)<<1); /* w -= 1kkkkkkkk */ } if (!v) swap(n,m); for (int i = 0; i < (n<<1); ++i) { for (int j = 0; j < (m<<1); ++j) { if (!v) cout << ans[j][i] << ' '; else cout << ans[i][j] << ' '; } cout << endl; } return; untrue: cout << "NO\n"; return; } int32_t main(int argc, char *argv[]) { if (argc>1) freopen(argv[1], "r", stdin); ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) solve(); }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:40:9: warning: unused variable 'tval' [-Wunused-variable]
   40 |     int tval;
      |         ^~~~
Main.cpp: In function 'int32_t main(int, char**)':
Main.cpp:141:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  141 |         freopen(argv[1], "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...