QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#480554 | #7606. Digital Nim | ucup-team052# | TL | 0ms | 0kb | C++14 | 1.5kb | 2024-07-16 16:30:13 | 2024-07-16 16:30:14 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int md = 1e9 + 7;
const int mod = 1e9 + 7;
inline int add(int x, int y) {
if (x + y >= md) return x + y - md;
return x + y;
}
inline int sub(int x, int y) {
if (x < y) return x - y + md;
return x - y;
}
inline int mul(int x, int y) {
return 1ull * x * y % md;
}
inline int mul(int x,int y,int z) {return mul(mul(x,y),z);}
inline int fpow(int x, int y) {
int ans = 1;
while (y) {
if (y & 1) ans = mul(ans, x);
y >>= 1; x = mul(x, x);
}
return ans;
}
struct Node
{
int siz;
vector<pair<int,int>> eg;
Node(int s=0)
{
assert(s<=1);
siz=s;
}
};
const int L=40;
int n,dv[1005][1005];
map<int,Node> f[L+1][L+1];
map<int,Node> tmp[L+1];
void init()
{
n=80;
f[1][0][1]=Node(1);
for(int i=2;i<=L;i++)
{
for(int j=1;j<i;j++)
{
for(int s=1;s<i;s++)
{
for(auto [w1,tr1]:f[i-s][j-1])
{
for(int k=0;k<s;k++)
{
for(auto [w2,tr2]:f[s][k])
{
int nw=mul(w1,w2,dv[n-2][k]);
if(f[i][j].find(nw)!=f[i][j].end()) continue;
Node ntr=tr1;
ntr.siz+=s;
for(auto [eu,ev]:tr2.eg) ntr.eg.emplace_back(eu+i-s,ev+i-s);
f[i][j][nw]=ntr;
}
}
}
}
printf("%d %d : %d\n",i,j,(int)f[i][j].size());
}
}
}
int main() {
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
for(int i=1;i<=1000;i++)
{
dv[i][0]=1;
for(int j=1;j<=1000;j++) dv[i][j]=mul(dv[i][j-1],i-j+1);
}
init();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
4 1 10 42 190
output:
2 1 : 1 3 1 : 1 3 2 : 1 4 1 : 2 4 2 : 1 4 3 : 1 5 1 : 3 5 2 : 2 5 3 : 1 5 4 : 1 6 1 : 5 6 2 : 3 6 3 : 2 6 4 : 1 6 5 : 1 7 1 : 7 7 2 : 5 7 3 : 3 7 4 : 2 7 5 : 1 7 6 : 1 8 1 : 11 8 2 : 7 8 3 : 5 8 4 : 3 8 5 : 2 8 6 : 1 8 7 : 1 9 1 : 15 9 2 : 11 9 3 : 7 9 4 : 5 9 5 : 3 9 6 : 2 9 7 : 1 9 8 : 1 10 1 : 22...