QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#523443 | #4907. djq 学生物 | N_z_ | 50 | 1458ms | 10544kb | C++14 | 6.3kb | 2024-08-18 11:06:52 | 2024-08-18 11:06:52 |
Judging History
answer
#if defined(LOCAL) or not defined(LUOGU)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include<bits/stdc++.h>
using namespace std;
struct time_helper
{
#ifdef LOCAL
clock_t time_last;
#endif
time_helper()
{
#ifdef LOCAL
time_last=clock();
#endif
}
void test()
{
#ifdef LOCAL
auto time_now=clock();
std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;
time_last=time_now;
#endif
}
~time_helper()
{
test();
}
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 10
#define between '\n'
#define __int128 long long
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-Setprecision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
void solve();
main()
{
#ifndef LOCAL
#ifndef ONLINE_JUDGE
freopen("hex.in","r",stdin);
freopen("hex.out","w",stdout);
#endif
#endif
int t=1;
// cin>>t;
while(t--)solve();
}
constexpr int p=998244353;
int qp(int x,int n=p-2)
{
int r=1;
while(n)
{
if(n&1)r=1ll*r*x%p;
x=1ll*x*x%p,n>>=1;
}
return r;
}
int a[1296][1297];
int gauss(int n)
{
for(int x=0;x<n;x++)
{
for(int y=x;y<n;y++)
if(a[y][x]){swap(a[x],a[y]);break;}
if(!a[x][x])return 0;
for(int y=0;y<n;y++)
if(y!=x)
{
int d=1ll*a[y][x]*qp(a[x][x])%p;
for(int z=x;z<=n;z++)
a[y][z]=(a[y][z]-1ll*a[x][z]*d)%p;
}
// for(int x=0;x<n;x++)
// {
// for(int y=0;y<=n;y++)
// cerr<<a[x][y]<<' ';cerr<<endl;
// }cerr<<endl;
}
for(int x=0;x<n;x++)
a[x][n]=1ll*a[x][n]*qp(-a[x][x])%p;
return 1;
}
constexpr int table[6][6]=
{
{0,1,2,3,4,5},
{1,0,3,2,5,4},
{2,4,0,5,1,3},
{3,5,1,4,0,2},
{4,2,5,0,3,1},
{5,3,4,1,2,0}
};
int trans(int u,int v)
{
vector<int>res;
while(u||v)
{
res.emplace_back(table[v%6][u%6]);
u/=6,v/=6;
}
reverse(res.begin(),res.end());
for(auto q:res)u=u*6+q;
return u;
}
void solve()
{
int n;
cin>>n;
if(n<=4)
{
n=pow(6,n);
vector<int>c(n);
cin>>c;
int fl=1;
for(auto q:c)fl=(fl+q)%p;
fl=qp(fl);
for(auto &q:c)q=1ll*fl*q%p;
a[0][n]=1;
for(int x=0;x<n;x++)
{
a[x][x]--;
for(int y=0;y<n;y++)
{
int _=trans(x,y);
a[_][x]=(a[_][x]+c[y])%p;
}
}
// for(int x=0;x<n;x++)
// {
// for(int y=0;y<=n;y++)
// cerr<<a[x][y]<<' ';cerr<<endl;
// }cerr<<endl;
if(!gauss(n))cout<<-1<<endl;
else
{
// for(int x=0;x<n;x++)
// {
// for(int y=0;y<=n;y++)
// cerr<<a[x][y]<<' ';cerr<<endl;
// }cerr<<endl;
int ans=0;
for(int x=0;x<n;x++)
a[x][n]=(1ll*a[x][n]*fl%p+p)%p,ans^=a[x][n];
cout<<ans<<endl;
}
return;
}
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3924kb
input:
1 10 10 10 10 499122217 499122156
output:
-1
result:
ok 1 number(s): "-1"
Test #2:
score: 10
Accepted
time: 0ms
memory: 3864kb
input:
1 719885386 651516139 596516649 191397068 26958009 352245674
output:
320270701
result:
ok 1 number(s): "320270701"
Test #3:
score: 10
Accepted
time: 0ms
memory: 3812kb
input:
1 783368690 104275706 48409057 969269573 366936187 542139073
output:
252144401
result:
ok 1 number(s): "252144401"
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #4:
score: 20
Accepted
time: 1ms
memory: 4024kb
input:
2 304089172 305211383 35005211 521595368 294702567 728712076 336465782 861021530 278722862 233665123 148685361 468703135 103269576 803735449 317389669 635723058 370888716 127653814 61717040 92529750 628175011 658233689 132931876 655133020 859484421 916300566 608413784 756898537 736330845 975349971 1...
output:
396724238
result:
ok 1 number(s): "396724238"
Test #5:
score: 20
Accepted
time: 1ms
memory: 4020kb
input:
2 913515603 749241873 137806862 42999170 982906996 135497281 511702305 87932219 939232731 829091974 572660336 160882152 805750846 634377376 102416960 435681504 143371771 84353895 939819582 4611839 2410108 549989014 610515434 587746011 376099690 760313750 478926734 356426808 945117276 891702825 78245...
output:
870050121
result:
ok 1 number(s): "870050121"
Test #6:
score: 20
Accepted
time: 15ms
memory: 4852kb
input:
3 57511226 265850707 413305323 845749015 943947739 985965659 855636226 751454233 471103741 958053186 37896442 463480570 44162728 977716025 317097467 893822248 378465744 927612902 332328964 603570492 689682299 660260756 959997301 485560280 402724286 593209441 196709512 894429689 364228444 949102266 2...
output:
315521842
result:
ok 1 number(s): "315521842"
Test #7:
score: 20
Accepted
time: 15ms
memory: 4988kb
input:
3 349517445 588219756 858424826 59174065 995706887 824845059 66858995 625032172 387451659 471017656 564157983 298625210 296921989 59223234 801633853 557074948 382697713 476667372 72330968 260401255 296864819 774044599 697517721 4741198 952711586 337695458 798829587 758671314 67067352 719346228 84681...
output:
927050034
result:
ok 1 number(s): "927050034"
Subtask #3:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
input:
7 13237606 0 0 696947386 879320747 0 0 0 0 0 0 0 0 0 0 0 0 0 266959993 0 0 371358373 632390641 0 666960563 0 0 708812199 564325578 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 299649176 0...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Subtask #4:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #12:
score: 20
Accepted
time: 1454ms
memory: 10400kb
input:
4 887790043 739693399 870246744 301313259 18507681 629005716 67544354 58092673 642897565 70732414 899481125 727551664 871859472 220238086 708355050 385234243 645860416 129326472 850844210 577801468 684900507 461005014 934205121 591855867 526169505 197643478 136123938 67642730 682939149 949635706 281...
output:
602449578
result:
ok 1 number(s): "602449578"
Test #13:
score: 20
Accepted
time: 1458ms
memory: 10432kb
input:
4 557598958 113906113 211073291 59019633 110287605 318903034 307171270 201167854 142201998 886457896 24068541 289099056 55884864 35794579 11689085 615385706 684842316 559228752 366244387 646068652 535314708 313739657 846826781 931109365 759018899 574643185 553946098 150095139 137782333 741636661 949...
output:
37335981
result:
ok 1 number(s): "37335981"
Test #14:
score: 20
Accepted
time: 1444ms
memory: 10544kb
input:
4 376545129 990894084 275573387 559810624 528344836 360116901 406141975 630960645 550842736 709965265 690253412 98881522 427656896 104902833 504114740 620019063 359704636 908644219 755230881 459810186 435557594 214555147 965394547 449697679 122566226 581267354 68455475 593798485 142522444 164230614 ...
output:
75788971
result:
ok 1 number(s): "75788971"
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%