QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90457 | #896. Horses | Crysfly | Compile Error | / | / | C++14 | 2.5kb | 2023-03-23 10:10:23 | 2023-03-23 10:10:27 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-03-23 10:10:27]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-03-23 10:10:23]
- 提交
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
//#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 998244353
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 300005
#define inf 0x3f3f3f3f
int n,m,a[maxn];
vi p[205];
int e[205][205],fa[205],g[205];
int gf(int x){
while(x^fa[x])x=fa[x]=fa[fa[x]];
return x;
}
vi mg(vi&a,vi&b){
vi c;
int n=a.size(),m=b.size(),i=0,j=0;
while(i<n&&j<m){
if(a[i]<b[j])c.pb(0),++i;
else c.pb(1),++j;
}
while(i<n)c.pb(0),++i;
while(j<m)c.pb(1),++j;
return c;
}
int nxt[maxn];
int period(vi s){
int n=s.size(); nxt[1]=0;
int j=0;
For(i,1,n-1){
while(j&&s[j]!=s[i])j=nxt[j];
if(s[j]==s[i])++j; nxt[i+1]=j;
}
int d=n-nxt[n];
if(n%d==0)return d;
else return n;
}
int st[maxn],top;
int deg[205],now[205],id[205],idx,cnt[205];
vi solve(int rt){
if(p[rt].empty()){
For(i,1,n)if(p[i].size() && e[rt][i])return {};
return {rt};
}
For(i,1,n)deg[i]=id[i]=cnt[i]=0,now[i]=1;
vi o;
For(i,1,n)if(gf(i)==rt)o.pb(i),id[i]=++idx;
top=0;
For(i,1,m)
if(id[a[i]] && cnt[a[i]]<p[a[i]].size()/g[rt]){
++cnt[a[i]];
st[++top]=a[i];
}
for(auto u:o){
while(now[u]<=top && st[now[u]]!=u)
deg[u]+=e[st[now[u]]][u],++now[u];
}
vi res;
For(_,1,top){
for(auto u:o){
if(now[u]<=top && !deg[u]){
res.pb(u);
for(auto v:o) deg[v]-=e[u][v];
++now[u];
while(now[u]<=top && st[now[u]]!=u)
deg[u]+=e[st[now[u]]][u],++now[u];
break;
}
}
}
return res;
}
signed main()
{
n=read();
For(i,1,n)fa[i]=i;
For(i,1,n)For(j,i+1,n)e[i][j]=e[j][i]=(!(read()));
m=read();
For(i,1,m)p[a[i]=read()].pb(i);
For(i,1,n)
For(j,i+1,n)
if(e[i][j] && p[i].size() && p[j].size()) fa[gf(i)]=gf(j);
For(i,1,n) g[gf(i)]=__gcd(g[gf(i)],(int)p[i].size());
For(i,1,n)
For(j,i+1,n)
if(e[i][j] && p[i].size() && p[j].size()){
vi tmp=mg(p[i],p[j]);
g[gf(i)]=__gcd(g[gf(i)],tmp.size()/period(tmp));
}
vector<vi>out;
For(i,1,n)
if(gf(i)==i){
vi o=solve(i);
if(o.size())out.pb(o);
}
sort(out.begin(),out.end());
for(auto t:out){
long long sum=0,pw=1;
for(int x:t)(sum+=x*pw)%=mod,(pw*=n+1)%=mod;
cout<<sum<<"\n";
}
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:111:47: error: no matching function for call to ‘__gcd(int&, std::vector<int>::size_type)’ 111 | g[gf(i)]=__gcd(g[gf(i)],tmp.size()/period(tmp)); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:1199:5: note: candidate: ‘template<class _EuclideanRingElement> _EuclideanRingElement std::__gcd(_EuclideanRingElement, _EuclideanRingElement)’ 1199 | __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n) | ^~~~~ /usr/include/c++/11/bits/stl_algo.h:1199:5: note: template argument deduction/substitution failed: answer.code:111:47: note: deduced conflicting types for parameter ‘_EuclideanRingElement’ (‘int’ and ‘long unsigned int’) 111 | g[gf(i)]=__gcd(g[gf(i)],tmp.size()/period(tmp)); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~