QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#480661 | #7616. Jump Graph | ucup-team052# | WA | 5ms | 7960kb | C++23 | 3.0kb | 2024-07-16 17:12:35 | 2024-07-16 17:12:36 |
Judging History
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 qpow(int x, int y) {
int ans = 1;
while (y) {
if (y & 1) ans = mul(ans, x);
y >>= 1; x = mul(x, x);
}
return ans;
}
int Inv(int x) {return qpow(x,mod-2);}
struct Node
{
int siz;
vector<pair<int,int>> eg;
Node(int s=0)
{
assert(s<=1);
siz=s;
}
};
const int L=10;
int n,dv[1005][1005];
map<int,Node> f[L+1][L+1];
map<int,Node> tmp[L+1];
void init()
{
for(int i=1;i<=n;i++) for(int j=0;j<i;j++) f[i][j].clear();
f[1][0][1]=Node(1);
for(int i=2;i<=n*2/3+2;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,mul(dv[n-2][k],1));
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);
ntr.eg.emplace_back(1,i-s+1);
f[i][j][nw]=ntr;
}
}
}
}
// printf("%d %d : %d\n",i,j,(int)f[i][j].size());
// for(auto [w,tr]:f[i][j])
// {
// printf("%d :\n",w);
// for(auto [x,y]:tr.eg) printf("%d %d\n",x,y);
// }
}
}
}
int Q,q[15],ok[15],sok;
Node ans[15];
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();
cin>>Q;
for(int i=1;i<=Q;i++)
{
cin>>q[i];
if(q[i]==1) ok[i]=1,ans[i]=Node(1),sok++;
if(q[i]==2)
{
ok[i]=1,sok++;
ans[i].siz=2;
ans[i].eg.emplace_back(1,2);
}
}
for(n=2;n<=2&&sok<Q;n++)
{
init();
for(int qid=1;qid<=Q;qid++)
{
for(int sl=1;sl<n&&!ok[qid];sl++)
{
int sr=n-sl+1;
if(sl>sr) break;
for(int kl=0;kl<sl&&!ok[qid];kl++) for(int kr=0;kr<sr&&!ok[qid];kr++)
{
int co=dv[n][kl+kr+1];
printf("%d %d %d %d : %d\n",sl,sr,kl,kr,co);
for(auto [w1,tr1]:f[sl][kl])
{
int way=mul(co,w1);
if(way==0) continue;
int ned=mul(Inv(way),q[qid]);
printf("%d : %d\n",w1,ned);
if(f[sr][kr].find(ned)!=f[sr][kr].end())
{
ok[qid]=1; sok++;
ans[qid]=tr1;
ans[qid].siz+=sr-1;
for(auto [eu,ev]:f[sr][kr][ned].eg)
{
if(eu==1||ev==1) ans[qid].eg.emplace_back(eu,ev);
else ans[qid].eg.emplace_back(eu+sl-1,ev+sl-1);
}
break;
}
}
}
}
}
}
for(int i=1;i<=Q;i++)
{
printf("%d\n",ans[i].siz);
for(auto [x,y]:ans[i].eg) printf("%d %d\n",x,y);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 7960kb
input:
6 1 6 3 2 5 4
output:
1 2 0 0 : 2 1 : 3 1 2 0 1 : 2 1 : 3 1 2 0 0 : 2 1 : 500000005 1 2 0 1 : 2 1 : 500000005 1 2 0 0 : 2 1 : 500000006 1 2 0 1 : 2 1 : 500000006 1 2 0 0 : 2 1 : 2 1 2 0 1 : 2 1 : 2 1 0 0 2 1 2 0 0
result:
wrong answer 1st lines differ - expected: '11 7 7 7 6 8', found: '1 2 0 0 : 2'