QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606067 | #6336. Council | eaten_book | 0 | 318ms | 178976kb | C++23 | 3.1kb | 2024-10-02 21:55:48 | 2024-10-02 21:55:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"
const ld PI = 3.1415926535;
const int N = 3e5+5;
const int M = 50 + 1;
const int mod = 1e9+7;
const int infi = 1e15;
const ll infl = LLONG_MAX;
const int P = 31;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
int n, m, a[N], ia[N], sm[20], udp[(1 << 20)], ddp[20][(1 << 20)], C[21][21];
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
int x = 0;
for(int j = 0; j < m; j++){
int c;
cin >> c;
sm[j] += c;
x += (c << j);
}
a[i] = x;
ia[i] = (1 << m) - 1 - x;
udp[ia[i]] = 1;
}
for(int i = 0; i < m; i++){
for(int mask = (1 << m) - 1; mask >= 0; mask--){
if((mask & (1 << i)) == 0)
udp[mask] += udp[mask ^ (1 << i)];
}
}
for(int mask = 0; mask < (1 << m); mask++){
ddp[__builtin_popcount(mask)][mask] = udp[mask];
}
for(int k = 0; k <= m; k++){
for(int i = 0; i < m; i++){
for(int mask = 0; mask < (1 << m); mask++)
if(mask & (1 << i))
ddp[k][mask] += ddp[k][mask ^ (1 << i)];
}
}
for(int i = 1; i <= n; i++){
int nd = 0, ans = 0;
for(int b = 0; b < m; b++){
int c = (a[i] >> b) & 1;
if(sm[b] - c == n / 2){
nd += (1 << b);
}
if(sm[b] - c > n / 2)
ans++;
}
int mx = 0;
int x = ia[i] & nd;
for(int k = 0; k <= m; k++){
if(ddp[k][nd] - C[__builtin_popcount(x)][k] > 0){
mx = max(mx, k);
}
}
cout << ans + mx << '\n';
}
}
signed main() {
mispertion;
for(int i = 0; i <= 20; i++){
for(int j = 0; j <= i; j++){
int res = 1;
for(int k = 1; k <= i; k++)
res *= k;
for(int k = 1; k <= j; k++)
res /= k;
for(int k = 1; k <= i - j; k++)
res /= k;
C[i][j] = res;
}
}
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 318ms
memory: 178976kb
input:
38 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...
output:
20 20 21 21 20 20 20 21 21 20 20 20 20 20 20 20 21 20 20 21 20 21 21 20 21 21 20 20 21 21 21 20 21 21 21 20 21 21
result:
wrong answer 1st numbers differ - expected: '18', found: '20'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #53:
score: 6
Accepted
time: 30ms
memory: 14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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 2nd numbers differ - expected: '1', found: '0'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%