QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#532162 | #2346. Miniature Golf | Swarthmore# | AC ✓ | 2013ms | 117364kb | C++20 | 2.8kb | 2024-08-25 00:55:38 | 2024-08-25 00:55:38 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
const char nl = '\n';
void solve() {
int N, M; cin >> N >> M;
vl A[N];
F0R(i, N) {
A[i] = vl(M);
F0R(j, M) cin >> A[i][j];
}
vector<pair<int, bool>> ev[N];
F0R(a, N) {
FOR(b, a+1, N) {
vpi ce;
F0R(i, M) {
ce.pb({A[a][i], 0});
ce.pb({A[b][i], 1});
}
ll sa = 0, ra = M, sb = 0, rb = M;
ll lst = 1;
ev[a].pb({1, 1});
ev[b].pb({1, 1});
sort(all(ce));
trav(x, ce) {
ll nxt = x.f;
F0R(iter, 2) {
bool oklst = sa + ra * lst >= sb + rb * lst;
bool oknxt = sa + ra * nxt >= sb + rb * nxt;
if (oklst != oknxt) {
ll lo = lst+1, hi = nxt;
while (lo < hi) {
ll mid = (lo+hi)/2;
bool okmid = sa + ra * mid >= sb + rb * mid;
if (okmid == oknxt) {
hi = mid;
} else lo = mid+1;
}
ev[a].pb({lo, oknxt});
}
swap(sa, sb);
swap(ra, rb);
swap(a, b);
}
lst = nxt;
if (x.s == 0) {
sa += x.f;
ra--;
} else {
sb += x.f;
rb--;
}
}
}
}
F0R(i, N) {
sort(all(ev[i]));
int cur = 0;
int ans = N;
F0R(j, sz(ev[i])) {
/*if (i == 2) {
cout << ev[i][j].f << " " << ev[i][j].s << endl;
}*/
cur += ev[i][j].s*2-1;
if (j == sz(ev[i])-1 || ev[i][j].f != ev[i][j+1].f) {
ans = min(ans, cur);
}
}
cout << ans+1 << nl;
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3572kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3592kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3620kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3512kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3792kb
Test #8:
score: 0
Accepted
time: 2ms
memory: 3688kb
Test #9:
score: 0
Accepted
time: 3ms
memory: 4008kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3568kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 3888kb
Test #12:
score: 0
Accepted
time: 6ms
memory: 3792kb
Test #13:
score: 0
Accepted
time: 0ms
memory: 3872kb
Test #14:
score: 0
Accepted
time: 0ms
memory: 3604kb
Test #15:
score: 0
Accepted
time: 6ms
memory: 4012kb
Test #16:
score: 0
Accepted
time: 161ms
memory: 5764kb
Test #17:
score: 0
Accepted
time: 2013ms
memory: 117364kb
Test #18:
score: 0
Accepted
time: 2013ms
memory: 116456kb
Test #19:
score: 0
Accepted
time: 1775ms
memory: 101876kb
Test #20:
score: 0
Accepted
time: 918ms
memory: 50240kb
Test #21:
score: 0
Accepted
time: 899ms
memory: 50260kb
Test #22:
score: 0
Accepted
time: 907ms
memory: 50312kb
Test #23:
score: 0
Accepted
time: 507ms
memory: 8316kb
Test #24:
score: 0
Accepted
time: 504ms
memory: 8160kb
Test #25:
score: 0
Accepted
time: 509ms
memory: 8108kb
Test #26:
score: 0
Accepted
time: 504ms
memory: 8232kb
Test #27:
score: 0
Accepted
time: 502ms
memory: 8320kb