QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#112848#5. 在线 O(1) 逆元yx20201301Compile Error//C++143.1kb2023-06-14 23:47:052024-11-05 21:50:25

Judging History

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

  • [2024-11-05 21:50:25]
  • 管理员手动重测本题所有提交记录
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-14 23:47:07]
  • 评测
  • [2023-06-14 23:47:05]
  • 提交

answer

// #pragma GCC optimize("Ofast,inline,unroll-loops")
// #define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define File(s) freopen(#s".in","r",stdin),freopen(#s".out","w",stdout)
#ifdef GTRAKIOI
#define defrog(...) fprintf(stderr,__VA_ARGS__)
#else
#define defrog(...) 1
#endif
#define defrogf(...) defrog(__VA_ARGS__)
#if __cplusplus>=201703L
#define rg
#else
#define rg register
#endif
#define ri rg int
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int>pii;
typedef std::vector<int>vi;
typedef std::vector<ll>vll;
typedef std::vector<pii>vpii;
typedef std::vector<vi >vvi;
typedef long double ld;
typedef __int128 i128;
typedef __uint128_t u128;
#define Tp template<typename T>
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define all(cont) cont.begin(),cont.end()

char ibuf[1<<15],*p1,*p2;
#define getchar() (p1==p2&&(p2=(p1=ibuf)+fread(ibuf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
struct FastIO{
	/*inline void ou128(u128 x){
		u128 y=1;
		while(y<=x/10)y*=10;
		do putchar(x/y|48),x%=y,y/=10;while(y);
	}*/
	inline int rint(){rg char c,f=0;while((c=getchar())<48||c>57)f|=c=='-';ri unsigned a=c&15;while((c=getchar())>=48&&c<=57)a=a*10+(c&15);return f?~a+1:a;}
	inline ll rll(){rg char c,f=0;while((c=getchar())<48||c>57)f|=c=='-';rg ull a=c&15;while((c=getchar())>=48&&c<=57)a=a*10+(c&15);return f?~a+1:a;}
//	inline operator int(){return rint();}
	inline operator ll(){return rll();}
	inline char rchar(){rg char c;while(!isgraph(c=getchar()));return c;}
	inline int rstr(char*s){rg char c;while(!isgraph(c=getchar()));int cnt=-1;do s[++cnt]=c;while(isgraph(c=getchar()));s[++cnt]=0;return cnt;}
}g90;

std::mt19937 rng(std::chrono::high_resolution_clock::now().time_since_epoch().count());
inline int rnd(const int&a,const int&b){
	return std::uniform_int_distribution<int>(a,b)(rng);
}
inline ld rnd(const ld&a,const ld&b){
	return std::uniform_real_distribution<ld>(a,b)(rng);
}
namespace MY_STD{
	Tp inline T abs(const T&a){return a<0?-a:a;}
}

struct DSU{//unweighted
	using key_type=int;

	std::vector<key_type>fa,size;
	inline DSU(key_type n):fa(n),size(n,1){std::iota(fa.begin(),fa.end(),0);}
	inline key_type& getFa(key_type x){
		while(x^fa[x])x=fa[x]=fa[fa[x]];
		return fa[x];
	}
	inline key_type& operator[](const key_type&x){return getFa(x);}
	inline auto canMerge(const key_type&u,const key_type&v){return getFa(u)!=getFa(v);}
	inline bool merge(key_type u,key_type v){
		u=getFa(u),v=getFa(v);
		return (u)!=(v)&&(size[u]<size[v]&&(std::swap(u,v),1),fa[v]=u,size[u]+=size[v],size[v]=0,true);
	}

};

constexpr int N=100001000,M=998244353;
inline int qpow(ll a,ll b){ri res=1;for(;b;a=a*a%M,b>>=1)if(b&1)res=res*a%M;return res;}
#define pow qpow
 
int fac[N],ifac[N];
inline ll C(auto a,auto b){
	if(a<0)return 0;
	if(b<0||b>a)return 0;
	return fac[a]*(ll)ifac[b]%M*ifac[a-b]%M;
}
inline void init(int p){
	fac[0]=ifac[0]=1;
	for(int i=1;i<N;++i)fac[i]=fac[i-1]*ll(i)%M;
	ifac[N-1]=qpow(fac[N-1],M-2);
	for(int i=N-2;i;--i)ifac[i]=ifac[i+1]*ll(i+1)%M;
	assert(ifac[1]==1);
}
inline int inv(int x){
	return fac[x-1]*(ll)ifac[x]%M;
}

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code:83:13: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   83 | inline ll C(auto a,auto b){
      |             ^~~~
answer.code:83:20: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   83 | inline ll C(auto a,auto b){
      |                    ^~~~
/usr/bin/ld: /tmp/ccFDt5n7.o: in function `main':
implementer.cpp:(.text.startup+0x12b): undefined reference to `init(int)'
/usr/bin/ld: implementer.cpp:(.text.startup+0x1d0): undefined reference to `inv(int)'
collect2: error: ld returned 1 exit status