QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#437456 | #8786. The Whole World | Kevin5307 | WA | 3088ms | 3836kb | C++23 | 2.7kb | 2024-06-09 10:58:37 | 2024-06-09 10:58:37 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const ll Mods[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59};
const int Len=17;
int n,x[33];
ll y[33];
ll C[44][44];
class EquationSolver
{
ll ksm(ll a,ll b,ll Mod)
{
ll ans=1;
while(b)
{
if(b&1) ans=(longer)(ans)*a%Mod;
b>>=1;
a=(longer)(a)*a%Mod;
}
return ans;
}
public:
bool solve(vector<vector<ll>> Mat,ll Mod,ll r)
{
int n=sz(Mat),m=sz(Mat[0])-1;
int cur=0;
for(int i=0;i<n;i++)
{
while(cur<m)
{
bool ok=false;
for(int j=i;j<n;j++)
if(Mat[j][cur]%r)
ok=true;
if(ok) break;
cur++;
}
if(cur==m) break;
for(int j=i;j<n;j++)
if(Mat[j][cur])
{
for(int k=0;k<=m;k++)
swap(Mat[i][k],Mat[j][k]);
break;
}
ll inv=ksm(Mat[i][cur],(Mod-Mod/r)*2-1,Mod);
for(int k=0;k<=m;k++)
Mat[i][k]=(longer)(Mat[i][k])*inv%Mod;
for(int j=i+1;j<n;j++)
{
ll Val=Mat[j][cur];
for(int k=0;k<=m;k++)
Mat[j][k]=(Mat[j][k]-(longer)(Mat[i][k])*Val%Mod+Mod)%Mod;
}
}
for(int i=0;i<n;i++)
{
bool ok=true;
for(int j=0;j<m;j++)
if(Mat[i][j])
ok=false;
if(!Mat[i][m])
ok=false;
if(ok)
return false;
}
return true;
}
}es;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
for(int i=0;i<44;i++)
C[i][i]=C[i][0]=1;
for(int i=2;i<44;i++)
for(int j=1;j<i;j++)
C[i][j]=C[i-1][j]+C[i-1][j-1];
int t;
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i];
for(int d=0;;d++)
{
bool ok=true;
for(int a=0;a<Len;a++)
{
vector<vector<ll>> Eq(n,vector<ll>(d+2));
ll realMod=Mods[a];
while(realMod<=1e16)
{
for(int i=1;i<=n;i++)
for(int j=0;j<=d;j++)
Eq[i-1][j]=C[x[i]][j]%realMod;
for(int i=1;i<=n;i++)
Eq[i-1][d+1]=(y[i]+realMod)%realMod;
if(!es.solve(Eq,realMod,Mods[a]))
{
ok=false;
break;
}
realMod*=Mods[a];
}
}
if(ok)
{
cout<<d<<endl;
break;
}
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
input:
2 2 1 0 4 1 3 1 1 4 4 6 6
output:
3 1
result:
ok 2 number(s): "3 1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
2 2 1 0 4 1 3 1 0 3 0 5 4
output:
3 3
result:
ok 2 number(s): "3 3"
Test #3:
score: 0
Accepted
time: 10ms
memory: 3560kb
input:
2 10 1 557 2 -172 3 -497 5 763 6 -149 7 -355 8 -29 9 -588 10 -171 11 -355 10 1 -461 2 -219 3 -45 4 -212 5 749 6 -294 9 -85 10 213 11 -412 12 125
output:
10 11
result:
ok 2 number(s): "10 11"
Test #4:
score: 0
Accepted
time: 649ms
memory: 3644kb
input:
20 10 1 -193165761 4 426322868 5 -408198139 7 -455731045 9 -389028341 17 -590246653 18 119481348 21 809814532 23 47591392 26 -21020402 10 3 -715116939 5 -263142266 6 -426687860 10 342227448 14 141724722 15 576758779 18 123410194 19 256532828 20 -223524833 25 386574889 10 5 34943085 7 238431559 9 168...
output:
25 22 23 20 20 25 23 25 26 23 23 25 29 23 24 29 29 27 25 19
result:
ok 20 numbers
Test #5:
score: -100
Wrong Answer
time: 3088ms
memory: 3836kb
input:
100 10 1 158027281 3 -154375927 6 -515683907 9 -801063453 15 371607728 16 -30224647 24 -215349633 26 219182013 29 -87257968 30 186925822 10 2 205585983 9 740879281 11 -672242855 14 -53907640 16 146130715 20 -17941862 25 -424140108 26 593743162 27 -8310423 28 84863497 10 3 46810292 4 361101002 5 4687...
output:
29 25 25 20 19 25 20 29 29 19 25 19 26 26 27 21 27 26 25 25 24 26 27 25 25 27 26 23 27 23 29 25 27 26 28 29 29 20 21 23 22 25 23 16 25 29 26 25 26 18 23 18 23 19 28 19 26 26 24 18 26 19 23 27 21 23 17 26 28 25 27 23 14 19 25 26 23 25 14 23 20 20 25 23 24 23 19 19 20 20 22 26 26 25 22 23 28 17 19 19
result:
wrong answer 73rd numbers differ - expected: '16', found: '14'