QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#232168 | #6345. Random Interactive Convex Hull Bot | CharlieVinnie | TL | 0ms | 0kb | C++17 | 3.4kb | 2023-10-29 22:49:32 | 2023-10-29 22:49:33 |
answer
#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](auto...){}(__VA_ARGS__)
#define debuga(...) [](auto...){}(__VA_ARGS__)
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
#define assume(expr) ((!!(expr))||(exit((fprintf(stderr,"Assumption Failed: %s on Line %d\n",#expr,__LINE__),-1)),false))
#define range basic_string_view
using namespace std; typedef long long ll;
constexpr int mod=1e9+7,B=6;
inline int qpow(int x,int y){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
bitset<mod> vis; int T,Q[11],val[205],ival[205]; vector<int> lis[205],lis2[205]; vector<pair<int,int>> Ans[11];
void solve(int n){
for(int i=0,t=1;i<=n-2;i++) val[i]=t,t=1ll*t*(n-2-i)%mod;
For(i,0,n-2) ival[i]=qpow(val[i],mod-2);
For(i,0,n-2) lis[i].clear(),lis2[i].clear();
function<void(int,int,int)> dfs1=[&](int d,int tot,int x){
lis[tot].push_back(x);
For(i,d,min(B,n-2-tot)) dfs1(i,tot+i,1ll*x*ival[i]%mod);
};
function<void(int,int,int)> dfs2=[&](int d,int tot,int x){
lis2[tot].push_back(x);
For(i,d,n-2-tot) dfs2(i,tot+i,1ll*x*val[i]%mod);
};
dfs1(1,0,1); dfs2(B+1,0,1);
For(id,1,T) if(Ans[id].empty()){
int o=1ll*qpow(n,mod-2)%mod*qpow(n-1,mod-2)%mod*Q[id]%mod;
For(s,0,n-2){
for(int x:lis[s]) vis.set(1ll*o*x%mod);
int X=0;
for(int x:lis2[n-2-s]) if(vis.test(x)) { X=x; break; }
for(int x:lis[s]) vis.reset(1ll*o*x%mod);
if(!X) continue;
vector<int> ans;
function<bool(int,int,int)> dfs3=[&](int d,int tot,int x){
if(tot==s&&x==X) return true;
For(i,d,min(B,n-2-tot)){
ans.push_back(i); if(dfs3(i,tot+i,1ll*x*ival[i]%mod)) return true; else ans.pop_back();
}
return false;
};
function<bool(int,int,int)> dfs4=[&](int d,int tot,int x){
if(tot==n-2-s&&x==X) return true;
For(i,d,n-2-tot){
ans.push_back(i); if(dfs4(i,tot+i,1ll*x*val[i]%mod)) return true; else ans.pop_back();
}
return false;
};
assert(dfs3(1,0,o)); assert(dfs4(B+1,0,1));
ans.resize(n); debug(ans);
for(int i=1,p=2;i<=n;i++){
For(_,1,ans[i-1]+(i==1)) Ans[id].emplace_back(i,p++);
}
break;
}
}
}
signed main(){
atexit([](){cerr<<"Time = "<<clock()<<" ms"<<endl;});
// int T; cin>>T; while(T--) { int o; cin>>o; if(o==1) { cout<<1<<'\n'; continue; }; int n=2; while(!solve(o,n)) n++; }
cin>>T; For(i,1,T) { cin>>Q[i]; if(Q[i]==1) Ans[i].emplace_back(0,0); }
for(int n=2;;n++){
solve(n); int ok=1; For(i,1,T) if(Ans[i].empty()) { ok=0; break; } if(ok) break;
}
For(i,1,T){
if(Ans[i][0].first==0) cout<<1<<'\n';
else{
cout<<Ans[i].size()+1<<'\n'; for(auto [x,y]:Ans[i]) cout<<x<<' '<<y<<'\n';
}
}
return 0;
}
// START TYPING IF YOU DON'T KNOW WHAT TO DO
// STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
// CONTINUE, NON-STOPPING, FOR CHARLIEVINNIE
// Started Coding On: October 28 Sat, 07 : 43 : 27
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
5