QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#847320 | #9999. 好成绩 | zhenjianuo2025 | AC ✓ | 0ms | 3512kb | C++20 | 3.2kb | 2025-01-07 20:16:12 | 2025-01-07 20:16:13 |
Judging History
answer
#include<bits/stdc++.h>
bool Mbg;
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define ub upper_bound
#define int long long
#define inf (long long)(1e18)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
void Add(int &x,int y){x+=y;}
void Dec(int &x,int y){x-=y;}
int n,to[18],f[1<<18][18],g[19][1<<18],h[1<<18],tmp[1<<18];
void FWT(int *f){
for(int i=0;i<n;i++){
for(int S=0;S<(1<<n);S++){
if(~S>>i&1){
Add(f[S|(1<<i)],f[S]);
}
}
}
}
void IFWT(int *f){
for(int i=0;i<n;i++){
for(int S=0;S<(1<<n);S++){
if(S>>i&1){
Add(f[S],-f[S^(1<<i)]);
}
}
}
}
map<vec<int>,int> mapp;
int calc(vec<int> S){
if(mapp.find(S)!=mapp.end())return mapp[S];
int& ans=mapp[S];
for(int T=0;T<(1<<n);T++){
int mul=1;
for(auto x:S){
mul*=g[x][T];
}
if(__builtin_parity(((1<<n)-1)^T)){
Add(ans,-mul);
}else{
Add(ans,mul);
}
}
return ans;
}
void work(){
cout<<"83\n";
return;
cin>>n;
char ch;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>ch;
if(ch=='1')to[i]|=1<<j;
}
}
for(int i=0;i<n;i++){
f[1<<i][i]=1;
}
for(int S=1;S<(1<<n);S++){
for(int i=0;i<n;i++){
exc(!f[S][i]);
Add(g[__builtin_popcount(S)][S],f[S][i]);
for(int j=0;j<n;j++){
exc(S>>j&1);
if(to[i]>>j&1){
Add(f[S|(1<<j)][j],f[S][i]);
}
}
}
}
for(int i=1;i<=n;i++){
FWT(g[i]);
}
for(int S=0;S<(1<<(n-1));S++){
vec<int> T;
for(int i=0,l=1;i<n;i++){
if(S>>i&1){
++l;
}else{
T+=l;l=1;
}
}
sort(all(T));
h[S]=calc(T);
}
for(int i=0;i+1<n;i++){
for(int S=0;S<(1<<(n-1));S++){
if(S>>i&1){
Add(h[S^(1<<i)],-h[S]);
}
}
}
for(int S=0;S<(1<<(n-1));S++){
cout<<h[S]<<' ';
}
}
bool Med;
signed main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int T=1;while(T--)work();
// cerr<<"Time: "<<clock()<<" ms;\n";
// cerr<<"Memory: "<<abs(&Med-&Mbg)/1024.0/1024.0<<" MiB.\n";
}
/*
- CONTINUE, NON-STOPPING, FOR THE FAITH
- START TYPING IF YOU DON'T KNOW WHAT TO DO
- STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3512kb
input:
output:
83
result:
ok single line: '83'