# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
711789 |
2023-03-17T13:54:30 Z |
tutis |
Coins (LMIO19_monetos) |
C++17 |
|
18 ms |
1376 KB |
/*input
0 4 1 5
0 0 1 0
0 0 0 1
0 1 1 1
1 1 0 1
*/
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename A, typename B>
using omap = tree <A, B, less<A>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename A>
using oset = tree <A, null_type, less<A>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
ll ran(ll a, ll b)
{
//return a + (ll)(rng() % (b - a + 1));
return uniform_int_distribution<ll>(a, b)(rng);
}
ll power(ll x, ll p)
{
if (abs(x) >= mod)
x %= mod;
if (x < 0)
x += mod;
if (abs(p) >= mod - 1)
p %= mod - 1;
if (p < 0)
p += mod - 1;
ll r = 1;
while (p)
{
if (p % 2)
r = (r * x) % mod;
x = (x * x) % mod;
p /= 2;
}
return r;
}
void solve()
{
int t, n, k1, k2;
cin >> t >> n >> k1 >> k2;
int a[n][n];
int c = 0;
for (int i = n - 1; i >= 0; i--)
{
for (int j = n - 1; j >= 0; j--)
{
cin >> a[i][j];
c += a[i][j];
}
}
int b[n][n + 1];
for (int i = 0; i < n; i++)
{
b[i][0] = 0;
for (int j = 0; j < n; j++)
b[i][j + 1] = b[i][j] + a[i][j];
}
int x[n + 2];
int* h = x + 1;
h[-1] = n;
h[n] = 0;
{
int c1 = c;
for (int i = 0; i < n; i++)
{
h[i] = min(n, c1);
c1 -= h[i];
}
}
for (int t = 0; t < 10000; t++)
{
int i = rng() % n;
int j = rng() % n;
if (i > j)
swap(i, j);
if (i == j)
continue;
//j +
//i -
int lo = min(h[i - 1] - h[i], h[j] - h[j + 1]);
int hi = min(h[i] - h[i + 1], h[j - 1] - h[j]);
pair<int, int>mx = {b[i][h[i]] + b[j][h[j]], 0};
for (int di = -hi; di <= lo; di++)
{
int dj = -di;
mx = max(mx, {b[i][h[i] + di] + b[j][h[j] + dj], di});
}
int di = mx.second;
int dj = -di;
h[i] += di;
h[j] += dj;
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
a[i][j] = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < h[i]; j++)
a[i][j] = 1;
for (int i = n - 1; i >= 0; i--)
{
for (int j = n - 1; j >= 0; j--)
{
cout << a[i][j] << " ";
}
cout << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
improper placement |
2 |
Incorrect |
1 ms |
336 KB |
K = 622 |
3 |
Partially correct |
18 ms |
1324 KB |
K = 20313 |
4 |
Incorrect |
11 ms |
1364 KB |
improper placement |
5 |
Incorrect |
13 ms |
1364 KB |
K = 21428 |
6 |
Partially correct |
11 ms |
1364 KB |
K = 22330 |
7 |
Partially correct |
11 ms |
1364 KB |
K = 22537 |
8 |
Incorrect |
12 ms |
1304 KB |
K = 25631 |
9 |
Incorrect |
12 ms |
1376 KB |
K = 22500 |
10 |
Partially correct |
15 ms |
1364 KB |
K = 22367 |