QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290850#7854. 这不是一道数据结构题myeeCompile Error//C++116.2kb2023-12-25 17:50:022023-12-25 17:50:02

Judging History

你现在查看的是最新测评结果

  • [2023-12-25 17:50:02]
  • 评测
  • [2023-12-25 17:50:02]
  • 提交

answer

// 那就是希望。
// 即便需要取模,也是光明。

#include <algorithm>
#include <set>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
    T ans=1%mod;
    while(index)
    {
        if(index&1)ans=ans*base%mod;
        base=base*base%mod,index>>=1;
    }
    return ans;
}
namespace ConstMod
{
template<const ullt p>
class mod_ullt
{
private:
    ullt v;
    inline ullt chg(ullt w){return(w<p)?w:w-p;}
    inline mod_ullt _chg(ullt w){mod_ullt ans;ans.v=(w<p)?w:w-p;return ans;}
public:
    mod_ullt():v(0){}
    mod_ullt(ullt v):v(v%p){}
    inline bol empty(){return!v;}
    inline ullt val(){return v;}
    inline ullt&operator()(){return v;}
    inline friend bol operator==(mod_ullt a,mod_ullt b){return a()==b();}
    inline friend bol operator!=(mod_ullt a,mod_ullt b){return a()!=b();}
    inline mod_ullt operator+(){return*this;}
    inline friend mod_ullt operator+(mod_ullt a,mod_ullt b){return a._chg(a()+b());}
    inline mod_ullt&operator+=(mod_ullt b){return*this=*this+b;}
    inline mod_ullt operator-(){return _chg(p-v);}
    inline friend mod_ullt operator-(mod_ullt a,mod_ullt b){return a+(-b);}
    inline mod_ullt&operator-=(mod_ullt b){return*this=*this-b;}
    inline friend mod_ullt operator*(mod_ullt a,mod_ullt b){return a()*b();}
    inline mod_ullt&operator*=(mod_ullt b){return*this=*this*b;}
    inline friend mod_ullt operator/(mod_ullt a,mod_ullt b){return a*b.inv();}
    inline mod_ullt&operator/=(mod_ullt b){return*this=*this/b;}
    friend mod_ullt operator^(mod_ullt a,ullt b)
    {
        mod_ullt v(1);
        while(b)
        {
            if(b&1)v*=a;
            a*=a,b>>=1;
        }
        return v;
    }
    inline mod_ullt&operator^=(ullt b){return*this=*this^b;}
    inline mod_ullt operator++(int){mod_ullt ans=*this;return v=chg(v+1),ans;}
    inline mod_ullt&operator++(){return v=chg(v+1),*this;}
    inline mod_ullt operator--(int){mod_ullt ans=*this;return v=chg(v+p-1),ans;}
    inline mod_ullt&operator--(){return v=chg(v+p-1),*this;}
    inline mod_ullt inv(){return(*this)^(p-2);}
    mod_ullt sqrt()
    {
        if(((*this)^((p-1)>>1))!=1)return 0;
        mod_ullt b(1);do b++;while((b^((p-1)>>1))==1);
        ullt t=p-1;uint s=0;while(!(t&1))s++,t>>=1;
        mod_ullt x=(*this)^((t+1)>>1),e=(*this)^t,w=inv();
        for(uint k=1;k<s;k++,e=w*x*x)if((e^(1llu<<(s-k-1)))!=1)x*=b^((1llu<<(k-1))*t);
        ullt ans=x();_min(ans,p-ans);return ans;
    }
    voi read()
    {
        v=0;chr c;do c=getchar();while(c>'9'||c<'0');
        do v=(c-'0'+v*10)%p,c=getchar();while(c>='0'&&c<='9');
    }
    voi print(chr endc='\0')
    {
        static chr C[20];uint tp=0;
        ullt w=v;do C[tp++]=w%10+'0',w/=10;while(w);
        while(tp--)putchar(C[tp]);
        if(endc)putchar(endc);
    }
    inline voi println(){print('\n');}
};
}
// Your shadow Gets in the way of my light
const ullt Mod=1e9+7;
typedef ConstMod::mod_ullt<Mod>modint;
typedef std::vector<modint>modvec;
std::vector<uint>Way[200005],Son[200005],Ps[200005];
std::vector<std::pair<uint,uint> >Es[200005];uint tp;
voi dfs(uint p,uint f)
{
    static uint Dep[200005],S[200005],Dfn[200005],F[200005],cnt;
    static std::vector<uint>B;std::vector<uint>A;
    if(!~f)for(auto&s:Dfn)s=-1;
    F[p]=f,Dep[p]=B.size(),B.push_back(p),Dfn[p]=cnt++;
    for(auto s:Way[p])if(s!=f)
    {
        if(~Dfn[s])
        {
            if(Dep[s]<Dep[p])S[B[Dep[s]+1]]--,S[p]++;
        }
        else A.push_back(s),dfs(s,p),S[p]+=S[s];
    }
    B.pop_back(),Son[p]=A;
    if(!~f)while(A.size())
    {
        B={A.back()},A.pop_back(),Ps[tp]={F[B[0]]};
        while(B.size())
        {
            Ps[tp].push_back(p=B.back()),B.pop_back();
            for(auto s:Son[p])(S[s]?B:A).push_back(s);
        }
        static bol Now[200005];
        for(auto s:Ps[tp])Now[s]=true;
        for(auto s:Ps[tp])for(auto ss:Way[s])if(s<ss&&Now[ss])Es[tp].push_back({s,ss});
        for(auto s:Ps[tp])Now[s]=false;
        tp++;
    }
}
uint D[200005];
int main()
{
#ifdef MYEE
    freopen("QAQ.in","r",stdin);
    freopen("QAQ.out","w",stdout);
#endif
    uint n,m;scanf("%u%u",&n,&m);
    while(m--){uint u,v;scanf("%u%u",&u,&v);Way[--u].push_back(--v),Way[v].push_back(u);}
    dfs(0,-1);
    modint ans(n);
    while(tp--)
    {
        for(auto p:Ps[tp])D[p]++;
        if(Ps[tp].size()==2)continue;
        ans*=2;
        static uint Xor[400005],Deg[200005],cnt;
        static std::vector<uint>Eid[200005],Q;
        std::set<std::pair<uint,uint> >M;
        for(auto p:Ps[tp])Eid[p].clear();
        cnt=0;
        for(auto e:Es[tp])
            M.insert(e),Eid[e.first].push_back(cnt),Eid[e.second].push_back(cnt),Xor[cnt++]=e.first^e.second;
        for(auto p:Ps[tp])if((Deg[p]=Eid[p].size())==2)Q.push_back(p);
        while(Q.size())
        {
            uint p=Q.back(),u=-1,v=-1;Q.pop_back();if(Deg[p]!=2)continue;
            Deg[p]=0;for(auto e:Eid[p])if(~Xor[e])(~u?v:u)=p^Xor[e],Xor[e]=-1u;
            if(u>v)std::swap(u,v);
            if(M.count({u,v}))
            {
                if(--Deg[u]==2)Q.push_back(u);
                if(--Deg[v]==2)Q.push_back(v);
            }
            else
                M.insert({u,v}),Eid[u].push_back(cnt),Eid[v].push_back(cnt),Xor[cnt++]=u^v;
        }
        uint cnt=0;
        for(auto p:Ps[tp])if(Deg[p])cnt++;
        if(cnt>2)return puts("0"),0;
    }
    for(uint i=0;i<n;i++)for(uint j=1;j<=D[i];j++)ans*=j;
    ans.println();
    return 0;
}

// 那就是希望。
// 即便需要取模,也是光明。

詳細信息

answer.code: In function ‘int main()’:
answer.code:168:14: error: redeclaration of ‘uint cnt’
  168 |         uint cnt=0;
      |              ^~~
answer.code:147:45: note: ‘uint cnt’ previously declared here
  147 |         static uint Xor[400005],Deg[200005],cnt;
      |                                             ^~~
answer.code:138:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  138 |     uint n,m;scanf("%u%u",&n,&m);
      |              ~~~~~^~~~~~~~~~~~~~
answer.code:139:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  139 |     while(m--){uint u,v;scanf("%u%u",&u,&v);Way[--u].push_back(--v),Way[v].push_back(u);}
      |                         ~~~~~^~~~~~~~~~~~~~