submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s144617839
p03988
C++
#include <bits/stdc++.h> #include <boost/range/algorithm.hpp> #include <boost/range/numeric.hpp> #include <boost/range/irange.hpp> #include <boost/range/adaptor/indexed.hpp> using namespace std; using namespace boost::adaptors; using namespace std::string_literals; using ll = int64_t; using vecint = vector<int>; using vecll = vector<ll>; using boost::irange; int main() { int n; cin>>n; vecint cnt(n, 0); int mn = n; int mx = 0; for(int i:irange(0,n)) { int a; cin>>a; ++cnt[a]; mn = min(mn, a); mx = max(mx, a); } bool ok = true; if (mn < mx / 2) { ok = false; } if (cnt[mx/2] > 1) { ok = false; } if ((mx%2) == 1 && cnt[mx/2+1] != 2) { ok = false; } for(int i:irange(min(mx+1,mx/2+2), mx+1)) { if (cnt[i] < 2) { ok = false; } } if (!ok!) { cout<<"Impossible"<<endl; } else { cout<<"Possible"<<endl; } return 0; }
a.cc:2:10: fatal error: boost/range/algorithm.hpp: No such file or directory 2 | #include <boost/range/algorithm.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s954025627
p03988
C++
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <string> #include <queue> #include <deque> #include <list> #include <set> #include <map> #include <bitset> using namespace std; int main() { int N; cin >> N; vector<int> v; for (int i = 0; i < N; i++) { int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end(), greater<int>()); int length = v[0]; int* count = new int[length + 1]; for (int i = 0; i <= length; i++) { count[i] = 0; } for (auto itr = v.begin(); itr != v.end(); itr++) { count[*itr]++; } if (length % 2 == 0) { for (int i = length; i > length / 2; i--) { if (count[i] < 2) { cout << "Impossible" << endl; return 0; } } if (count[length / 2] != 1) { cout << "Impossible" << endl; return 0; } } else { for (int i = length; i * 2 > length + 2; i--) { if (count[i] < 2) { cout << "Impossible" << endl; return 0; } } if (count[(length + 1) / 2] != 2) { cout << "Impossible" << endl; return 0; } } cout << "Possible" << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 23 | sort(v.begin(), v.end(), greater<int>()); | ^~~~ | sqrt
s240105892
p03988
C++
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <string> #include <queue> #include <deque> #include <list> #include <set> #include <map> #include <bitset> using namespace std; int main(){ int N; cin >> N; vector<int> v; for(int i=0;i<N;i++){ int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end(), std::greater<int>() ); int length = v[0]; int *count = new int[length+1]; for(int i=0;i<=length;i++){ count[i] = 0; } for(auto itr = v.begin(); itr != v.end(); itr++){ count[*itr]++; } if(length %2 == 0){ for(int i=length;i > length/2;i--){ if(count[i] < 2){ cout << "Impossible" << endl; return 0; } } if(count[length/2] != 1){ cout << "Impossible" << endl; return 0; } } else{ for(int i=length;i*2 > length + 2;i--){ if(count[i] < 2){ cout << "Impossible" << endl; return 0; } } if(count[(length+1)/2] != 2){ cout << "Impossible" << endl; return 0; } } cout << "Possible" << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 23 | sort(v.begin(), v.end(), std::greater<int>() ); | ^~~~ | sqrt
s938447324
p03988
C++
#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; const ll INF = 1LL << 60; const ll MOD = 1000000007; template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } template <class C> void print(const C &c, std::ostream &os = std::cout) { std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " ")); os << std::endl; } int main() { int n; cin >> n; vi a(n); map<int, int> cnt; int maxi = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; chmax(maxi, a[i]); cnt[a[i]]++; } int nmin = (maxi % 2 == 0 ? maxi / 2 : maxi / 2 + 1); for (int i = maxi; i >= nmin; --i) { if (i == nmin && maxi % 2 == 0) { if (cnt[i] < 1) { cout << "Impossible" << "\n"; return 0; } else { cnt[i] -= 1; } } else { if (cnt[i] < 2) { cout << "Impossible" << "\n"; return 0; } else { cnt[i] -= 2; } } } while (true) { int cmax = -1; for (auto it = cnt.rbegin(); it != cnt.rend(); it = next(it)) { if (it->second != 0) { cmax = it->first; break; } } if (cmax == -1) break; if (cmax <= nmin || cmax > maxi) { cout << "Impossible" << "\n"; return 0; } for (int i = cmax; i > nmin; --i) { if (cnt[i] < 1) { continue } else { cnt[i]--; } } } cout << "Possible" << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:74:25: error: expected ';' before '}' token 74 | continue | ^ | ; 75 | } else { | ~
s372318760
p03988
C++
#include <bits/stdc++.h> using namespace std; const int MOD=1e9+7; //const int MOD=998244353; const int INF=1e9; const long long LINF=1e18; #define int long long //template template <typename T> void fin(T a){ cout<<a<<endl; exit(0); } //main signed main(){ int N;cin>>N; std::vector<int> v(N); for(int i=0;i<N;i++)cin>>v[i]; sort(v.begin(),v.end()); map<int,int> m; for(int i=0;i<N;i++)m[v[i]]++; 5 4 3 3 4 5 if(v[N-1]&1){ for(int i=v[N-1];i>v[N-1]/2;i--)if(m[i]<2)fin("Impossible"); if(m[v[N-1]/2+1]>2)fin("Impossible"); for(int i=v[N-1]/2;i>=0;i--)if(m[i])fin("Impossible"); fin("Possible"); } for(int i=v[N-1];i>v[N-1]/2;i--)if(m[i]<2)fin("Impossible"); if(m[v[N-1]/2]!=1)fin("Impossible"); for(int i=m[v[N-1]/2-1];i>=0;i--)if(m[i])fin("Impossible"); fin("Possible"); }
a.cc: In function 'int main()': a.cc:22:4: error: expected ';' before numeric constant 22 | 5 4 3 3 4 5 | ^~ | ;
s715548740
p03988
C++
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define start_routine() int begtime = clock(); #define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0 #define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false) // #define exit(a, b) return cout << a, b; #define PB push_back #define MP make_pair #define sd(n) scanf("%lld", &n) #define pdn(n) printf("%lld\n", n); #define pds(n) printf("%lld ", n); #define endl '\n' #define forn(a, b, i) for (int i = a; i < b; i += 1) #define all(v) v.begin(), v.end() #define print(stuff) cout << stuff << endl #define len(stuff) (int) stuff.size() #define int long long // #define float long double #define ll long long #define ld long double typedef long long LL; using vi = vector<int>; using vb = vector<bool>; using pii = pair<int, int>; using mii = map<int, int>; const int inf = (int) 1e16; const int upper = (int) 3e5 + 50; // const int M = (ll) 1e9 + 7; const int mod = (ll) 998244353; const int M = mod; const double eps = 1e-8; int n, k; int modexp (int a, int b) { if (b == 0) return 1; int ans = modexp(a, b/2); ans = (ans * ans) % mod; if (b & 1) ans = (ans * a) % mod; return ans; } int inv (int a) { return modexp(a, mod - 2); } int fac[2000005], invfac[2000005]; void compute() { fac[0] = 1; for (int i = 1; i <= 2000000; i += 1) { fac[i] = (fac[i - 1] * i) % mod; } invfac[2000000] = inv(fac[2000000]); for (int i = 2000000 - 1; i >= 0; i--) { invfac[i] = (invfac[i + 1] * (i + 1)) % mod; } } inline int c (int a, int b) { if (b > a) return 0; int ans = fac[a]; ans *= invfac[a - b], ans %= mod; ans *= invfac[b], ans %= mod; return ans; } int n; signed main () { start_routine(); speed(); #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // freopen("errlog.txt", "w", stderr); #endif cin >> n; int cnt[n + 1] = {0}; int mx = -1; for (int i = 1; i <= n; i += 1) { int lol; cin >> lol; cnt[lol]++; mx = max(mx, lol); } if (cnt[mx] < 2) { cout << "Impossible"; return 0; } cout << "Possible"; end_routine(); }
a.cc:81:5: error: redefinition of 'long long int n' 81 | int n; | ^ a.cc:47:5: note: 'long long int n' previously declared here 47 | int n, k; | ^
s799542152
p03988
C++
#include "bits/stdc++.h" #include <MT.h> typedef long long ll; #define int ll #define fi first #define se second #define SORT(a) sort(a.begin(),a.end()) #define rep(i,n) for(int i = 0;i < (n) ; i++) #define REP(i,n) for(int i = 0;i < (n) ; i++) #define MP(a,b) make_pair(a,b) #define pb(a) push_back(a) #define INF LLONG_MAX/2 #define all(x) (x).begin(),(x).end() #define debug(x) cerr<<#x<<": "<<x<<endl #define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl using namespace std; int MOD = 1000000007; int n; int a[101]; signed main(){ cin >> n; int mini = 110; int maxi = -1; rep(i,n){ int val; cin >> val; a[val]++; mini = min(mini,val); maxi = max(maxi,val); } if(a[mini] == 1){ if(maxi != mini*2){ cout << "Impossible" << endl; return 0; } if(a[mini+1] == 1){ cout << "Impossible" << endl; return 0; } for(int i = mini+1;i <= maxi;i++){ if(a[i] < a[i-1]){ cout << "Impossible" << endl; return 0; } } cout << "Possible" << endl; }else if(a[mini] == 2){ if(maxi != mini*2-1){ cout << "Impossible" << endl; return 0; } for(int i = mini+1;i <= maxi;i++){ if(a[i] < a[i-1]){ cout << "Impossible" << endl; return 0; } } cout << "Possible" << endl; }else{ cout << "Impossible" << endl; } return 0; } // g++ -std=c++14 code1.cpp // rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d // rm -r -f test;oj dl http://agc005.contest.atcoder.jp/tasks/agc005_c
a.cc:2:10: fatal error: MT.h: No such file or directory 2 | #include <MT.h> | ^~~~~~ compilation terminated.
s311366953
p03988
C++
///*BY ME*/// #include <bits/stdc++.h> using namespace std; #define y1 sijf #define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) #define all(v) (v).begin(),(v).end() #define pb push_back #define F first #define S second #define endl '\n' #define flsh cout<<flush typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef double dd; const ll MOD=1e9+7; set<int>ans; int n,a[101],sum,mn,mx,minn=1000000,maxx; int main() { RampageRead; cin>>n; if(n>2) mn=1+(n-1)*2; else mn=2; for(int i=n-1;i>=n/2;i--) mx+=i*2; if(n&1) mx-=(n/2); //cout<<mn<<" "<<mx<<endl; for(int i=0;i<n;i++)5 { cin>>a[i]; sum+=a[i]; ans.insert(a[i]); minn=min(minn,a[i]); maxx=max(maxx,a[i]); } sort(a,a+n); for(int i=2;i<n;i++) if(a[i-1]+1<a[i] or mx<sum or mn>sum or ans.size()>n/2+1 or (a[0]==1 and ans.size()>2)) { cout<<"Impossible"; return 0; } cout<<"Possible"; return 0; }
a.cc: In function 'int main()': a.cc:28:26: error: expected ';' before '{' token 28 | for(int i=0;i<n;i++)5 | ^ | ; 29 | { | ~
s343747377
p03988
C++
///*BY ME*/// #include <bits/stdc++.h> #define y1 sijf //#define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) #define all(v) (v).begin(),(v).end() #define pb push_back #define F first #define S second #define endl '\n' #define flsh cout<<flush typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef double dd; const ll MOD=1e9+7; int n,a[101],sum,mn,mx; int main() { //RampageRead; cin>>n; if(n>2) mn=1+(n-1)*2; else mn=2; for(int i=n-1;i>=n/2;i--) mx+=i*2; if(n&1) mx-=(n/2); //cout<<mn<<" "<<mx<<endl; for(int i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; } sort(a,a+n); for(int i=2;i<n;i++) if(a[i-1]+1<a[i] or mx<sum or mn>sum) { cout<<"Impossible"; return 0; } cout<<"Possible"; return 0; }
a.cc: In function 'int main()': a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 22 | cin>>n; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:2: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:33:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'? 33 | sort(a,a+n); | ^~~~ | std::sort In file included from /usr/include/c++/14/algorithm:86, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ a.cc:37:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 37 | cout<<"Impossible"; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:40:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 40 | cout<<"Possible"; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s259078257
p03988
C++
///*BY ME*/// #include <bits/stdc++.h> #define y1 sijf #define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) #define all(v) (v).begin(),(v).end() #define pb push_back #define F first #define S second #define endl '\n' #define flsh cout<<flush typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef double dd; const ll MOD=1e9+7; int n,a[101],sum,mn,mx; int main() { RampageRead; cin>>n; if(n>2) mn=1+(n-1)*2; else mn=2; for(int i=n-1;i>=n/2;i--) mx+=i*2; if(n&1) mx-=(n/2); //cout<<mn<<" "<<mx<<endl; for(int i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; } sort(a,a+n); for(int i=2;i<n;i++) if(a[i-1]+1<a[i] or mx<sum or mn>sum) { cout<<"Impossible"; return 0; } cout<<"Possible"; return 0; }
a.cc: In function 'int main()': a.cc:5:21: error: 'ios_base' has not been declared 5 | #define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) | ^~~~~~~~ a.cc:21:5: note: in expansion of macro 'RampageRead' 21 | RampageRead; | ^~~~~~~~~~~ a.cc:5:50: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 5 | #define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) | ^~~ a.cc:21:5: note: in expansion of macro 'RampageRead' 21 | RampageRead; | ^~~~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:2: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:5:61: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 5 | #define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) | ^~~~ a.cc:21:5: note: in expansion of macro 'RampageRead' 21 | RampageRead; | ^~~~~~~~~~~ /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:5:73: error: 'mt19937' was not declared in this scope; did you mean 'std::mt19937'? 5 | #define RampageRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()) | ^~~~~~~ a.cc:21:5: note: in expansion of macro 'RampageRead' 21 | RampageRead; | ^~~~~~~~~~~ In file included from /usr/include/c++/14/random:48, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:179: /usr/include/c++/14/bits/random.h:1717:37: note: 'std::mt19937' declared here 1717 | 0xefc60000UL, 18, 1812433253UL> mt19937; | ^~~~~~~ a.cc:33:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'? 33 | sort(a,a+n); | ^~~~ | std::sort In file included from /usr/include/c++/14/algorithm:86, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~
s121690758
p03988
C++
var n,mi,ma,i,a:Longint; cnt:array[1..99]of Longint; f:Boolean; begin read(n); mi:=n; for i:=1 to n do begin read(a); if mi>a then mi:=a; if ma<a then ma:=a; inc(cnt[a]); end; f:=true; if cnt[mi]-ma mod 2<>1 then f:=false; for i:=mi+1 to ma do begin if cnt[i]<2 then f:=false; end; if f and(mi*2>=ma)then writeln('Possible')else writeln('Impossible'); end.
a.cc:3:19: error: too many decimal points in number 3 | cnt:array[1..99]of Longint; | ^~~~~ a.cc:19:40: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 19 | if f and(mi*2>=ma)then writeln('Possible')else writeln('Impossible'); | ^~~~~~~~~~ a.cc:19:64: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes 19 | if f and(mi*2>=ma)then writeln('Possible')else writeln('Impossible'); | ^~~~~~~~~~~~ a.cc:1:1: error: 'var' does not name a type 1 | var | ^~~ a.cc:3:12: error: found ':' in nested-name-specifier, expected '::' 3 | cnt:array[1..99]of Longint; | ^ | :: a.cc:3:9: error: 'cnt' does not name a type; did you mean 'int'? 3 | cnt:array[1..99]of Longint; | ^~~ | int a.cc:4:10: error: found ':' in nested-name-specifier, expected '::' 4 | f:Boolean; | ^ | :: a.cc:4:9: error: 'f' does not name a type 4 | f:Boolean; | ^ a.cc:5:1: error: 'begin' does not name a type 5 | begin | ^~~~~ a.cc:7:9: error: 'mi' does not name a type 7 | mi:=n; | ^~ a.cc:8:9: error: expected unqualified-id before 'for' 8 | for i:=1 to n do begin | ^~~ a.cc:10:17: error: expected unqualified-id before 'if' 10 | if mi>a then mi:=a; | ^~ a.cc:11:17: error: expected unqualified-id before 'if' 11 | if ma<a then ma:=a; | ^~ a.cc:12:20: error: expected constructor, destructor, or type conversion before '(' token 12 | inc(cnt[a]); | ^ a.cc:13:9: error: 'end' does not name a type 13 | end; | ^~~ a.cc:14:9: error: 'f' does not name a type 14 | f:=true; | ^ a.cc:15:9: error: expected unqualified-id before 'if' 15 | if cnt[mi]-ma mod 2<>1 then f:=false; | ^~ a.cc:16:9: error: expected unqualified-id before 'for' 16 | for i:=mi+1 to ma do begin | ^~~ a.cc:18:9: error: 'end' does not name a type 18 | end; | ^~~ a.cc:19:9: error: expected unqualified-id before 'if' 19 | if f and(mi*2>=ma)then writeln('Possible')else writeln('Impossible'); | ^~ a.cc:20:1: error: 'end' does not name a type 20 | end. | ^~~
s278139428
p03988
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++) int main(void){ int N; cin >> N; int a[N+10]; rep(i,N)cin >> a[i]; sort(a,a + N); int separate = (N - 1) - a[N - 1]; int depth = N - separate; map<int,int> mp; rep(i,N)mp[a[i]]++; if(depth % 2 == 1){ if(mp[depth / 2] != 1){ cout << "Impossible" << "\n"; return 0; } mp[depth / 2] = 0; } int cou = 0; rep(i,N){ if(mp[a[i]] == 1){ cout << "Impossible" << "\n"; return 0; } cou += max(mp[a[i]] - 2, 0); mp[a[i]] = 0; } for(i,N - 1){ if(abs(a[i] - a[i + 1]) > 1){ cout << "Impossible" << "\n"; return 0; } } if(cou == separate)cout << "Possible" << "\n"; else cout << "Impossible" << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:32:9: error: 'i' was not declared in this scope 32 | for(i,N - 1){ | ^ a.cc:38:5: error: expected primary-expression before 'if' 38 | if(cou == separate)cout << "Possible" << "\n"; | ^~ a.cc:37:6: error: expected ';' before 'if' 37 | } | ^ | ; 38 | if(cou == separate)cout << "Possible" << "\n"; | ~~ a.cc:38:5: error: expected primary-expression before 'if' 38 | if(cou == separate)cout << "Possible" << "\n"; | ^~ a.cc:37:6: error: expected ')' before 'if' 37 | } | ^ | ) 38 | if(cou == separate)cout << "Possible" << "\n"; | ~~ a.cc:32:8: note: to match this '(' 32 | for(i,N - 1){ | ^
s380035639
p03988
C++
#include <iostream> #include <vector> using namespace std; typedef long long int ll; #define all(x) x.begin(),x.end() int main() { int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } int k = *max_element(all(a)); vector<int> cnt(k+1); for(int i = 0; i < n; i++){ cnt[a[i]]++; } bool flag = true; if(k%2==0){ for(int i = 1; i <= k; i++){ if(i<k/2 && cnt[i]>0) flag = false; if(i>k/2 && cnt[i]<2) flag = false; if(i==k/2 && cnt[i]!=1) flag = false; } }else{ k++; for(int i = 1; i <k; i++){ if(i<k/2 && cnt[i]>0) flag = false; if(i>k/2 && cnt[i]<2) flag = false; if(i==k/2 && cnt[i]!=2) flag = false; } } cout << (flag?"Possible":"Impossible") << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:18: error: 'max_element' was not declared in this scope 18 | int k = *max_element(all(a)); | ^~~~~~~~~~~
s788891686
p03988
C++
#include <bits/stdc++.h> #define bp __builtin_popcountll #define pb push_back #define in(s) freopen(s, "r", stdin); #define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\ freopen((string(s) + "." + end2).c_str(), "w", stdout); #define fi first #define se second #define bw(i, r, l) for (int i = r - 1; i >= l; i--) #define fw(i, l, r) for (int i = l; i < r; i++) #define fa(i, x) for (auto i: x) using namespace std; const int mod = 1e9 + 7, inf = 1061109567; const long long infll = 4557430888798830399; const int N = 105; int n, mn = inf, a[N], cnt[N], mx = -inf; void bad() { cout << "Impossible"; exit(0); } void good() { cout << "Possible"; exit(0); } signed main() { #ifdef BLU in("blu.inp"); #endif ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; fw (i, 0, n) cin >> a[i], mn = min(mn, a[i]), mx = max(mx, a[i]), cnt[a[i]]++; fw (i, 0, n) if (a[i] > 2 * mn) bad(); bool startbad = 0; if (n == 2 && cnt[1] == 2) good(); if (cnt[1] > 1) bad(); fw (i, mn, 2 * mn + 1) { if (cnt[i] == 0) startbad = 1; if (startbad && cnt[i] > 0) bad(); } //Missing case: cnt[1 -> (mx + 1) / 2] > 2. if (k & 1) fw (i, mn, (mx + 1) / 2 + 1) if (cnt[i] > 2) bad(); else fw (i, mn, (mx + 1) / 2 + 1) if (cnt[i] > 1) bad(); good(); return 0; }
a.cc: In function 'int main()': a.cc:41:13: error: 'k' was not declared in this scope 41 | if (k & 1) fw (i, mn, (mx + 1) / 2 + 1) if (cnt[i] > 2) bad(); | ^
s305890584
p03988
C++
/*input 4 3 3 3 2 */ #include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ALL(a) a.begin(),a.end() #define SZ(a) ((int)a.size()) #define F first #define S second #define REP(i,n) for(int i=0;i<((int)n);i++) #define pb push_back #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) #define YY cout<<"YES\n" #define NN cout<<"NO\n" #define yy cout<<"Yes\n" #define nn cout<<"No\n" #ifdef leowang #define debug(...) do{\ fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\ _DO(__VA_ARGS__);\ }while(0) template<typename I> void _DO(I&&x){cerr<<x<<endl;} template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);} #else #define debug(...) #endif template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<'('<<P.F<<','<<P.S<<')'; return out; } //}}} const ll maxn=300005; const ll maxlg=__lg(maxn)+2; const ll INF64=8000000000000000000LL; const int INF=0x3f3f3f3f; const ll MOD=ll(1e9+7); const double PI=acos(-1); //const ll p=880301; //const ll P=31; ll mypow(ll a,ll b){ ll res=1LL; while(b){ if(b&1) res=res*a%MOD; a=a*a%MOD; b>>=1; } return res; } int a[maxn]; multiset<int> st; int main() { IOS; int n; cin>>n; REP(i,n) cin>>a[i]; int mx=*max_element(a,a+n); REP(i,n) st.insert(a[i]); REP(i,mx+1){ int cur=max(i,mx-i); if(!st.count(cur)){ cout<<"Impossible\n"; return 0; } st.erase(st.lower_bound(cur)); } for(int i:st){ if(i<(k+1)/2+1){ cout<<"Impossible\n"; return 0; } } cout<<"Possible\n"; return 0; }
a.cc: In function 'int main()': a.cc:82:23: error: 'k' was not declared in this scope 82 | if(i<(k+1)/2+1){ | ^
s462281519
p03988
C++
#include <bits/stdc++.h> using namespace std; const int MAXn = 100 + 10; int n, ar[MAXn], max1 = 0 , min1 = MAXn, cnt, cnt2; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; min1 = min(min1 , ar[i]); if (ar[i] == min1) cnt2++; else if (ar[i] < max1) cnt2 = 0; if (ar[i] == max1) cnt++; else if (ar[i] > max1) cnt = 0; max1 = max(max1 , ar[i]); } if (min1 < max1 / 2 + (max1 % 2) || cnt < 2 || (cnt2 > 1 && min1 == max1 / 2) return cout << "Impossible",0; cout << "Possible"; }
a.cc: In function 'int main()': a.cc:20:86: error: expected ';' before 'return' 20 | if (min1 < max1 / 2 + (max1 % 2) || cnt < 2 || (cnt2 > 1 && min1 == max1 / 2) | ^ | ; 21 | return cout << "Impossible",0; | ~~~~~~ a.cc:22:27: error: expected ')' before ';' token 22 | cout << "Possible"; | ^ | ) a.cc:20:12: note: to match this '(' 20 | if (min1 < max1 / 2 + (max1 % 2) || cnt < 2 || (cnt2 > 1 && min1 == max1 / 2) | ^
s345601471
p03988
C++
#include <bits/stdc++.h> using namespace std; struct P { //string r; int x,y,z; bool operator<(const P &a)const{ // if(y!=a.y) // return y>a.y; return x<a.x; // return z>a.z; } }; vector<int> v[155]; //bitset<4001000> b; int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};// int l[201010]; int o[200150]; int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1}; long long x[200100],y,z[200100],mod=1000000007; P u[11]; int j[200011]; stack<int> s; queue<P> q; //'1'==49; //'A'==65; //'a'==97; //unordered_ //map<int,int > p; //list<int> l; //string r[111],r2; char r[510][555]; bool as(P a,P b) { // if(a.x!=b.x) return a.x<b.x; //return a.y>b.y; } int main() { scanf("%d",&a); for(int t=1;t<=a;l[o[t]]++,t++) scanf("%d",&o[t]); sort(o+1,o+a+1); if(o[a]!=o[a-1]) { puts("Impossible"); return 0; } j[a]=1; for(int t=a-1;t>0;t--) if(o[t]<o[a]/2+o[a]%2) { puts("Impossible"); return 0; } else if(j[o[t]]) { j[o[a]-o[t]]++; } else j[o[t]]++; if(o[a]%2) { if(max(j[o[a]/2],j[o[a]/2+o[a]%2)>1) { puts("Impossible"); return 0; } } else { if(j[o[a]/2]>1) { puts("Impossible"); return 0; } } for(int t=1;t<=o[a];t++) if(j[t]==0) { puts("Impossible"); return 0; } puts("Possible"); }
a.cc: In function 'int main()': a.cc:73:41: error: expected ']' before ')' token 73 | if(max(j[o[a]/2],j[o[a]/2+o[a]%2)>1) | ^ | ]
s322066689
p03988
C++
def check(a): a = sorted(a) d = {} for x in a: if x not in d.keys(): d[x] = 1 else: d[x] += 1 if (a[-1]+1)>>1 != a[0]: return False if (a[-1]&1) != 1 and d[a[0]]!=1: return False if (a[-1]&1) == 1 and d[a[0]]!=2: return False for i in xrange(a[-1], a[0], -1): if i not in d.keys() or d[i]<2: return False return True def main(): n = int(raw_input().strip()) a = [int(x) for x in raw_input().strip().split()] if check(a): print 'Possible' else: print 'Impossible' if __name__ == '__main__': main()
a.cc:24:15: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 24 | print 'Possible' | ^~~~~~~~~~ a.cc:26:15: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes 26 | print 'Impossible' | ^~~~~~~~~~~~ a.cc:28:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 28 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'def' does not name a type 1 | def check(a): | ^~~ a.cc:4:5: error: expected unqualified-id before 'for' 4 | for x in a: | ^~~
s558308626
p03988
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> typedef long long ll ; #define rep(i, a, b) for (int i = a; i <= b; ++ i) const int N = 500 ; using namespace std ; int n, a[N] ; int main() { scanf("%d", &n) ; int x ; rep(i, 1, n) scanf("%d", &x), ++ a[x] ; int x = 1 ; for ( ; !a[x] ; ++ x) ; if (a[x] == 1) { rep(i, x + 1, 2 * x) if (a[i] < 2) { puts("Impossible") ; return 0 ; } rep(i, 2 * x + 1, n - 1) if (a[i]) { puts("Impossible") ; return 0 ; } puts("Possible") ; } else if (a[x] == 2) { rep(i, x + 1, 2 * x - 1) if (a[i] < 2) { puts("Impossible") ; return 0 ; } rep(i, 2 * x, n - 1) if (a[i]) { puts("Impossible") ; return 0 ; } puts("Possible") ; } else puts("Impossible") ; return 0 ; }
a.cc: In function 'int main()': a.cc:17:13: error: redeclaration of 'int x' 17 | int x = 1 ; | ^ a.cc:15:13: note: 'int x' previously declared here 15 | int x ; | ^
s308636898
p03988
C++
#include <iostream> #include <vector> using namespace std; typedef long long lli; lli n; vector<lli> a; int pos(){ cout << "Possible" << endl; return 0; } int imp(){ cout << "Impossible" << endl; return 0; } int main(){ cin >> n; a = vector<lli> (n); for(lli i = 0;i < n;i++) cin >> a[i]; sort(a.begin(),a.end()); if(a.back()%2){ for(lli i = a.back();i >= (a.back()+1)/2+1;i--){ if(upper_bound(a.begin(),a.end(),i) - lower_bound(a.begin(),a.end(),i) < 2) return imp(); } if(upper_bound(a.begin(),a.end(),(a.back()+1)/2) - lower_bound(a.begin(),a.end(),(a.back()+1)/2) != 2) return imp(); if(a.front() < (a.back()+1)/2) return imp(); else return pos(); }else{ for(lli i = a.back();i >= a.back()/2 + 1;i--){ if(upper_bound(a.begin(),a.end(),i) - lower_bound(a.begin(),a.end(),i) < 2) return imp(); } if(upper_bound(a.begin(),a.end(),a.back()/2) - lower_bound(a.begin(),a.end(),a.back()/2) != 1) return imp(); if(a.back() < (a.back()/2)) return imp(); else return pos(); } return 0; }
a.cc: In function 'int main()': a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'? 19 | sort(a.begin(),a.end()); | ^~~~ | short a.cc:22:16: error: 'upper_bound' was not declared in this scope 22 | if(upper_bound(a.begin(),a.end(),i) - lower_bound(a.begin(),a.end(),i) < 2) return imp(); | ^~~~~~~~~~~ a.cc:24:12: error: 'upper_bound' was not declared in this scope 24 | if(upper_bound(a.begin(),a.end(),(a.back()+1)/2) - lower_bound(a.begin(),a.end(),(a.back()+1)/2) != 2) return imp(); | ^~~~~~~~~~~ a.cc:29:16: error: 'upper_bound' was not declared in this scope 29 | if(upper_bound(a.begin(),a.end(),i) - lower_bound(a.begin(),a.end(),i) < 2) return imp(); | ^~~~~~~~~~~ a.cc:31:12: error: 'upper_bound' was not declared in this scope 31 | if(upper_bound(a.begin(),a.end(),a.back()/2) - lower_bound(a.begin(),a.end(),a.back()/2) != 1) return imp(); | ^~~~~~~~~~~
s299021007
p03988
C++
#include <cstdio> #include <vector> #include <algorithm> #include <map> using namespace std; int main() { size_t N; scanf("%zu", &N); vector<int> a(N); map<int, int> m; int max_a=0; for (size_t i=0; i<N; ++i) { scanf("%d", &a[i]); ++m[a[i]]; if (max_a < a[i]) max_a = a[i]; } if (N == 2) return !printf("%sossible\n", m[1]==2? "P":"Imp"); for (int i=max_a; i>max_a/2; --i) { if (m[i] < 2) return !printf("Impossible\n"); } if (m[max_a/2] < 1-(max_a%2)) return !printf("Impossible\n"); for (i=max_a/2; --i;) if (m[i]) return !printf("Impossible\n"); if (m[1] > 1) return !printf("Impossible\n"); printf("Possible\n"); return 0; }
a.cc: In function 'int main()': a.cc:33:10: error: 'i' was not declared in this scope 33 | for (i=max_a/2; --i;) | ^
s268208923
p03988
C++
use std::cmp; fn main(){ let mut sc = Scanner::new(); while let Ok(n) = sc.wrapped() { let mut a = vec![0i32; n]; for e in a.iter_mut() { *e = sc.next(); } let solve = || { let mut cnt = vec![0; n+1]; let mut max = 0; for i in 0..n { cnt[a[i] as usize] += 1; max = cmp::max(max, a[i]); } let mut k = max; while k >= (max + 1) / 2 { let c = cnt[k as usize]; if max%2 == 0 { if k == (max + 1) / 2 { if c != 1 { return false; } } else { if c < 2 { return false; } } } else { if c < 2 { return false; } } k -= 1; } while k >= 0 { if cnt[k as usize] > 0 { return false; } k -= 1; } true }; println!("{}", if solve() { "Possible" } else { "Impossible" }) } } #[allow(dead_code)] struct Scanner { token_buffer : Vec<String>, index : usize, } #[allow(dead_code)] impl Scanner { fn new() -> Scanner{ Scanner { token_buffer: vec![], index: 0 } } fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr { let s = try!(self.fetch_token()); let t = try!(s.parse::<T>().map_err(|_| "Parse error")); Ok(t) } fn next<T>(& mut self) -> T where T: std::str::FromStr { self.wrapped::<T>().unwrap() } fn fetch_token(&mut self) -> Result<&String,&str> { while self.index >= self.token_buffer.len() { let mut st = String::new(); while st.trim() == "" { match std::io::stdin().read_line(&mut st) { Ok(l) if l > 0 => continue, Ok(_) => return Err("End of file"), Err(_) => return Err("Failed to read line"), } } self.token_buffer = st.split_whitespace() .map(|x| x.to_string()) .collect(); self.index = 0; } self.index += 1; Ok(&self.token_buffer[self.index - 1]) } }
a.cc:14:22: error: too many decimal points in number 14 | for i in 0..n { | ^~~~ a.cc:44:2: error: invalid preprocessing directive #[ 44 | #[allow(dead_code)] | ^ a.cc:50:2: error: invalid preprocessing directive #[ 50 | #[allow(dead_code)] | ^ a.cc:1:1: error: 'use' does not name a type 1 | use std::cmp; | ^~~ a.cc:3:1: error: 'fn' does not name a type 3 | fn main(){ | ^~ a.cc:46:5: error: 'token_buffer' does not name a type 46 | token_buffer : Vec<String>, | ^~~~~~~~~~~~ a.cc:51:6: error: expected initializer before 'Scanner' 51 | impl Scanner { | ^~~~~~~
s200474694
p03988
C++
#include <bits/stdc++.h> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define RI(X) scanf("%d", &(X)) #define RII(X, Y) scanf("%d%d", &(X), &(Y)) #define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z)) #define DRI(X) int (X); scanf("%d", &X) #define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y) #define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define F first #define S second #define RF(x) freopen(x,"r",stdin) #define WF(x) freopen(x,"w",stdout) typedef long long LL; using namespace std; typedef pair<LL,LL> PLL; typedef pair<int,int> PII; const LL MOD = 1e9+7; const int SIZE = 1e6+5; const LL INF = 1LL<<60; const double eps = 1e-4; const double PI=3.1415926535897932; int f[109],x[109]; int main(){ DRI(n); REP(i,n){ RI(x[i]); f[x[i]]++; } sort(x,x+n); if(f[0]>=2){ printf("Impossible");return 0; } int h=x[n-1]/2; if(x[n-1]%2){ REPP(i,h+1,x[n-1]+1){ if(f[i]<2){ printf("Impossible");return 0; } } REPP(i,h+1){ if(f[i]){ printf("Impossible");return 0; } } } else{ REPP(i,h+1,x[n-1]+1){ if(f[i]<2){ printf("Impossible");return 0; } } if(f[h]<1){ printf("Impossible");return 0; } REPP(i,h){ if(f[i]){ printf("Impossible");return 0; } } } printf("Possible"); }
a.cc:52:27: error: macro "REPP" requires 3 arguments, but only 2 given 52 | REPP(i,h+1){ | ^ a.cc:5:9: note: macro "REPP" defined here 5 | #define REPP(I, A, B) for (int I = (A); I < (B); ++I) | ^~~~ a.cc:67:25: error: macro "REPP" requires 3 arguments, but only 2 given 67 | REPP(i,h){ | ^ a.cc:5:9: note: macro "REPP" defined here 5 | #define REPP(I, A, B) for (int I = (A); I < (B); ++I) | ^~~~ a.cc: In function 'int main()': a.cc:52:17: error: 'REPP' was not declared in this scope 52 | REPP(i,h+1){ | ^~~~ a.cc:67:17: error: 'REPP' was not declared in this scope 67 | REPP(i,h){ | ^~~~
s240380824
p03988
C++
#include <iostream> #include <algorithm> using namespace std; void solve(); int main(int argc, char *argv[]) { if (argc == 2) { freopen(argv[1], "r", stdin); } else if (argc == 3) { freopen(argv[1], "r", stdin); freopen(argv[2], "w", stdout); } solve(); return 0; } const int N=100+10; int n,a[N],cnt[N]; bool check(int x, int y){ for(int i=x;i<=y;i++) if(cnt[i]>=2) return true; return false; } void solve() { while(cin>>n) { memset(cnt,0,sizeof(cnt)); for(int i=0;i<n;i++) { cin>>a[i]; cnt[a[i]]++; } sort(a,a+n); int minD=a[0], maxD=a[n-1]; bool flag=false; if(maxD==2*minD-1) { if(check(minD,maxD)) flag=true; } if(maxD==2*minD) { if(cnt[minD]==1&&check(minD+1,maxD)) flag=true; } if(flag) puts("Possible"); else puts("Impossible"); } }
a.cc: In function 'void solve()': a.cc:25:9: error: 'memset' was not declared in this scope 25 | memset(cnt,0,sizeof(cnt)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | using namespace std;
s091623895
p03988
C++
#include <iostream> #include <cstdio> #include <vector> #include <string> #include <set> #include <algorithm> using namespace std; #define mP make_pair #define pB push_back #define X first #define Y second int Abs(int x){ if(x < 0) return -x; else return x; } int main(){ int n; cin >> n; vector<int> v; for(int i = 0 ; i < n ; ++i){ int x; cin >> x; v.pB(x); } sort(v.begin() , v.end()); int cnt = 0; int tt = v[n - 1]; for(int i = n - 1 ; i >= 1 ; --i){ int ttt = 0; while(v[i] == tt) { --i; ++ttt; } if((i >= 0) && || Abs(v[i] - tt) > 1){ cout << "Impossible" << endl; return 0; } tt = v[i]; ++i; ++cnt; } //cout << cnt << endl; if(v[0] == cnt){ cout << "Possible" << endl; } else cout << "Impossible" << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:32: error: expected primary-expression before '||' token 42 | if((i >= 0) && || Abs(v[i] - tt) > 1){ | ^~
s471701220
p03988
C++
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <iomanip> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(int i = 0;i < n;++i) #define LONGINF 1000000000000000000 int main() { int n; cin >> n; vector<int> a; REP(i, n) { int tmp; cin >> tmp; a.push_back(tmp); } sort(a.begin(), a.end()); if (a[0] != (a[n - 1] + 1) / 2) goto impossible; if ((a[0]-1) * 2 + 1 > a[n - 1]) goto impossible; int cnt = 1; int hoge = a[1]; for (int i = 2;i < n;++i) { if (a[i] != hoge) { if (cnt == 1) goto impossible; cnt = 1; hoge = a[i]; }else{ cnt++; } } cout << "Possible" << endl; return 0; impossible:; cout << "Impossible" << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:1: error: jump to label 'impossible' 52 | impossible:; | ^~~~~~~~~~ a.cc:38:47: note: from here 38 | if ((a[0]-1) * 2 + 1 > a[n - 1]) goto impossible; | ^~~~~~~~~~ a.cc:40:13: note: crosses initialization of 'int hoge' 40 | int hoge = a[1]; | ^~~~ a.cc:39:13: note: crosses initialization of 'int cnt' 39 | int cnt = 1; | ^~~ a.cc:52:1: error: jump to label 'impossible' 52 | impossible:; | ^~~~~~~~~~ a.cc:37:46: note: from here 37 | if (a[0] != (a[n - 1] + 1) / 2) goto impossible; | ^~~~~~~~~~ a.cc:40:13: note: crosses initialization of 'int hoge' 40 | int hoge = a[1]; | ^~~~ a.cc:39:13: note: crosses initialization of 'int cnt' 39 | int cnt = 1; | ^~~
s174849537
p03988
C++
#include<iostream> #include<algorithm> #include<climits> #include<cmath> #include<cstdio> #include<cstdlib> #include<ctime> #include<string> #include<cstring> #include<vector> #include<stack> #include<queue> #include<set> #include<bitset> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> i_i; #define PI 3.141592653589793238462643383279 #define mod 1000000007LL #define rep(i, n) for(i = 0;i < n;++i) #define rep1(i, n) for(i = 1;i < n;++i) #define per(i, n) for(i = n - 1;i > -1;--i) #define int(x) int x; scanf("%d",&x) #define int2(x, y) int x, y; scanf("%d%d",&x, &y) #define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z) #define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z) #define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z) #define ll2(x, y) ll x, y; cin >> x >> y; #define scn(n, a) rep(i, n)cin >> a[i] #define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i] #define pri(x) cout << (x) << "\n" #define pri2(x, y) cout << (x) << " " << (y) << "\n" #define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n" #define pb push_back #define mp make_pair #define all(a) (a).begin(),(a).end() #define endl "\n" #define kabe puts("---------------------------") #define kara puts("") #define debug(x) cout << " --- " << (x) << "\n" #define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n" #define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n" #define X first #define Y second #define eps 0.0001 #define prid(x) printf("%.15lf\n", x) int a[100]; bool solve(void){ if(n == 2 && a[1] == 1)return true; if(a[1] == 1)return false; if(a[0] == 1){ int i; rep1(i, n)if(a[i] != 2)return false; return true; } return true; } signed main(void){ int i, j; for(int testcase = 0;testcase >= 0;testcase++){ int(n); scn(n, a); sort(a, a + n); puts(solve() ? "Possible" : "Impossible"); /*/ //*/ break; } return 0; }
a.cc: In function 'bool solve()': a.cc:54:6: error: 'n' was not declared in this scope; did you mean 'yn'? 54 | if(n == 2 && a[1] == 1)return true; | ^ | yn a.cc:58:13: error: 'n' was not declared in this scope 58 | rep1(i, n)if(a[i] != 2)return false; | ^ a.cc:25:34: note: in definition of macro 'rep1' 25 | #define rep1(i, n) for(i = 1;i < n;++i) | ^
s680295661
p03988
C++
#include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> using namespace std; template <class F, class T> void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } long int pow(long int n, int m){ if(m<=0){ return 1; }else{ return n * pow(n,m-1); } } typedef unsigned int uint; int main(){ int N; cin >> N; int a[N]; for(int i=0; i<N; ++i){ cin >> a[i]; } sort(&a[0], &a[N-1]); int ma = a[N-1]; bool ans = true; int p; if(N==2){ if(!(a[0]==1 && a[1]==1)){ ans = false; } }else if(ma<2){ if(N>2){ ans = false; } } if(!ans){ cout << "Impossible" << endl; return 0; if(ma%2==0){ if(!(a[0] == ma/2 && a[1] == ma/2+1)){ ans = false; } p = 1; }else{ if(!(a[0] == ma/2+1 && a[1] == ma/2+1 && a[2] == ma/2+2)){ ans = false; } p = 2; } if(!ans){ cout << "Impossible" << endl; return 0; } int now = a[p]-1; int count = 2; for(; p<N; ++p){ if(a[p] != now){ if(a[p] != now+1 || count < 2){ ans = false; break; }else{ now = a[p]; count = 1; } }else{ count++; } } if(count < 2){ ans = false; } if(ans){ cout << "Possible" << endl; }else{ cout << "Impossible" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:88:2: error: expected '}' at end of input 88 | } | ^ a.cc:25:11: note: to match this '{' 25 | int main(){ | ^
s151786391
p03988
C++
#include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> using namespace std; template <class F, class T> void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } long int pow(long int n, int m){ if(m<=0){ return 1; }else{ return n * pow(n,m-1); } } typedef unsigned int uint; int main(){ int N; cin >> N; int a[N]; for(int i=0; i<N; ++i){ cin >> a[i]; } sort(&a[0], &a[N-1]); int ma = a[N-1]; bool ans = true; int p; if(N==2){ if(!(a[0]==1 && a[1]==1)){ ans = false; }else if(ma<2){ if(N>2){ ans = false; } }else if(ma%2==0){ if(!(a[0] == ma/2 && a[1] == ma/2+1)){ ans = false; } p = 1; }else{ if(!(a[0] == ma/2+1 && a[1] == ma/2+1 && a[2] == ma/2+2)){ ans = false; } p = 2; } if(!ans){ cout << "Impossible" << endl; return 0; } int now = a[p]-1; int count = 2; for(; p<N; ++p){ if(a[p] != now){ if(a[p] != now+1 || count < 2){ ans = false; break; }else{ now = a[p]; count = 1; } }else{ count++; } } if(count < 2){ ans = false; } if(ans){ cout << "Possible" << endl; }else{ cout << "Impossible" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:82:2: error: expected '}' at end of input 82 | } | ^ a.cc:25:11: note: to match this '{' 25 | int main(){ | ^
s451387231
p03988
C++
#include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> using namespace std; template <class F, class T> void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } long int pow(long int n, int m){ if(m<=0){ return 1; }else{ return n * pow(n,m-1); } } typedef unsigned int uint; int main(){ int N; cin >> N; int a[N]; for(int i=0; i<N; ++i){ cin >> a[i]; } sort(&a[0], &a[N-1]); int ma = a[N-1]; bool ans = true; int p; if(N==2){ if(!(a[0]==1 && a[1]==1)){ ans = false; else if(ma<2){ if(N>2){ ans = false; } }else if(ma%2==0){ if(!(a[0] == ma/2 && a[1] == ma/2+1)){ ans = false; } p = 1; }else{ if(!(a[0] == ma/2+1 && a[1] == ma/2+1 && a[2] == ma/2+2)){ ans = false; } p = 2; } if(!ans){ cout << "Impossible" << endl; return 0; } int now = a[p]-1; int count = 2; for(; p<N; ++p){ if(a[p] != now){ if(a[p] != now+1 || count < 2){ ans = false; break; }else{ now = a[p]; count = 1; } }else{ count++; } } if(count < 2){ ans = false; } if(ans){ cout << "Possible" << endl; }else{ cout << "Impossible" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:39:3: error: expected '}' before 'else' 39 | else if(ma<2){ | ^~~~ a.cc:37:30: note: to match this '{' 37 | if(!(a[0]==1 && a[1]==1)){ | ^ a.cc:82:2: error: expected '}' at end of input 82 | } | ^ a.cc:25:11: note: to match this '{' 25 | int main(){ | ^
s657992932
p03988
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<ll,ll> #define ppa pair<int,pa> #define mp make_pair #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; struct Segment{ Point p1,p2; }; double hen(Vector a){ if(fabs(a.x)<EPS && a.y>0) return acos(0); else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0); else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0); else if(fabs(a.y)<EPS && a.x>0) return 0.0; else if(a.y>0) return acos(a.x/a.absv()); else return 2*acos(0)+acos(-a.x/a.absv()); } double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; //----------------kokomade temple------------ signed main(){ int n; cin>>n; int co[1000]={0}; int a[110]; for(int i=0;i<n;i++){ cin>>a[i]; co[a[i]]++; } sort(a,a+n); if(2*a[0]<a[n-1]){ cout<<"Impossible"<<endl; return 0; } if(a[n-1]>=n){ cout<<"Impossible"<<endl; return 0; } if(n==2){ if(a[0]==1 && a[1]==1){ cout<<"Possible"<<endl; } else{ cout<<"Impossible"<<endl; } return 0; } if(a[1]==1){ cout<<"Impossible"<<endl; return 0; } if(a[0]==1){ ///cout<<"s"<<endl; int b=0; for(int i=1;i<n;i++) if(a[i]!=2) b++; if(b==0){ cout<<"Possible"<<endl; } else{ cout<<"Impossible"<<endl; } return 0; } if(a[n-1]==n-1){ int b=0; for(int i=n-1;i>0;i--){ if(a[i]!= n-1-((n-1)-i)/2) b++; } if(b==0){ cout<<"Possible"<<endl; } else{ cout<<"Impossible"<<endl; } return 0; } if(a[0]> n/2){ cout<<"Impossible"<<endl; return 0; } if(a[n-1]!=a[n-2]){ cout<<"Impossible"<<endl; return 0; } if(a[0]==a[n-1]){ cout<<"Impossible"<<endl; return 0; } if(1){ int b=0; for(int i=a[0];i<=a[n-1];i++) if(co[i]==0) b++; if(b!=0){ cout<<"Impossible"<<endl; return 0; } } if(a[n-1]%2==0){ if(a[0]!=a[n-1]/2){ cout<<"Impossible"<<endl; return 0; } } if(a[n-1]%2==1){ if(a![0]=a[n-1]/2+1){ cout<<"Impossible"<<endl; return 0; } } cout<<"Possible"<<endl; return 0; } //printf("%.10f\n",ans);
a.cc: In function 'int main()': a.cc:160:21: error: expected ')' before '!' token 160 | if(a![0]=a[n-1]/2+1){ | ~ ^ | )
s535495924
p03988
C++
#include <bits/stdc++.h> #include <stdio.h> #include <ctype.h> #define y second #define x first #define lsb(x) (x&-x) #define pb push_back #define l(x) x<<1 #define r(x) (x<<1)|1 #define non(x) ( (x) > N? (x) - N : (x) + N) #define y second const int MOD=1000000007; //LOL const int MAXM=210*210; const int NMAX=6100; const int HP=73; const int SQRT=350; using namespace std; const double eps=1e-5; const double PI=acos(-1.0); typedef long long LL; typedef long double LD; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<LD, LD> PLD; typedef vector<int> VI; const int dx[]={-1, 0, 0, 1}; const int dy[]={0, 1, -1, 0}; int A[200666]; PII sortme[200666]; bool m[150]; LL rs; int n; int ac[1000]; set<int> S1,S2; bool cmp(int l, int r) { return l>r; } bool cmp2(int l, int r) { return l<r; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); //freopen("input.in", "rt", stdin); //freopen("output.out", "wt", stdout); cin>>n; for(int i=1; i<=n; ++i) cin>>A[i]; sort(A+1, A+1+n, cmp); if(A[1]!=A[2] || A[1]>=101) { cout<<"Impossible"; return 0; } int k=A[1]; for(int i=2; i<=k; ++i) { m[max(i-1, k+1-i)]--; ac[max(i-1, k+1-i)]++; } A[1]=-1; A[2]=-2; sort(A+1, A+1+n, cmp2); for(int i=3; i<=n; ++i) { if(!ac[A[i]]) { cout<<"Impossible"; return 0; } m[A[i]]++; ac[A[i]+1]++; } for(int i=2; i<=k; ++i) { if(m[max(i-1, k+1-i)]<0) { cout<<"Impossible"; return 0; } } cout<<"Possible"; return 0; }
a.cc: In function 'int main()': a.cc:62:34: error: use of an operand of type 'bool' in 'operator--' is forbidden 62 | m[max(i-1, k+1-i)]--; | ~~~~~~~~~~~~~~~~~^ a.cc:75:23: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17 75 | m[A[i]]++; | ~~~~~~^
s772687673
p03988
C
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define int long long const int MAX_N = 100; int N, A[MAX_N]; int cnt[MAX_N]; bool Solve() { int ma = 0, mi = MAX_N; for (int i = 0; i < N; i++) { mi = min(mi, A[i]); ma = max(ma, A[i]); cnt[A[i]]++; } if (N > 2 && ma < 2) return false; if (ma&1) { if (ma/2 + 1 != mi) return false; if (cnt[mi] < 2) return false; } else { if (ma/2 != mi) return false; if (cnt[mi] != 1) return false; } for (int i = mi + 1; i <= ma; i++) { if (cnt[i] < 2) return false; } return true; } signed main() { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } if (Solve()) puts("Possible"); else puts("Impossible"); return 0; }
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory 2 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s211684544
p03988
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; vector<int> v; cin>>N; v.resize(N); for(int i=0; i<N; i++){ cin>>v[i]; } sort(v.begin(), v.end()); if(v[N-1]!=v[N-2]){ cout<<"Impossible"<<endl; }else if(N!=2 && v[1]==1){ cout<<"Impossible"<<endl; }else{ cout<<"Possible"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'sort' was not declared in this scope; did you mean 'short'? 17 | sort(v.begin(), v.end()); | ^~~~ | short
s331423943
p03988
C++
main(){puts("Possible");}
a.cc:1:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 1 | main(){puts("Possible");} | ^~~~ a.cc: In function 'int main()': a.cc:1:8: error: 'puts' was not declared in this scope 1 | main(){puts("Possible");} | ^~~~
s266550554
p03988
C++
import random print(random.choice(['Possible','Impossible']))
a.cc:2:22: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 2 | print(random.choice(['Possible','Impossible'])) | ^~~~~~~~~~ a.cc:2:33: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes 2 | print(random.choice(['Possible','Impossible'])) | ^~~~~~~~~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import random | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s435359113
p03989
C
#include<bits/stdc++.h> #define pb push_back #define ins insert #define F first #define S second #define var auto using namespace std; typedef long long ll; const int Mod = 924844033; const int Max = 4010; ll dp[Max][Max]; ll numofway[Max][Max]; ll fact[Max]; void Solve(vector<int> A , int cntOfElem) { int n = A.size() - 1;//there exists A[i] for every i from 1 to n numofway[0][0] = numofway[1][0] = numofway[1][1] = 1; for(int a = 2; a < Max; a++) { numofway[a][0] = 1; for(int cnt = 1; cnt <= a; cnt++) { numofway[a][cnt] = (numofway[a - 1][cnt] + numofway[a - 2][cnt - 1]) % Mod; } } for(int cnt = 0; cnt <= A[n]; cnt++) { dp[n][cnt] = numofway[A[n]][cnt]; } for(int i = n - 1; i >= 1; i--) { dp[i][0] = 1; for(int cnt = 1; cnt <= cntOfElem; cnt++) { for(int j = 0; j <= A[i] && j <= cnt; j++) { dp[i][cnt] += (dp[i + 1][cnt - j] * numofway[A[i]][j]) % Mod; } dp[i][cnt] %= Mod; } } fact[0] = 1; for(int i = 1; i < Max; i++) fact[i] = (fact[i - 1] * i) % Mod; ll ans = 0; int sign = 1; for(int i = 0; i <= cntOfElem; i++) { ans = (ans + sign * (dp[1][i] * fact[cntOfElem - i] % Mod) + Mod ) % Mod; sign = -sign; } cout << ans << '\n';; } int main() { int n , k;cin >> n >> k; int badCnt = 2 * (n - k); int mn = badCnt / (2 * k); int bgcnt = badCnt % (2 * k); vector<int> A;A.pb(0); for(int i = 0 ; i < 2 * k ; i++) if(i < bgcnt) A.pb(mn + 1); else A.pb(mn); Solve(A , n); }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s990792359
p03989
C++
#include<bits/stdc++.h> using namespace std; const long long delta = 924844033, maxn = 2005; long long pat_chos[maxn][maxn]; void calc_pat_chos(){ for(long long i = 0; i < maxn; i++) pat_chos[i][0] = pat_chos[i][1] = 1; pat_chos[0][1] = 0; for(long long i = 2; i < maxn; i++) for(long long j = 1; j < maxn; j++) pat_chos[i][j] = (pat_chos[i - 1][j] + pat_chos[i - 2][j - 1]) % delta; } long long dp[maxn][maxn]; long long fact[maxn]; void nap(vector<long long> &v){ dp[0][0] = true; for(long long i = 1; i <= (long long)(v.size()); i++){ for(long long x = 0; x <= v[i - 1]; x++) for(long long sm = 0; sm < maxn; sm++) dp[i][sm] = (dp[i][sm] + dp[i - 1][sm - x] * pat_chos[v[i - 1]][x]) % delta; } fact[0] = 1; for(long long i = 1; i < maxn; i++) fact[i] = (fact[i - 1] * i) % delta; } void solve(long long n, long long k){ vector<long long> v; for(long long i = 0; i < k; i++){ v.push_back(n / k - 1 + (i < (n % k))); v.push_back(n / k - 1 + (i < (n % k))); } nap(v); long long ans = 0; for(long long i = 0; i <= n; i++) ans = (ans + delta + (((i & 1) * (-1) + ((i & 1) == 0) ) * ((fact[n - i] * dp[v.size()][i]) % delta)) % delta; cout << ans; } int main(){ calc_pat_chos(); long long n, k; cin >> n>> k; solve(n, k); }
a.cc: In function 'void solve(long long int, long long int)': a.cc:42:118: error: expected ')' before ';' token 42 | ans = (ans + delta + (((i & 1) * (-1) + ((i & 1) == 0) ) * ((fact[n - i] * dp[v.size()][i]) % delta)) % delta; | ~ ^ | )
s624047859
p03989
C++
#include<bits/stdc++.h> using namespace std; const long long delta = 924844033, maxn = 2005; long long pat_chos[maxn][maxn]; void calc_pat_chos(){ for(long long i = 0; i < maxn; i++) pat_chos[i][0] = pat_chos[i][1] = 1; pat_chos[0][1] = 0; for(long long i = 2; i < maxn; i++) for(long long j = 1; j < maxn; j++) pat_chos[i][j] = (pat_chos[i - 1][j] + pat_chos[i - 2][j - 1]) % delta; } long long dp[maxn][maxn]; long long fact[maxn]; void nap(vector<long long> &v){ dp[0][0] = true; for(long long i = 1; i <= long long(v.size()); i++){ for(long long x = 0; x <= v[i - 1]; x++) for(long long sm = 0; sm < maxn; sm++) dp[i][sm] = (dp[i][sm] + dp[i - 1][sm - x] * pat_chos[v[i - 1]][x]) % delta;//,cout << i << ' ' <<v[i - 1]<<' '<< x << ' ' << sm<<' '<<pat_chos[v[i]][x] << endl; //for(long long sm = 0; sm < maxn; sm++) // cout << dp[i][sm]<<' '; //cout << endl; } fact[0] = 1; for(long long i = 1; i < maxn; i++) fact[i] = (fact[i - 1] * i) % delta; } void solve(long long n, long long k){ //cout <<"F"<<(n % k) << ' ' <<(k - (n % k))<<endl; vector<long long> v; for(long long i = 0; i < k; i++){ v.push_back(n / k - 1 + (i < (n % k))); v.push_back(n / k - 1 + (i < (n % k))); } //cout <<"show"<<endl; //for(auto a : v) // cout << a << ' '; //cout << endl; nap(v); long long ans = 0; for(long long i = 0; i <= n; i++) ans = (ans + delta + ((((i & 1) * (-1) + ((i & 1) == 0) ) * fact[n - i]) % delta ) * dp[v.size()][i]) % delta;//, cout << fact[n - i] * dp[v.size()][i]<<' '<<((i & 1) * (-1) + ((i & 1) == 0) )<< endl; cout << ans<<endl; } int main(){ calc_pat_chos(); long long n, k; cin >> n>> k; solve(n, k); }
a.cc: In function 'void nap(std::vector<long long int>&)': a.cc:22:31: error: expected primary-expression before 'long' 22 | for(long long i = 1; i <= long long(v.size()); i++){ | ^~~~ a.cc:22:30: error: expected ';' before 'long' 22 | for(long long i = 1; i <= long long(v.size()); i++){ | ^~~~~ | ; a.cc:22:31: error: expected primary-expression before 'long' 22 | for(long long i = 1; i <= long long(v.size()); i++){ | ^~~~ a.cc:22:30: error: expected ')' before 'long' 22 | for(long long i = 1; i <= long long(v.size()); i++){ | ~ ^~~~~ | ) a.cc:22:31: error: expected primary-expression before 'long' 22 | for(long long i = 1; i <= long long(v.size()); i++){ | ^~~~ a.cc:22:52: error: 'i' was not declared in this scope 22 | for(long long i = 1; i <= long long(v.size()); i++){ | ^
s970824750
p03989
Java
import java.io.*; import java.util.*; public class TaskA { //FastIO io = new FastIO("in.txt"); int N, M; long[][] dp; static long MOD = 1000000007; static long[] FS = new long[1005]; void init(){ FS[0] = 1; for(int i=1; i<1005; i++){ FS[i] = (FS[i-1] * i) % MOD; } } long solve(){ init(); dp = new long[N][N+1]; for(int i=0; i<N; i++){ dp[i][0] = 1; } for(int i=1; i<N; i++){ for(int k=1; k<=N; k++) { int j = i - M; if (j >= 0) { dp[i][k] += dp[i-1][k-1] * 2; if(k - 2 >= 0){ dp[i][k] += dp[i-1][k-2]; } } } } long ans = FS[N], f = -1; for(int k=1; k<=N; k++){ ans += f * dp[N-1][k] * FS[N - k]; f = f * -1; ans %= MOD; } return ans; } public void main() throws Exception { N = io.nextInt(); M = io.nextInt(); io.out(solve() + "\n"); } public static void main(String[] args) throws Exception { TaskA task = new TaskA(); task.main(); } class FastIO { BufferedReader br; StringTokenizer sk; public FastIO(String fname){ try{ File f = new File(fname); if(f.exists()) { System.setIn(new FileInputStream(fname)); } }catch (Exception e){ throw new IllegalArgumentException(e); } br = new BufferedReader(new InputStreamReader(System.in)); } public FastIO(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(sk==null || !sk.hasMoreElements()){ try { sk = new StringTokenizer(br.readLine()); }catch (Exception e){ throw new IllegalArgumentException(e); } } return sk.nextToken(); } public int nextInt(){ return Integer.parseInt(next()); } public char nextChar(){ return next().charAt(0); } public long nextLong(){ return Long.parseLong(next()); } public double nextDouble(){ return Double.parseDouble(next()); } public String nextLine(){ String str = ""; try { str = br.readLine(); }catch (Exception e){ e.printStackTrace(); } return str; } public void out(String v){ System.out.print(v); } public void out(int v) { System.out.print(v); } public void out(long v){ System.out.print(v); } public void out(double v) { System.out.print(v); } } }
Main.java:4: error: class TaskA is public, should be declared in a file named TaskA.java public class TaskA { ^ Main.java:47: error: cannot find symbol N = io.nextInt(); M = io.nextInt(); ^ symbol: variable io location: class TaskA Main.java:47: error: cannot find symbol N = io.nextInt(); M = io.nextInt(); ^ symbol: variable io location: class TaskA Main.java:48: error: cannot find symbol io.out(solve() + "\n"); ^ symbol: variable io location: class TaskA 4 errors
s684532931
p03989
C++
#include <iostream> #include <vector> #include <map> using namespace std; typedef long long ll; const int MOD = 924844033; struct Modint { ll val; Modint (ll _val = 0) : val(_val % MOD) {} Modint operator+ (Modint other) const { return Modint(val + other.val); } void operator+= (Modint other) { val += other.val; val %= MOD; } Modint operator- () const { return Modint(MOD - val); } Modint operator- (Modint other) const { return Modint(val + MOD - other.val); } void operator-= (Modint other) { val += MOD - other.val; val %= MOD; } Modint operator* (Modint other) const { return Modint(val * other.val); } void operator*= (Modint other) { val *= other.val; val %= MOD; } bool operator== (Modint other) const { return val == other.val; } bool operator!= (Modint other) const { return val != other.val; } }; Modint exp (Modint a, int k) { if (k == 0) { return Modint(1); } else if (k % 2 == 0) { Modint half = exp(a, k / 2); return half * half; } else { return a * exp(a, k - 1); } } Modint inv (Modint a) { return exp(a, MOD - 2); } ostream& operator<< (ostream& out, Modint p) { out << p.val; return out; } const int MAX_N = 1 << 11 const Modint inv2 = inv(Modint(2)); Modint dp [MAX_N / 2][MAX_N / 2][3]; // position, # of things, is last taken vector<Modint> do_dp (int n, int ls, int rs) { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= 2; k++) { dp[i][j][k] = Modint(0); } } } if (n == -1) { vector<Modint> ans (2); ans[0] = Modint(1); ans[1] = Modint(0); return ans; } if (n == 1 && (ls == 1 || rs == 1)) { vector<Modint> ans (2, Modint(1)); return ans; } if (ls) { dp[1][0][0] = Modint(1); dp[1][1][2] = Modint(1); } else { dp[1][0][0] = Modint(1); dp[1][1][1] = Modint(1); dp[1][1][2] = Modint(1); } for (int i = 1; i < n; i++) { for (int j = 0; j < n; j++) { dp[i + 1][j][0] += dp[i][j][0]; dp[i + 1][j + 1][1] += dp[i][j][0]; dp[i + 1][j + 1][2] += dp[i][j][0]; dp[i + 1][j][0] += dp[i][j][1]; dp[i + 1][j + 1][1] += dp[i][j][1]; dp[i + 1][j + 1][2] += dp[i][j][1]; dp[i + 1][j][0] += dp[i][j][2]; dp[i + 1][j + 1][2] += dp[i][j][2]; } } vector<Modint> ans (n + 1); for (int i = 0; i <= n; i++) { ans[i] = dp[n][i][0] + dp[n][i][1]; if (!rs) { ans[i] += dp[n][i][2]; } } return ans; } typedef pair<int, pair<int, int>> type; type get_type (int u, int n, int k) { if (u - k <= 0 && u + k > n) return make_pair(-1, make_pair(0, 0)); int fst = u; int len = 1; while (true) { if (u + 2 * k > n) break; u += 2 * k; len++; } int lst = u; int ls = 0; if (fst - k <= 0) ls = 1; int rs = 0; if (lst + k > n) rs = 1; return make_pair(len, make_pair(ls, rs)); } vector<Modint> mul (vector<Modint> p, vector<Modint> q) { vector<Modint> ans ((int) p.size() + (int) q.size() - 1, Modint(0)); for (int i = 0; i < (int) p.size(); i++) { for (int j = 0; j < (int) q.size(); j++) { ans[i + j] += p[i] * q[j]; } } return ans; } vector<Modint> exp (vector<Modint> p, int k) { if (k == 0) { return vector<Modint> (1, Modint(1)); } else if (k % 2 == 0) { auto half = exp(p, k / 2); return mul(half, half); } else { return mul(p, exp(p, k - 1)); } } Modint fact [MAX_N]; int main () { fact[0] = Modint(1); for (int i = 1; i < MAX_N; i++) { fact[i] = Modint(i) * fact[i - 1]; } ios::sync_with_stdio(false); int n, k; cin >> n >> k; map<type, int> cnt; for (int i = 1; i <= min(n, 2 * k); i++) { type cur = get_type(i, n, k); if (cnt.find(cur) == cnt.end()) { cnt[cur] = 0; } cnt[cur]++; } vector<Modint> ans (1, Modint(1)); for (auto it = cnt.begin(); it != cnt.end(); it++) { vector<Modint> cur = do_dp(it->first.first, it->first.second.first, it->first.second.second); cur = exp(cur, it->second); ans = mul(ans, cur); } Modint sol (0); for (int i = 0; i <= n; i++) { Modint add = ans[i] * fact[n - i]; if (i % 2 == 0) sol += add; else sol += Modint(MOD - 1) * add; } cout << sol << endl; }
a.cc:78:1: error: expected ',' or ';' before 'const' 78 | const Modint inv2 = inv(Modint(2)); | ^~~~~
s004998278
p03989
C++
#include <iostream> #include <algorithm> #include <utility> #include <vector> #include <numeric> #include <array> template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; } struct range { using int_ = int_fast64_t; struct itr { int_ i; constexpr itr(int_ i_): i(i_) { } constexpr void operator ++ () { ++i; } constexpr int_ operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr range(int_ l_, int_ r_): l(l_), r(std::max(l_, r_)) { } constexpr itr begin() const { return l; } constexpr itr end() const { return r; } }; struct revrange { using int_ = int_fast64_t; struct itr { int_ i; constexpr itr(int_ i_): i(i_) { } constexpr void operator ++ () { --i; } constexpr int_ operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr revrange(int_ l_, int_ r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } constexpr itr begin() const { return r; } constexpr itr end() const { return l; } }; using i32 = int_fast32_t; using i64 = int_fast64_t; using u32 = uint_fast32_t; using u64 = uint_fast64_t; constexpr i32 inf32 = (i32(1) << 30) - 1; constexpr i64 inf64 = (i64(1) << 62) - 1; template <uint_fast32_t Modulus> class modular { public: using value_type = uint_fast32_t; using max_type = uint_fast64_t; static constexpr value_type mod = Modulus; static constexpr value_type mod_min = 1; static constexpr value_type mod_max = 2147483647; static_assert(mod >= mod_min, "invalid mod :: too small"); static_assert(mod <= mod_max, "invalid mod :: too big"); template <class T> static constexpr value_type normalize(T value_) { if (value_ < 0) { value_ = -value_; value_ %= mod; if (value_ == 0) return 0; return mod - value_; } return value_ % mod; } private: value_type value; public: constexpr modular(): value(0) { } template <class T> explicit constexpr modular(T value_): value(normalize(value_)) { } template <class T> explicit constexpr operator T() { return static_cast<T>(value); } constexpr value_type operator () () const { return value; } constexpr modular operator - () const { return modular(mod - value); } constexpr modular operator ~ () const { return inverse(); } constexpr value_type &extract() { return value; } constexpr modular inverse() const { return power(mod - 2); } constexpr modular power(max_type exp) const { modular res(1), mult(*this); while (exp > 0) { if (exp & 1) res *= mult; mult *= mult; exp >>= 1; } return res; } constexpr modular operator + (const modular &rhs) const { return modular(*this) += rhs; } constexpr modular& operator += (const modular &rhs) { if ((value += rhs.value) >= mod) value -= mod; return *this; } constexpr modular operator - (const modular &rhs) const { return modular(*this) -= rhs; } constexpr modular& operator -= (const modular &rhs) { if ((value += mod - rhs.value) >= mod) value -= mod; return *this; } constexpr modular operator * (const modular &rhs) const { return modular(*this) *= rhs; } constexpr modular& operator *= (const modular &rhs) { value = (max_type) value * rhs.value % mod; return *this; } constexpr modular operator / (const modular &rhs) const { return modular(*this) /= rhs; } constexpr modular& operator /= (const modular &rhs) { return (*this) *= rhs.inverse(); } constexpr bool zero() const { return value == 0; } constexpr bool operator == (const modular &rhs) const { return value == rhs.value; } constexpr bool operator != (const modular &rhs) const { return value != rhs.value; } friend std::ostream& operator << (std::ostream &stream, const modular &rhs) { return stream << rhs.value; } }; template <class T, std::size_t N> class factorials { public: using value_type = T; static constexpr std::size_t size = N; public: std::array<value_type, size + 1> fact{}; std::array<value_type, size + 1> fact_inv{}; factorials() { fact.front() = value_type(1); for (std::size_t i = 1; i <= size; ++i) { fact[i] = fact[i - 1] * value_type(i); } fact_inv.back() = ~fact.back(); for (std::size_t i = size; i > 0; --i) { fact_inv[i - 1] = fact_inv[i] * value_type(i); } } value_type operator () (std::size_t n, std::size_t r) const { return fact[n] * fact_inv[n - r] * fact_inv[r]; } }; using m32 = modular<924844033>; factorials<m32, 1000> fact; template <class T, int N, int I = 0> auto gen_vec(const int (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { return value; } template <class T, int N, int I = 0> auto gen_vec(const int (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { return std::vector<decltype(gen_vec<T, N, I + 1>(list, value))>(list[I], gen_vec<T, N, I + 1>(list, value)); } int main() { i32 N, K; std::cin >> N >> K; if (K > (N - 1) / 2) { m32 ans; i32 size = 2 * (N - K); for (auto i: range(0, size + 1)) { if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; else ans += fact(size, i) * fact.fact[N - i]; } std::cout << ans << '\n'; } else { auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); dp[0][0] = (m32) 1; for (auto i: range(0, 2 * K)) { i32 size = N / (2 * K) + i32(N % (2 * K) > i); auto ndp = gen_vec<m32>({ size, size + 1, 2 }); ndp[0][1][1] = (m32) 1; ndp[0][0][0] = (m32) 1; if (i >= K) ndp[0][1][0] = (m32) 1; for (auto j: range(0, size - 1)) { for (auto k: range(0, j + 2)) { ndp[j + 1][k][0] += ndp[j][k][0]; ndp[j + 1][k][0] += ndp[j][k][1]; ndp[j + 1][k + 1][0] += ndp[j][k][0]; if (i + (j + 1) * (2 * K) + K < N) { ndp[j + 1][k + 1][1] += ndp[j][k][0]; ndp[j + 1][k + 1][1] += ndp[j][k][1]; } } } for (auto j: range(0, N + 1)) { for (auto k: range(0, size + 1)) { if (j + k <= N) { dp[i + 1][j + k] += dp[i][j] * (ndp[size - 1][k][0] + ndp[size - 1][k][1]); } } } } m32 ans; for (auto i: range(0, N + 1)) { if (i & 1) ans -= dp[2 * K][i] * fact.fact[N - i]; else ans += dp[2 * K][i] * fact.fact[N - i]; } std::cout << ans << '\n'; } return 0; }
a.cc:22:16: error: 'int_fast64_t' does not name a type 22 | using int_ = int_fast64_t; | ^~~~~~~~~~~~ a.cc:24:5: error: 'int_' does not name a type; did you mean 'int'? 24 | int_ i; | ^~~~ | int a.cc:25:23: error: expected ')' before 'i_' 25 | constexpr itr(int_ i_): i(i_) { } | ~ ^~~ | ) a.cc:27:15: error: 'int_' does not name a type; did you mean 'int'? 27 | constexpr int_ operator * () const { return i; } | ^~~~ | int a.cc:31:23: error: expected ')' before 'l_' 31 | constexpr range(int_ l_, int_ r_): l(l_), r(std::max(l_, r_)) { } | ~ ^~~ | ) a.cc: In member function 'constexpr void range::itr::operator++()': a.cc:26:39: error: 'i' was not declared in this scope 26 | constexpr void operator ++ () { ++i; } | ^ a.cc: In member function 'constexpr bool range::itr::operator!=(range::itr) const': a.cc:28:55: error: 'i' was not declared in this scope 28 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc:28:62: error: 'struct range::itr' has no member named 'i' 28 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc: At global scope: a.cc:37:16: error: 'int_fast64_t' does not name a type 37 | using int_ = int_fast64_t; | ^~~~~~~~~~~~ a.cc:39:5: error: 'int_' does not name a type; did you mean 'int'? 39 | int_ i; | ^~~~ | int a.cc:40:23: error: expected ')' before 'i_' 40 | constexpr itr(int_ i_): i(i_) { } | ~ ^~~ | ) a.cc:42:15: error: 'int_' does not name a type; did you mean 'int'? 42 | constexpr int_ operator * () const { return i; } | ^~~~ | int a.cc:46:26: error: expected ')' before 'l_' 46 | constexpr revrange(int_ l_, int_ r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } | ~ ^~~ | ) a.cc: In member function 'constexpr void revrange::itr::operator++()': a.cc:41:39: error: 'i' was not declared in this scope 41 | constexpr void operator ++ () { --i; } | ^ a.cc: In member function 'constexpr bool revrange::itr::operator!=(revrange::itr) const': a.cc:43:55: error: 'i' was not declared in this scope 43 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc:43:62: error: 'struct revrange::itr' has no member named 'i' 43 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc: At global scope: a.cc:51:13: error: 'int_fast32_t' does not name a type 51 | using i32 = int_fast32_t; | ^~~~~~~~~~~~ a.cc:52:13: error: 'int_fast64_t' does not name a type 52 | using i64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:53:13: error: 'uint_fast32_t' does not name a type 53 | using u32 = uint_fast32_t; | ^~~~~~~~~~~~~ a.cc:54:13: error: 'uint_fast64_t' does not name a type 54 | using u64 = uint_fast64_t; | ^~~~~~~~~~~~~ a.cc:56:11: error: 'i32' does not name a type 56 | constexpr i32 inf32 = (i32(1) << 30) - 1; | ^~~ a.cc:57:11: error: 'i64' does not name a type 57 | constexpr i64 inf64 = (i64(1) << 62) - 1; | ^~~ a.cc:59:11: error: 'uint_fast32_t' has not been declared 59 | template <uint_fast32_t Modulus> | ^~~~~~~~~~~~~ a.cc:62:22: error: 'uint_fast32_t' does not name a type 62 | using value_type = uint_fast32_t; | ^~~~~~~~~~~~~ a.cc:63:20: error: 'uint_fast64_t' does not name a type 63 | using max_type = uint_fast64_t; | ^~~~~~~~~~~~~ a.cc:65:20: error: 'value_type' does not name a type 65 | static constexpr value_type mod = Modulus; | ^~~~~~~~~~ a.cc:66:20: error: 'value_type' does not name a type 66 | static constexpr value_type mod_min = 1; | ^~~~~~~~~~ a.cc:67:20: error: 'value_type' does not name a type 67 | static constexpr value_type mod_max = 2147483647; | ^~~~~~~~~~ a.cc:68:17: error: 'mod' was not declared in this scope 68 | static_assert(mod >= mod_min, "invalid mod :: too small"); | ^~~ a.cc:68:24: error: 'mod_min' was not declared in this scope 68 | static_assert(mod >= mod_min, "invalid mod :: too small"); | ^~~~~~~ a.cc:69:17: error: 'mod' was not declared in this scope 69 | static_assert(mod <= mod_max, "invalid mod :: too big"); | ^~~ a.cc:69:24: error: 'mod_max' was not declared in this scope 69 | static_assert(mod <= mod_max, "invalid mod :: too big"); | ^~~~~~~ a.cc:72:20: error: 'value_type' does not name a type 72 | static constexpr value_type normalize(T value_) { | ^~~~~~~~~~ a.cc:83:3: error: 'value_type' does not name a type 83 | value_type value; | ^~~~~~~~~~ a.cc:92:13: error: 'value_type' does not name a type 92 | constexpr value_type operator () () const { return value; } | ^~~~~~~~~~ a.cc:96:13: error: 'value_type' does not name a type 96 | constexpr value_type &extract() { return value; } | ^~~~~~~~~~ a.cc:98:27: error: 'max_type' has not been declared 98 | constexpr modular power(max_type exp) const { | ^~~~~~~~ a.cc:166:12: error: 'm32' was not declared in this scope 166 | factorials<m32, 1000> fact; | ^~~ a.cc:166:21: error: template argument 1 is invalid 166 | factorials<m32, 1000> fact; | ^ a.cc: In function 'int main()': a.cc:179:3: error: 'i32' was not declared in this scope 179 | i32 N, K; | ^~~ a.cc:180:15: error: 'N' was not declared in this scope 180 | std::cin >> N >> K; | ^ a.cc:180:20: error: 'K' was not declared in this scope 180 | std::cin >> N >> K; | ^ a.cc:182:5: error: 'm32' was not declared in this scope 182 | m32 ans; | ^~~ a.cc:183:8: error: expected ';' before 'size' 183 | i32 size = 2 * (N - K); | ^~~~~ | ; a.cc:184:27: error: 'size' was not declared in this scope; did you mean 'std::size'? 184 | for (auto i: range(0, size + 1)) { | ^~~~ | std::size In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/range_access.h:272:5: note: 'std::size' declared here 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ a.cc:185:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 185 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ^~~ | abs a.cc:185:29: error: 'fact' cannot be used as a function 185 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ~~~~^~~~~~~~~ a.cc:185:46: error: request for member 'fact' in 'fact', which is of non-class type 'int' 185 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ^~~~ a.cc:186:12: error: 'ans' was not declared in this scope; did you mean 'abs'? 186 | else ans += fact(size, i) * fact.fact[N - i]; | ^~~ | abs a.cc:186:23: error: 'fact' cannot be used as a function 186 | else ans += fact(size, i) * fact.fact[N - i]; | ~~~~^~~~~~~~~ a.cc:186:40: error: request for member 'fact' in 'fact', which is of non-class type 'int' 186 | else ans += fact(size, i) * fact.fact[N - i]; | ^~~~ a.cc:188:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 188 | std::cout << ans << '\n'; | ^~~ | abs a.cc:191:23: error: 'm32' was not declared in this scope 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ^~~ a.cc:191:27: error: no matching function for call to 'gen_vec<<expression error> >(<brace-enclosed initializer list>)' 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:169:6: note: candidate: 'template<class T, int N, int I> auto gen_vec(const int (&)[N], typename std::enable_if<(I == N), const T&>::type)' 169 | auto gen_vec(const int (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { | ^~~~~~~ a.cc:169:6: note: template argument deduction/substitution failed: a.cc:191:27: error: template argument 1 is invalid 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:174:6: note: candidate: 'template<class T, int N, int I> auto gen_vec(const int (&)[N], typename std::enable_if<(I != N), const T&>::type)' 174 | auto gen_vec(const int (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { | ^~~~~~~ a.cc:174:6: note: template argument deduction/substitution failed: a.cc:191:27: error: template argument 1 is invalid 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:194:10: error: expected ';' before 'size' 194 | i32 size = N
s349917679
p03989
C++
#include <iostream> #include <algorithm> #include <utility> #include <vector> #include <numeric> #include <array> template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; } struct range { using int_ = int_fast64_t; struct itr { int_ i; constexpr itr(int_ i_): i(i_) { } constexpr void operator ++ () { ++i; } constexpr int_ operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr range(int_ l_, int_ r_): l(l_), r(std::max(l_, r_)) { } constexpr itr begin() const { return l; } constexpr itr end() const { return r; } }; struct revrange { using int_ = int_fast64_t; struct itr { int_ i; constexpr itr(int_ i_): i(i_) { } constexpr void operator ++ () { --i; } constexpr int_ operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr revrange(int_ l_, int_ r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } constexpr itr begin() const { return r; } constexpr itr end() const { return l; } }; using i32 = int_fast32_t; using i64 = int_fast64_t; using u32 = uint_fast32_t; using u64 = uint_fast64_t; constexpr i32 inf32 = (i32(1) << 30) - 1; constexpr i64 inf64 = (i64(1) << 62) - 1; template <uint_fast32_t Modulus> class modular { public: using value_type = uint_fast32_t; using max_type = uint_fast64_t; static constexpr value_type mod = Modulus; static constexpr value_type mod_min = 1; static constexpr value_type mod_max = 2147483647; static_assert(mod >= mod_min, "invalid mod :: too small"); static_assert(mod <= mod_max, "invalid mod :: too big"); template <class T> static constexpr value_type normalize(T value_) { if (value_ < 0) { value_ = -value_; value_ %= mod; if (value_ == 0) return 0; return mod - value_; } return value_ % mod; } private: value_type value; public: constexpr modular(): value(0) { } template <class T> explicit constexpr modular(T value_): value(normalize(value_)) { } template <class T> explicit constexpr operator T() { return static_cast<T>(value); } constexpr value_type operator () () const { return value; } constexpr modular operator - () const { return modular(mod - value); } constexpr modular operator ~ () const { return inverse(); } constexpr value_type &extract() { return value; } constexpr modular inverse() const { return power(mod - 2); } constexpr modular power(max_type exp) const { modular res(1), mult(*this); while (exp > 0) { if (exp & 1) res *= mult; mult *= mult; exp >>= 1; } return res; } constexpr modular operator + (const modular &rhs) const { return modular(*this) += rhs; } constexpr modular& operator += (const modular &rhs) { if ((value += rhs.value) >= mod) value -= mod; return *this; } constexpr modular operator - (const modular &rhs) const { return modular(*this) -= rhs; } constexpr modular& operator -= (const modular &rhs) { if ((value += mod - rhs.value) >= mod) value -= mod; return *this; } constexpr modular operator * (const modular &rhs) const { return modular(*this) *= rhs; } constexpr modular& operator *= (const modular &rhs) { value = (max_type) value * rhs.value % mod; return *this; } constexpr modular operator / (const modular &rhs) const { return modular(*this) /= rhs; } constexpr modular& operator /= (const modular &rhs) { return (*this) *= rhs.inverse(); } constexpr bool zero() const { return value == 0; } constexpr bool operator == (const modular &rhs) const { return value == rhs.value; } constexpr bool operator != (const modular &rhs) const { return value != rhs.value; } friend std::ostream& operator << (std::ostream &stream, const modular &rhs) { return stream << rhs.value; } }; template <class T, std::size_t N> class factorials { public: using value_type = T; static constexpr std::size_t size = N; public: std::array<value_type, size + 1> fact{}; std::array<value_type, size + 1> fact_inv{}; factorials() { fact.front() = value_type(1); for (std::size_t i = 1; i <= size; ++i) { fact[i] = fact[i - 1] * value_type(i); } fact_inv.back() = ~fact.back(); for (std::size_t i = size; i > 0; --i) { fact_inv[i - 1] = fact_inv[i] * value_type(i); } } value_type operator () (std::size_t n, std::size_t r) const { return fact[n] * fact_inv[n - r] * fact_inv[r]; } }; using m32 = modular<924844033>; factorials<m32, 1000> fact; template <class T, size_t N, size_t I = 0> decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { return value; } template <class T, size_t N, size_t I = 0> decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { return std::vector(list[I], gen_vec<T, N, I + 1>(list, value)); } int main() { i32 N, K; std::cin >> N >> K; if (K > (N - 1) / 2) { m32 ans; i32 size = 2 * (N - K); for (auto i: range(0, size + 1)) { if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; else ans += fact(size, i) * fact.fact[N - i]; } std::cout << ans << '\n'; } else { auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); dp[0][0] = (m32) 1; for (auto i: range(0, 2 * K)) { i32 size = N / (2 * K) + i32(N % (2 * K) > i); auto ndp = gen_vec<m32>({ size, size + 1, 2 }); ndp[0][1][1] = (m32) 1; ndp[0][0][0] = (m32) 1; if (i >= K) ndp[0][1][0] = (m32) 1; for (auto j: range(0, size - 1)) { for (auto k: range(0, j + 2)) { ndp[j + 1][k][0] += ndp[j][k][0]; ndp[j + 1][k][0] += ndp[j][k][1]; ndp[j + 1][k + 1][0] += ndp[j][k][0]; if (i + (j + 1) * (2 * K) + K < N) { ndp[j + 1][k + 1][1] += ndp[j][k][0]; ndp[j + 1][k + 1][1] += ndp[j][k][1]; } } } for (auto j: range(0, N + 1)) { for (auto k: range(0, size + 1)) { if (j + k <= N) { dp[i + 1][j + k] += dp[i][j] * (ndp[size - 1][k][0] + ndp[size - 1][k][1]); } } } } m32 ans; for (auto i: range(0, N + 1)) { if (i & 1) ans -= dp[2 * K][i] * fact.fact[N - i]; else ans += dp[2 * K][i] * fact.fact[N - i]; } std::cout << ans << '\n'; } return 0; }
a.cc:22:16: error: 'int_fast64_t' does not name a type 22 | using int_ = int_fast64_t; | ^~~~~~~~~~~~ a.cc:24:5: error: 'int_' does not name a type; did you mean 'int'? 24 | int_ i; | ^~~~ | int a.cc:25:23: error: expected ')' before 'i_' 25 | constexpr itr(int_ i_): i(i_) { } | ~ ^~~ | ) a.cc:27:15: error: 'int_' does not name a type; did you mean 'int'? 27 | constexpr int_ operator * () const { return i; } | ^~~~ | int a.cc:31:23: error: expected ')' before 'l_' 31 | constexpr range(int_ l_, int_ r_): l(l_), r(std::max(l_, r_)) { } | ~ ^~~ | ) a.cc: In member function 'constexpr void range::itr::operator++()': a.cc:26:39: error: 'i' was not declared in this scope 26 | constexpr void operator ++ () { ++i; } | ^ a.cc: In member function 'constexpr bool range::itr::operator!=(range::itr) const': a.cc:28:55: error: 'i' was not declared in this scope 28 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc:28:62: error: 'struct range::itr' has no member named 'i' 28 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc: At global scope: a.cc:37:16: error: 'int_fast64_t' does not name a type 37 | using int_ = int_fast64_t; | ^~~~~~~~~~~~ a.cc:39:5: error: 'int_' does not name a type; did you mean 'int'? 39 | int_ i; | ^~~~ | int a.cc:40:23: error: expected ')' before 'i_' 40 | constexpr itr(int_ i_): i(i_) { } | ~ ^~~ | ) a.cc:42:15: error: 'int_' does not name a type; did you mean 'int'? 42 | constexpr int_ operator * () const { return i; } | ^~~~ | int a.cc:46:26: error: expected ')' before 'l_' 46 | constexpr revrange(int_ l_, int_ r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } | ~ ^~~ | ) a.cc: In member function 'constexpr void revrange::itr::operator++()': a.cc:41:39: error: 'i' was not declared in this scope 41 | constexpr void operator ++ () { --i; } | ^ a.cc: In member function 'constexpr bool revrange::itr::operator!=(revrange::itr) const': a.cc:43:55: error: 'i' was not declared in this scope 43 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc:43:62: error: 'struct revrange::itr' has no member named 'i' 43 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc: At global scope: a.cc:51:13: error: 'int_fast32_t' does not name a type 51 | using i32 = int_fast32_t; | ^~~~~~~~~~~~ a.cc:52:13: error: 'int_fast64_t' does not name a type 52 | using i64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:53:13: error: 'uint_fast32_t' does not name a type 53 | using u32 = uint_fast32_t; | ^~~~~~~~~~~~~ a.cc:54:13: error: 'uint_fast64_t' does not name a type 54 | using u64 = uint_fast64_t; | ^~~~~~~~~~~~~ a.cc:56:11: error: 'i32' does not name a type 56 | constexpr i32 inf32 = (i32(1) << 30) - 1; | ^~~ a.cc:57:11: error: 'i64' does not name a type 57 | constexpr i64 inf64 = (i64(1) << 62) - 1; | ^~~ a.cc:59:11: error: 'uint_fast32_t' has not been declared 59 | template <uint_fast32_t Modulus> | ^~~~~~~~~~~~~ a.cc:62:22: error: 'uint_fast32_t' does not name a type 62 | using value_type = uint_fast32_t; | ^~~~~~~~~~~~~ a.cc:63:20: error: 'uint_fast64_t' does not name a type 63 | using max_type = uint_fast64_t; | ^~~~~~~~~~~~~ a.cc:65:20: error: 'value_type' does not name a type 65 | static constexpr value_type mod = Modulus; | ^~~~~~~~~~ a.cc:66:20: error: 'value_type' does not name a type 66 | static constexpr value_type mod_min = 1; | ^~~~~~~~~~ a.cc:67:20: error: 'value_type' does not name a type 67 | static constexpr value_type mod_max = 2147483647; | ^~~~~~~~~~ a.cc:68:17: error: 'mod' was not declared in this scope 68 | static_assert(mod >= mod_min, "invalid mod :: too small"); | ^~~ a.cc:68:24: error: 'mod_min' was not declared in this scope 68 | static_assert(mod >= mod_min, "invalid mod :: too small"); | ^~~~~~~ a.cc:69:17: error: 'mod' was not declared in this scope 69 | static_assert(mod <= mod_max, "invalid mod :: too big"); | ^~~ a.cc:69:24: error: 'mod_max' was not declared in this scope 69 | static_assert(mod <= mod_max, "invalid mod :: too big"); | ^~~~~~~ a.cc:72:20: error: 'value_type' does not name a type 72 | static constexpr value_type normalize(T value_) { | ^~~~~~~~~~ a.cc:83:3: error: 'value_type' does not name a type 83 | value_type value; | ^~~~~~~~~~ a.cc:92:13: error: 'value_type' does not name a type 92 | constexpr value_type operator () () const { return value; } | ^~~~~~~~~~ a.cc:96:13: error: 'value_type' does not name a type 96 | constexpr value_type &extract() { return value; } | ^~~~~~~~~~ a.cc:98:27: error: 'max_type' has not been declared 98 | constexpr modular power(max_type exp) const { | ^~~~~~~~ a.cc:166:12: error: 'm32' was not declared in this scope 166 | factorials<m32, 1000> fact; | ^~~ a.cc:166:21: error: template argument 1 is invalid 166 | factorials<m32, 1000> fact; | ^ a.cc: In function 'int main()': a.cc:179:3: error: 'i32' was not declared in this scope 179 | i32 N, K; | ^~~ a.cc:180:15: error: 'N' was not declared in this scope 180 | std::cin >> N >> K; | ^ a.cc:180:20: error: 'K' was not declared in this scope 180 | std::cin >> N >> K; | ^ a.cc:182:5: error: 'm32' was not declared in this scope 182 | m32 ans; | ^~~ a.cc:183:8: error: expected ';' before 'size' 183 | i32 size = 2 * (N - K); | ^~~~~ | ; a.cc:184:27: error: 'size' was not declared in this scope; did you mean 'std::size'? 184 | for (auto i: range(0, size + 1)) { | ^~~~ | std::size In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/range_access.h:272:5: note: 'std::size' declared here 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ a.cc:185:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 185 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ^~~ | abs a.cc:185:29: error: 'fact' cannot be used as a function 185 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ~~~~^~~~~~~~~ a.cc:185:46: error: request for member 'fact' in 'fact', which is of non-class type 'int' 185 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ^~~~ a.cc:186:12: error: 'ans' was not declared in this scope; did you mean 'abs'? 186 | else ans += fact(size, i) * fact.fact[N - i]; | ^~~ | abs a.cc:186:23: error: 'fact' cannot be used as a function 186 | else ans += fact(size, i) * fact.fact[N - i]; | ~~~~^~~~~~~~~ a.cc:186:40: error: request for member 'fact' in 'fact', which is of non-class type 'int' 186 | else ans += fact(size, i) * fact.fact[N - i]; | ^~~~ a.cc:188:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 188 | std::cout << ans << '\n'; | ^~~ | abs a.cc:191:23: error: 'm32' was not declared in this scope 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ^~~ a.cc:191:27: error: no matching function for call to 'gen_vec<<expression error> >(<brace-enclosed initializer list>)' 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:169:16: note: candidate: 'template<class T, long unsigned int N, long unsigned int I> decltype(auto) gen_vec(const size_t (&)[N], typename std::enable_if<(I == N), const T&>::type)' 169 | decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { | ^~~~~~~ a.cc:169:16: note: template argument deduction/substitution failed: a.cc:191:27: error: template argument 1 is invalid 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:174:16: note: candidate: 'template<class T, long unsigned int N, long unsigned int I> decltype(auto) gen_vec(const size_t (&)[N], typename std::enable_if<(I != N), const T&>::type)' 174 | decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { | ^~~~~~~ a.cc:174:16: note: template argument deduction/substitution failed: a.cc:191:27: error: template argument 1 is invalid 191 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 })
s093733100
p03989
C++
#include <iostream> #include <algorithm> #include <utility> #include <vector> #include <numeric> template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; } struct range { using int_ = int_fast64_t; struct itr { int_ i; constexpr itr(int_ i_): i(i_) { } constexpr void operator ++ () { ++i; } constexpr int_ operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr range(int_ l_, int_ r_): l(l_), r(std::max(l_, r_)) { } constexpr itr begin() const { return l; } constexpr itr end() const { return r; } }; struct revrange { using int_ = int_fast64_t; struct itr { int_ i; constexpr itr(int_ i_): i(i_) { } constexpr void operator ++ () { --i; } constexpr int_ operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr revrange(int_ l_, int_ r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } constexpr itr begin() const { return r; } constexpr itr end() const { return l; } }; using i32 = int_fast32_t; using i64 = int_fast64_t; using u32 = uint_fast32_t; using u64 = uint_fast64_t; constexpr i32 inf32 = (i32(1) << 30) - 1; constexpr i64 inf64 = (i64(1) << 62) - 1; template <uint_fast32_t Modulus> class modular { public: using value_type = uint_fast32_t; using max_type = uint_fast64_t; static constexpr value_type mod = Modulus; static constexpr value_type mod_min = 1; static constexpr value_type mod_max = 2147483647; static_assert(mod >= mod_min, "invalid mod :: too small"); static_assert(mod <= mod_max, "invalid mod :: too big"); template <class T> static constexpr value_type normalize(T value_) { if (value_ < 0) { value_ = -value_; value_ %= mod; if (value_ == 0) return 0; return mod - value_; } return value_ % mod; } private: value_type value; public: constexpr modular(): value(0) { } template <class T> explicit constexpr modular(T value_): value(normalize(value_)) { } template <class T> explicit constexpr operator T() { return static_cast<T>(value); } constexpr value_type operator () () const { return value; } constexpr modular operator - () const { return modular(mod - value); } constexpr modular operator ~ () const { return inverse(); } constexpr value_type &extract() { return value; } constexpr modular inverse() const { return power(mod - 2); } constexpr modular power(max_type exp) const { modular res(1), mult(*this); while (exp > 0) { if (exp & 1) res *= mult; mult *= mult; exp >>= 1; } return res; } constexpr modular operator + (const modular &rhs) const { return modular(*this) += rhs; } constexpr modular& operator += (const modular &rhs) { if ((value += rhs.value) >= mod) value -= mod; return *this; } constexpr modular operator - (const modular &rhs) const { return modular(*this) -= rhs; } constexpr modular& operator -= (const modular &rhs) { if ((value += mod - rhs.value) >= mod) value -= mod; return *this; } constexpr modular operator * (const modular &rhs) const { return modular(*this) *= rhs; } constexpr modular& operator *= (const modular &rhs) { value = (max_type) value * rhs.value % mod; return *this; } constexpr modular operator / (const modular &rhs) const { return modular(*this) /= rhs; } constexpr modular& operator /= (const modular &rhs) { return (*this) *= rhs.inverse(); } constexpr bool zero() const { return value == 0; } constexpr bool operator == (const modular &rhs) const { return value == rhs.value; } constexpr bool operator != (const modular &rhs) const { return value != rhs.value; } friend std::ostream& operator << (std::ostream &stream, const modular &rhs) { return stream << rhs.value; } }; template <class T, std::size_t N> class factorials { public: using value_type = T; static constexpr std::size_t size = N; public: std::array<value_type, size + 1> fact{}; std::array<value_type, size + 1> fact_inv{}; factorials() { fact.front() = value_type(1); for (std::size_t i = 1; i <= size; ++i) { fact[i] = fact[i - 1] * value_type(i); } fact_inv.back() = ~fact.back(); for (std::size_t i = size; i > 0; --i) { fact_inv[i - 1] = fact_inv[i] * value_type(i); } } value_type operator () (std::size_t n, std::size_t r) const { return fact[n] * fact_inv[n - r] * fact_inv[r]; } }; using m32 = modular<924844033>; factorials<m32, 1000> fact; template <class T, size_t N, size_t I = 0> decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { return value; } template <class T, size_t N, size_t I = 0> decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { return std::vector(list[I], gen_vec<T, N, I + 1>(list, value)); } int main() { i32 N, K; std::cin >> N >> K; if (K > (N - 1) / 2) { m32 ans; i32 size = 2 * (N - K); for (auto i: range(0, size + 1)) { if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; else ans += fact(size, i) * fact.fact[N - i]; } std::cout << ans << '\n'; } else { auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); dp[0][0] = (m32) 1; for (auto i: range(0, 2 * K)) { i32 size = N / (2 * K) + i32(N % (2 * K) > i); auto ndp = gen_vec<m32>({ size, size + 1, 2 }); ndp[0][1][1] = (m32) 1; ndp[0][0][0] = (m32) 1; if (i >= K) ndp[0][1][0] = (m32) 1; for (auto j: range(0, size - 1)) { for (auto k: range(0, j + 2)) { ndp[j + 1][k][0] += ndp[j][k][0]; ndp[j + 1][k][0] += ndp[j][k][1]; ndp[j + 1][k + 1][0] += ndp[j][k][0]; if (i + (j + 1) * (2 * K) + K < N) { ndp[j + 1][k + 1][1] += ndp[j][k][0]; ndp[j + 1][k + 1][1] += ndp[j][k][1]; } } } for (auto j: range(0, N + 1)) { for (auto k: range(0, size + 1)) { if (j + k <= N) { dp[i + 1][j + k] += dp[i][j] * (ndp[size - 1][k][0] + ndp[size - 1][k][1]); } } } } m32 ans; for (auto i: range(0, N + 1)) { if (i & 1) ans -= dp[2 * K][i] * fact.fact[N - i]; else ans += dp[2 * K][i] * fact.fact[N - i]; } std::cout << ans << '\n'; } return 0; }
a.cc:21:16: error: 'int_fast64_t' does not name a type 21 | using int_ = int_fast64_t; | ^~~~~~~~~~~~ a.cc:23:5: error: 'int_' does not name a type; did you mean 'int'? 23 | int_ i; | ^~~~ | int a.cc:24:23: error: expected ')' before 'i_' 24 | constexpr itr(int_ i_): i(i_) { } | ~ ^~~ | ) a.cc:26:15: error: 'int_' does not name a type; did you mean 'int'? 26 | constexpr int_ operator * () const { return i; } | ^~~~ | int a.cc:30:23: error: expected ')' before 'l_' 30 | constexpr range(int_ l_, int_ r_): l(l_), r(std::max(l_, r_)) { } | ~ ^~~ | ) a.cc: In member function 'constexpr void range::itr::operator++()': a.cc:25:39: error: 'i' was not declared in this scope 25 | constexpr void operator ++ () { ++i; } | ^ a.cc: In member function 'constexpr bool range::itr::operator!=(range::itr) const': a.cc:27:55: error: 'i' was not declared in this scope 27 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc:27:62: error: 'struct range::itr' has no member named 'i' 27 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc: At global scope: a.cc:36:16: error: 'int_fast64_t' does not name a type 36 | using int_ = int_fast64_t; | ^~~~~~~~~~~~ a.cc:38:5: error: 'int_' does not name a type; did you mean 'int'? 38 | int_ i; | ^~~~ | int a.cc:39:23: error: expected ')' before 'i_' 39 | constexpr itr(int_ i_): i(i_) { } | ~ ^~~ | ) a.cc:41:15: error: 'int_' does not name a type; did you mean 'int'? 41 | constexpr int_ operator * () const { return i; } | ^~~~ | int a.cc:45:26: error: expected ')' before 'l_' 45 | constexpr revrange(int_ l_, int_ r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } | ~ ^~~ | ) a.cc: In member function 'constexpr void revrange::itr::operator++()': a.cc:40:39: error: 'i' was not declared in this scope 40 | constexpr void operator ++ () { --i; } | ^ a.cc: In member function 'constexpr bool revrange::itr::operator!=(revrange::itr) const': a.cc:42:55: error: 'i' was not declared in this scope 42 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc:42:62: error: 'struct revrange::itr' has no member named 'i' 42 | constexpr bool operator != (itr x) const { return i != x.i; } | ^ a.cc: At global scope: a.cc:50:13: error: 'int_fast32_t' does not name a type 50 | using i32 = int_fast32_t; | ^~~~~~~~~~~~ a.cc:51:13: error: 'int_fast64_t' does not name a type 51 | using i64 = int_fast64_t; | ^~~~~~~~~~~~ a.cc:52:13: error: 'uint_fast32_t' does not name a type 52 | using u32 = uint_fast32_t; | ^~~~~~~~~~~~~ a.cc:53:13: error: 'uint_fast64_t' does not name a type 53 | using u64 = uint_fast64_t; | ^~~~~~~~~~~~~ a.cc:55:11: error: 'i32' does not name a type 55 | constexpr i32 inf32 = (i32(1) << 30) - 1; | ^~~ a.cc:56:11: error: 'i64' does not name a type 56 | constexpr i64 inf64 = (i64(1) << 62) - 1; | ^~~ a.cc:58:11: error: 'uint_fast32_t' has not been declared 58 | template <uint_fast32_t Modulus> | ^~~~~~~~~~~~~ a.cc:61:22: error: 'uint_fast32_t' does not name a type 61 | using value_type = uint_fast32_t; | ^~~~~~~~~~~~~ a.cc:62:20: error: 'uint_fast64_t' does not name a type 62 | using max_type = uint_fast64_t; | ^~~~~~~~~~~~~ a.cc:64:20: error: 'value_type' does not name a type 64 | static constexpr value_type mod = Modulus; | ^~~~~~~~~~ a.cc:65:20: error: 'value_type' does not name a type 65 | static constexpr value_type mod_min = 1; | ^~~~~~~~~~ a.cc:66:20: error: 'value_type' does not name a type 66 | static constexpr value_type mod_max = 2147483647; | ^~~~~~~~~~ a.cc:67:17: error: 'mod' was not declared in this scope 67 | static_assert(mod >= mod_min, "invalid mod :: too small"); | ^~~ a.cc:67:24: error: 'mod_min' was not declared in this scope 67 | static_assert(mod >= mod_min, "invalid mod :: too small"); | ^~~~~~~ a.cc:68:17: error: 'mod' was not declared in this scope 68 | static_assert(mod <= mod_max, "invalid mod :: too big"); | ^~~ a.cc:68:24: error: 'mod_max' was not declared in this scope 68 | static_assert(mod <= mod_max, "invalid mod :: too big"); | ^~~~~~~ a.cc:71:20: error: 'value_type' does not name a type 71 | static constexpr value_type normalize(T value_) { | ^~~~~~~~~~ a.cc:82:3: error: 'value_type' does not name a type 82 | value_type value; | ^~~~~~~~~~ a.cc:91:13: error: 'value_type' does not name a type 91 | constexpr value_type operator () () const { return value; } | ^~~~~~~~~~ a.cc:95:13: error: 'value_type' does not name a type 95 | constexpr value_type &extract() { return value; } | ^~~~~~~~~~ a.cc:97:27: error: 'max_type' has not been declared 97 | constexpr modular power(max_type exp) const { | ^~~~~~~~ a.cc:165:12: error: 'm32' was not declared in this scope 165 | factorials<m32, 1000> fact; | ^~~ a.cc:165:21: error: template argument 1 is invalid 165 | factorials<m32, 1000> fact; | ^ a.cc: In function 'int main()': a.cc:178:3: error: 'i32' was not declared in this scope 178 | i32 N, K; | ^~~ a.cc:179:15: error: 'N' was not declared in this scope 179 | std::cin >> N >> K; | ^ a.cc:179:20: error: 'K' was not declared in this scope 179 | std::cin >> N >> K; | ^ a.cc:181:5: error: 'm32' was not declared in this scope 181 | m32 ans; | ^~~ a.cc:182:8: error: expected ';' before 'size' 182 | i32 size = 2 * (N - K); | ^~~~~ | ; a.cc:183:27: error: 'size' was not declared in this scope; did you mean 'std::size'? 183 | for (auto i: range(0, size + 1)) { | ^~~~ | std::size In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/range_access.h:272:5: note: 'std::size' declared here 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ a.cc:184:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 184 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ^~~ | abs a.cc:184:29: error: 'fact' cannot be used as a function 184 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ~~~~^~~~~~~~~ a.cc:184:46: error: request for member 'fact' in 'fact', which is of non-class type 'int' 184 | if (i & 1) ans -= fact(size, i) * fact.fact[N - i]; | ^~~~ a.cc:185:12: error: 'ans' was not declared in this scope; did you mean 'abs'? 185 | else ans += fact(size, i) * fact.fact[N - i]; | ^~~ | abs a.cc:185:23: error: 'fact' cannot be used as a function 185 | else ans += fact(size, i) * fact.fact[N - i]; | ~~~~^~~~~~~~~ a.cc:185:40: error: request for member 'fact' in 'fact', which is of non-class type 'int' 185 | else ans += fact(size, i) * fact.fact[N - i]; | ^~~~ a.cc:187:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 187 | std::cout << ans << '\n'; | ^~~ | abs a.cc:190:23: error: 'm32' was not declared in this scope 190 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ^~~ a.cc:190:27: error: no matching function for call to 'gen_vec<<expression error> >(<brace-enclosed initializer list>)' 190 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:168:16: note: candidate: 'template<class T, long unsigned int N, long unsigned int I> decltype(auto) gen_vec(const size_t (&)[N], typename std::enable_if<(I == N), const T&>::type)' 168 | decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { | ^~~~~~~ a.cc:168:16: note: template argument deduction/substitution failed: a.cc:190:27: error: template argument 1 is invalid 190 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 }); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:173:16: note: candidate: 'template<class T, long unsigned int N, long unsigned int I> decltype(auto) gen_vec(const size_t (&)[N], typename std::enable_if<(I != N), const T&>::type)' 173 | decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { | ^~~~~~~ a.cc:173:16: note: template argument deduction/substitution failed: a.cc:190:27: error: template argument 1 is invalid 190 | auto dp = gen_vec<m32>({ 2 * K + 1, N + 1 })
s274785608
p03989
C++
#include <iostream> #include <algorithm> #include <cmath> #include <stdio.h> #include <stdlib.h> #include <vector> #include <map> #include <queue> #include <set> #include <string> #include <string.h> #include <stack> #include <assert.h> #include <self/combinatorics> #define Endl endl #define mp make_pair #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define over(A) {cout<<A<<endl;exit(0);} #define all(A) A.begin(),A.end() #define ceil(a,b) ((a-1)/b+1) #define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rand(l,r) uniform_int_distribution<int>(l,r)(rng) typedef unsigned long long ull; const int inf=1039074182; using namespace std; int n,k; int mod; int dp[2005][2005];//=i(mod k) (0~k-1)µÄ¶Î£¬Ñ¡È¡ÁËj¸öÔªËØ int l1,l2; int f[2][2005]; bool extra[2005]; int dp2[2005][2005][2][2]; void solve(int n,int f[]) { if(n==1) { f[0]=1; f[1]=0; return; } if(n==2) { f[0]=1; f[1]=2; f[2]=1; return; } memset(dp2,0,sizeof(dp2)); dp2[1][0][0][0]=1; dp2[1][1][0][1]=1; for(int i=1;i<n;i++) { for(int used=0;used<=i;used++) { for(int have2=0;have2<2;have2++) { for(int have3=0;have3<2;have3++) { dp2[i+1][used][have3][0]+=dp2[i][used][have2][have3]; if(dp2[i+1][used][have3][0]>=mod) dp2[i+1][used][have3][0]-=mod; if(!have2) dp2[i+1][used+1][have3][0]+=dp2[i][used][have2][have3]; if(dp2[i+1][used+1][have3][0]>=mod) dp2[i+1][used+1][have3][0]-=mod; if(i!=n-1) dp2[i+1][used+1][have3][1]+=dp2[i][used][have2][have3]; if(dp2[i+1][used+1][have3][1]>=mod) dp2[i+1][used+1][have3][1]-=mod; } } } } for(int i=0;i<=n;i++) { f[i]=add(add(dp2[n][i][0][0],dp2[n][i][0][1]),add(dp2[n][i][1][0],dp2[n][i][1][1])); } // cout<<n<<':'; // for(int i=0;i<=n;i++) // { // cout<<f[i]<<' '; // } // cout<<endl; } void solve() { int basic=n/k; solve(basic,f[0]); solve(basic+1,f[1]); for(int i=0;i<=n;i++) { dp[0][i]=f[extra[0]][i]; } for(int i=0;i<k-1;i++) { for(int j=0;j<=n;j++) { for(int nadd=0;nadd<=basic+extra[i+1];nadd++) { if(j+nadd>n) break; dp[i+1][j+nadd]=add(dp[i+1][j+nadd],mult(f[extra[i+1]][nadd],dp[i][j])); } } } // cout<<f[1][1]<<endl; // for(int i=0;i<k;i++) // { // for(int j=0;j<=n;j++) // { // cout<<dp[i][j]<<' '; // } // cout<<endl; // } int res=0; for(int i=0;i<=n;i++) { if(i&1) { res=sub(res,mult(dp[k-1][i],fac[n-i])); } else { res=add(res,mult(dp[k-1][i],fac[n-i])); } // cout<<dp[k-1][i]<<'\n'; } cout<<res<<endl; } void precalc() { mod=924844033; init(n+5,mod); int basic=n/k; for(int i=0;i<k;i++) { int s=0; for(int j=i;j<n;j+=k,s++); if(s==basic) extra[i]=false;else extra[i]=true; } } int main() { // freopen("input.txt","r",stdin); cin>>n>>k; precalc(); solve(); return 0; }
a.cc:14:10: fatal error: self/combinatorics: No such file or directory 14 | #include <self/combinatorics> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated.
s820945997
p03989
C++
#pragma GCC optimize("Ofast") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native") #include <iostream> #include <vector> #include <algorithm> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <stdio.h> #include <cstdio> #include <math.h> #include <cmath> #include <string> #include <cstring> #include <queue> #include <deque> #include <random> #include <iomanip> #include <bitset> using namespace std; template<typename T> void uin(T &a, T b) { if (b < a) { a = b; } } template<typename T> void uax(T &a, T b) { if (b > a) { a = b; } } #define int long long #define left left228 #define right right228 #define prev prev228 #define list list228 #define mp make_pair #define all(v) v.begin(), v.end() #define forn(i, n) for (int i = 0; i < (int)n; ++i) #define firn(i, n) for (int i = 1; i < (int)n; ++i) #define x first #define y second const int N = 2007; const int MOD = 924844033; void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; } int addi(int a, int b) { add(a, b); return a; } void mul(int &a, int b) { a *= b, a %= MOD; } int mult(int a, int b) { mul(a, b); return a; } int mod(int x) { x %= MOD; if (x < 0) x += MOD; return x; } vector<int> g[N * 2]; int M[N], dp[N]; int f[N][N], F[N], deg[N ]; bool used[N]; int sum_deg = 0, len = 0; void dfs(int v) { used[v] = 1; sum_deg += deg[v]; ++len; for (int to : g[v]) { if (!used[to]) { dfs(to); } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; ++i) { if (i - k > 0) { g[i].push_back(n + i - k); g[n + i - k].push_back(i); ++deg[i], ++deg[n + i - k]; } if (i + k <= n) { g[i].push_back(n + i + k); g[n + i + k].push_back(i); ++deg[i], ++deg[n + i + k]; } } f[0][0] = 1; for (int i = 1; i <= n; ++i) { f[i][0] = 1; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { f[i][j] = f[i - 1][j]; if (i > 1) { add(f[i][j], f[i - 2][j - 1]); } } } int s = 0; dp[0] = 1; for (int iv = 1; iv <= n; ++iv) { if (!used[iv]) { sum_deg = len = 0; dfs(iv); // cout << "len=" << len << " sum_deg=" << sum_deg << endl; vector<int> dp1(s + 1); for (int i = 0; i <= s; ++i) { dp1[i] = dp[i]; } vector<int> dp2(len + 1); if (sum_deg == 2 * len) { for (int i = 1; i <= len; ++i) { dp2[i] = addi(f[len - 1][i], f[len - 3][i - 1]); } } else { for (int i = 0; i <= len; ++i) { dp2[i] = f[len][i]; } } dp2[0] = 1; for (int i = 0; i <= s + len; ++i) { dp[i] = 0; } for (int i = 0; i <= s; ++i) { for (int j = 0; j <= len; ++j) { dp[i + j] = mod(dp[i + j], mult(dp1[i], dp2[j])); } } s += len; } } F[0] = 1; M[0] = dp[0]; for (int i = 1; i <= n; ++i) { F[i] = mult(F[i - 1], i); M[i] = dp[i]; } // for (int i = 0; i <= n; ++i) { // cout << "M[" << i << "]=" << M[i] << '\n'; // } int res = 0; for (int i = 0; i <= n; ++i) { int z = 1; if (i & 1) z = -1; res = mod(res + z * M[i] * F[n - i]); } cout << res << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:147:36: error: too many arguments to function 'long long int mod(long long int)' 147 | dp[i + j] = mod(dp[i + j], mult(dp1[i], dp2[j])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:68:5: note: declared here 68 | int mod(int x) { | ^~~
s517144727
p03989
C++
#include<bits/stdc++.h> using namespace std; const int N=4005; const int mod=924844033; #define ll long long int n,k,ok[N]; ll f[N][2],fac[N/2]; int main(){ scanf("%d%d",&n,&k); fac[0]=1;ll s; for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod; f[0][0]=1;ll cnt=0; for(int i=1;i<=k;i++){ ok[cnt+1]=1;cnt+=(n-i)/k+1; ok[cnt+1]=1;cnt+=(n-i)/k+1; } s=2*n;ll t; for(int i=1;i<=s;i++){
a.cc: In function 'int main()': a.cc:18:31: error: expected '}' at end of input 18 | for(int i=1;i<=s;i++){ | ~^ a.cc:18:31: error: expected '}' at end of input a.cc:8:11: note: to match this '{' 8 | int main(){ | ^
s836027344
p03989
C++
#include<bits/stdc++.h> using namespace std; #define LL long long #define P pair<LL,LL> const LL inf = 0x3f3f3f3f; const LL mod = 924844033; const LL N = 4e3+10; template <typename tp> inline void read(tp &x) { x=0;char c=getchar();int f=0; for(;c>'9'||c<'0';f|=(c=='-'),c=getchar()); for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar()); if(f) x=-x; } int n,k,ans; int vis[N][2],tot,end[N]; LL dp[N][N][2],f[N],fac[N]; signed main() { read(n),read(k); for(int i=1;i<=n;i++) for(int j=0;j<=1;j++) if(!vis[i][j]) { for(int x=i,y=j;x<=n;x+=k,y^=1) vis[x][y]=1,tot++; end[tot]=1; } end[0]=dp[0][0][0]=1; for(int i=0;i<2*n;i++) for(int j=0;j<=n;j++) { dp[i+1][j][0]=(dp[i][j][0]+dp[i][j][1])%mod; if(!end[i]) dp[i+1][j+1][1]=dp[i][j][0]; } for(int i=0;i<=n;i++) f[i]=(dp[2*n][i][0]+dp[2*n][i][1])%mod; fac[0]=1;for(int i=1;i<=n;i++) fac[i]=(1ll*fac[i-1]*i)%mod; for(int i=0,j=1;i<=n;i++,j=-j) ans=((1ll*ans+1ll*j*fac[n-i]*f[i])%mod+mod)%mod; printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:27:33: error: reference to 'end' is ambiguous 27 | end[tot]=1; | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:16:19: note: 'int end [4010]' 16 | int vis[N][2],tot,end[N]; | ^~~ a.cc:29:9: error: reference to 'end' is ambiguous 29 | end[0]=dp[0][0][0]=1; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:16:19: note: 'int end [4010]' 16 | int vis[N][2],tot,end[N]; | ^~~ a.cc:34:29: error: reference to 'end' is ambiguous 34 | if(!end[i]) dp[i+1][j+1][1]=dp[i][j][0]; | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:16:19: note: 'int end [4010]' 16 | int vis[N][2],tot,end[N]; | ^~~
s465678428
p03989
C++
#include<cstdio> #include<algorithm> #define rep(i,s,t) for(register int i=s;i<=t;++i) using namespace std; const int mod=924844033; const int N=5011 int n,k,tot,ans; int f[N][N][2],fac[N]; bool vis[N][2]; int ed[N]; int main(){ scanf("%d%d",&n,&k); f[1][0][0]=1; rep(i,1,n) rep(j,0,1) if(!vis[i][j]){ for(register int x=i,y=j;x<=n;x+=k,y^=1) vis[x][y]=1,++tot; ed[tot]=1; } rep(i,1,tot) rep(j,0,n){ f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod; if(!ed[i])f[i+1][j+1][1]=f[i][j][0]; } fac[0]=1; rep(i,1,n) fac[i]=1ll*i*fac[i-1]%mod; rep(i,0,n){ int s=i&1; if(s)s=-1; else s=1; ans=(ans+1ll*s*(f[tot][i][0]+f[tot][i][1])*fac[n-i]%mod)%mod; ans=(ans+mod)%mod; } printf("%d\n",ans); return 0; }
a.cc:7:1: error: expected ',' or ';' before 'int' 7 | int n,k,tot,ans; | ^~~ a.cc: In function 'int main()': a.cc:12:23: error: 'n' was not declared in this scope 12 | scanf("%d%d",&n,&k); | ^ a.cc:12:26: error: 'k' was not declared in this scope 12 | scanf("%d%d",&n,&k); | ^ a.cc:14:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 14 | rep(i,1,n) | ^ a.cc:3:37: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:15:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 15 | rep(j,0,1) | ^ a.cc:3:37: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:17:50: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | for(register int x=i,y=j;x<=n;x+=k,y^=1) | ^ a.cc:17:54: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | for(register int x=i,y=j;x<=n;x+=k,y^=1) | ^ a.cc:18:55: error: 'tot' was not declared in this scope 18 | vis[x][y]=1,++tot; | ^~~ a.cc:19:36: error: 'tot' was not declared in this scope 19 | ed[tot]=1; | ^~~ a.cc:21:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 21 | rep(i,1,tot) | ^ a.cc:3:37: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:21:17: error: 'tot' was not declared in this scope 21 | rep(i,1,tot) | ^~~ a.cc:3:44: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:22:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 22 | rep(j,0,n){ | ^ a.cc:3:37: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:27:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 27 | rep(i,1,n) | ^ a.cc:3:37: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:29:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 29 | rep(i,0,n){ | ^ a.cc:3:37: note: in definition of macro 'rep' 3 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:33:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 33 | ans=(ans+1ll*s*(f[tot][i][0]+f[tot][i][1])*fac[n-i]%mod)%mod; | ^~~ | abs a.cc:33:35: error: 'tot' was not declared in this scope 33 | ans=(ans+1ll*s*(f[tot][i][0]+f[tot][i][1])*fac[n-i]%mod)%mod; | ^~~ a.cc:36:23: error: 'ans' was not declared in this scope; did you mean 'abs'? 36 | printf("%d\n",ans); | ^~~ | abs
s096785859
p03989
C++
#include <bits/stdc++.h> using namespace std; const int N=2050,mod=924844033; int n,m,k,ans,jc[N]= {1},f[N*2][N][2]; bool ed[N],vis[N][2]; int main() { scanf("%d%d",&n,&k); for(int i=1; i<=n; i++) for(int j=0; j<2; j++) if(!vis[i][j]) int cnt=0; for(int x=i,y=j; x<=n; x+=k,y^=1) { cnt++; vis[x][y]=true; } m+=cnt; ed[m]=true; f[1][0][0]=1; for(int i=1; i<=m; i++) for(int j=0; j<=n; j++) { f[i+1][j][0]=f[i][j][0]+f[i][j][1]<mod?f[i][j][0]+f[i][j][1]:f[i][j][0]+f[i][j][1]-mod; if(!ed[i]) f[i+1][j+1][1]=f[i][j][0]; } for(int i=1; i<=n; i++) jc[i]=1LL*jc[i-1]*i%mod; ans=jc[n]; for(int i=1; i<=n; i++) if(i&1) ans=(ans-1LL*(f[m][i][0]+f[m][i][1])%mod*jc[n-i]%mod+mod)%mod; else ans=(ans+1LL*(f[m][i][0]+f[m][i][1])%mod*jc[n-i]%mod)%mod; printf("%d\n",ans); }
a.cc: In function 'int main()': a.cc:13:43: error: 'i' was not declared in this scope 13 | for(int x=i,y=j; x<=n; x+=k,y^=1) | ^ a.cc:13:61: error: 'y' was not declared in this scope 13 | for(int x=i,y=j; x<=n; x+=k,y^=1) | ^ a.cc:15:41: error: 'cnt' was not declared in this scope; did you mean 'int'? 15 | cnt++; | ^~~ | int a.cc:18:36: error: 'cnt' was not declared in this scope; did you mean 'int'? 18 | m+=cnt; | ^~~ | int
s883731385
p03989
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; typedef long long ll; const int N=4009; const ll md=924844033; int n,k; bool vis[N][N]; ll g[N],fac[N]; int end[N],tot; ll f[N][N][2]; int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) for(int j=0;j<=1;j++) if(!vis[i][j]) { int len=0; for(int x=i,y=j;x<=n;x+=k,y^=1) vis[x][y]=1,++len; end[tot+=len]=1; } f[1][0][0]=1; for(int i=1;i<=tot;i++) for(int j=0;j<=n;j++) { f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%md; if(!end[i]) f[i+1][j+1][1]=f[i][j][0]; } for(int i=0;i<=n;i++) g[i]=(f[tot][i][0]+f[tot][i][1])%md; fac[0]=1; for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%md; ll ans=fac[n]; for(int i=1,j=-1;i<=n;i++,j=-j) (ans+=md+j*fac[n-i]*g[i]%md)%=md; printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:29:33: error: reference to 'end' is ambiguous 29 | end[tot+=len]=1; | ^~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:16:5: note: 'int end [4009]' 16 | int end[N],tot; | ^~~ a.cc:37:29: error: reference to 'end' is ambiguous 37 | if(!end[i]) | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:16:5: note: 'int end [4009]' 16 | int end[N],tot; | ^~~
s078065998
p03989
C++
#include <bits/stdc++.h> using namespace std; const long long mod = 924844033; void add(long long &x, long long y) { x += y; if (x >= mod) x -= mod; } int main() { int n, K; cin >> n >> K; static long long dp[2020][2020][2]; // pos, num, L/H vector<int> c(K * 2); for (int i = 0; i < min(n, 2 * K); i++) { dp[i][0][0] = 1; if (i - K >= 0) dp[i][1][0] = 1; if (i + K < n) dp[i][1][1] = 1; c[i]++; } for (int i = 2 * K; i < n; i++) { c[i % (2 * K)]++; for (int j = 0; j <= n; j++) { // not take add(dp[i][j][0], dp[i - 2 * K][j][0]); add(dp[i][j][0], dp[i - 2 * K][j][1]); // take L add(dp[i][j + 1][0], dp[i - 2 * K][j][0]); // take H if (i + K < n) { add(dp[i][j + 1][1], dp[i - 2 * K][j][0]); add(dp[i][j + 1][1], dp[i - 2 * K][j][1]); } } } static long long xp0[4040], xp1[4040]; xp0[0] = 1; int sum = 0; for (int i = 0; i < min(n, 2 * K); i++) { memset(xp1, 0, sizeof(xp1)); int ii = n - 1 - i; for (int j = 0; j <= sum; j++) { for (int k = 0; k <= c[i]; k++) { (xp1[j + k] += xp0[j] * (dp[ii][k][0] + dp[ii][k][1])) %= mod; } } sum += c[i]; swap(xp0, xp1); } vector<long long> fact(1010101); fact[0] = 1; for (int i = 1; i < 1010101) fact[i] = i * fact[i - 1] % mod; long long ans = 0; for (int i = 0; i <= n; i++) { if (i % 2 == 0) { ans += fact[n - i] * xp0[i] % mod; } else { ans += mod - fact[n - i] * xp0[i] % mod; } } ans %= mod; cout << ans << endl; }
a.cc: In function 'int main()': a.cc:61:36: error: expected ';' before ')' token 61 | for (int i = 1; i < 1010101) fact[i] = i * fact[i - 1] % mod; | ^ | ;
s446811436
p03989
Java
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static void solve() { int n = ni(), K = ni(); int mod = 924844033; int[][][] dp = new int[n+1][2][n+1]; // RIRI dp[0][0][0] = 1; for(int i = 0;i <= n-1;i++){ for(int j = 0;j <= n-1;j++){ if(dp[i][0][j] == 0 && dp[i][0][j] == 1)continue; dp[i+1][0][j] += dp[i][0][j]; if(dp[i+1][0][j] >= mod)dp[i+1][0][j] -= mod; dp[i+1][0][j] += dp[i][1][j]; if(dp[i+1][0][j] >= mod)dp[i+1][0][j] -= mod; dp[i+1][1][j+1] += dp[i][0][j]; if(dp[i+1][1][j+1] >= mod)dp[i+1][1][j+1] -= mod; dp[i+1][1][j+1] += dp[i][1][j]; if(dp[i+1][1][j+1] >= mod)dp[i+1][1][j+1] -= mod; if(i > 0){ dp[i+1][0][j+1] += dp[i][0][j]; if(dp[i+1][0][j+1] >= mod)dp[i+1][0][j+1] -= mod; } } } int[][][] ep = new int[n+1][2][n+1]; // RIRI ep[0][0][0] = 1; for(int i = 0;i <= n-1;i++){ for(int j = 0;j <= n-1;j++){ if(ep[i][0][j] == 0 && ep[i][0][j] == 1)continue; ep[i+1][0][j] += ep[i][0][j]; if(ep[i+1][0][j] >= mod)ep[i+1][0][j] -= mod; ep[i+1][0][j] += ep[i][1][j]; if(ep[i+1][0][j] >= mod)ep[i+1][0][j] -= mod; ep[i+1][1][j+1] += ep[i][0][j]; if(ep[i+1][1][j+1] >= mod)ep[i+1][1][j+1] -= mod; ep[i+1][1][j+1] += ep[i][1][j]; if(ep[i+1][1][j+1] >= mod)ep[i+1][1][j+1] -= mod; ep[i+1][0][j+1] += ep[i][0][j]; if(ep[i+1][0][j+1] >= mod)ep[i+1][0][j+1] -= mod; } } long[] fp = new long[n+1]; fp[0] = 1; long[] temp = new long[n+1]; for(int i = 0;i < 2*K && i < n;i++){ int len = (n-i+2*K-1)/(2*K); if(i < K){ if(i+2*K*(len-1)+K < n){ for(int v = 0;v <= n;v++){ temp[v] = dp[len][0][v]+dp[len][1][v]; } fp = Arrays.copyOf(convoluteSimply(fp, temp, mod, 5), n+1); }else{ for(int v = 0;v <= n;v++){ temp[v] = dp[len][0][v]; } fp = Arrays.copyOf(convoluteSimply(fp, temp, mod, 5), n+1); } }else{ if(i+2*K*(len-1)+K < n){ for(int v = 0;v <= n;v++){ temp[v] = ep[len][0][v]+ep[len][1][v]; } fp = Arrays.copyOf(convoluteSimply(fp, temp, mod, 5), n+1); }else{ for(int v = 0;v <= n;v++){ temp[v] = ep[len][0][v]; } fp = Arrays.copyOf(convoluteSimply(fp, temp, mod, 5), n+1); } } } long F = 1; for(int i = n-1;i >= 1;i--){ F = F * (n-i) % mod; fp[i] = fp[i] * F % mod; } F = F * n % mod; for(int i = 1, sig = -1;i <= n;i++, sig = -sig){ F += sig * fp[i]; } F %= mod; if(F < 0)F += mod; out.println(F); } public static long[] convoluteSimply(long[] a, long[] b, int P, int g) { int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length)-1)<<2); long[] fa = nttmb(a, m, false, P, g); long[] fb = a == b ? fa : nttmb(b, m, false, P, g); for(int i = 0;i < m;i++){ fa[i] = fa[i]*fb[i]%P; } return nttmb(fa, m, true, P, g); } public static long[] convolute(long[] a, long[] b) { int USE = 2; int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length)-1)<<2); long[][] fs = new long[USE][]; for(int k = 0;k < USE;k++){ int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; long[] fa = nttmb(a, m, false, P, g); long[] fb = a == b ? fa : nttmb(b, m, false, P, g); for(int i = 0;i < m;i++){ fa[i] = fa[i]*fb[i]%P; } fs[k] = nttmb(fa, m, true, P, g); } int[] mods = Arrays.copyOf(NTTPrimes, USE); long[] gammas = garnerPrepare(mods); int[] buf = new int[USE]; for(int i = 0;i < fs[0].length;i++){ for(int j = 0;j < USE;j++)buf[j] = (int)fs[j][i]; long[] res = garnerBatch(buf, mods, gammas); long ret = 0; for(int j = res.length-1;j >= 0;j--)ret = ret * mods[j] + res[j]; fs[0][i] = ret; } return fs[0]; } public static long[] convolute(long[] a, long[] b, int USE, int mod) { int m = Math.max(2, Integer.highestOneBit(Math.max(a.length, b.length)-1)<<2); long[][] fs = new long[USE][]; for(int k = 0;k < USE;k++){ int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; long[] fa = nttmb(a, m, false, P, g); long[] fb = a == b ? fa : nttmb(b, m, false, P, g); for(int i = 0;i < m;i++){ fa[i] = fa[i]*fb[i]%P; } fs[k] = nttmb(fa, m, true, P, g); } int[] mods = Arrays.copyOf(NTTPrimes, USE); long[] gammas = garnerPrepare(mods); int[] buf = new int[USE]; for(int i = 0;i < fs[0].length;i++){ for(int j = 0;j < USE;j++)buf[j] = (int)fs[j][i]; long[] res = garnerBatch(buf, mods, gammas); long ret = 0; for(int j = res.length-1;j >= 0;j--)ret = (ret * mods[j] + res[j]) % mod; fs[0][i] = ret; } return fs[0]; } // static int[] wws = new int[270000]; // outer faster // Modifed Montgomery + Barrett private static long[] nttmb(long[] src, int n, boolean inverse, int P, int g) { long[] dst = Arrays.copyOf(src, n); int h = Integer.numberOfTrailingZeros(n); long K = Integer.highestOneBit(P)<<1; int H = Long.numberOfTrailingZeros(K)*2; long M = K*K/P; int[] wws = new int[1<<h-1]; long dw = inverse ? pow(g, P-1-(P-1)/n, P) : pow(g, (P-1)/n, P); long w = (1L<<32)%P; for(int k = 0;k < 1<<h-1;k++){ wws[k] = (int)w; w = modh(w*dw, M, H, P); } long J = invl(P, 1L<<32); for(int i = 0;i < h;i++){ for(int j = 0;j < 1<<i;j++){ for(int k = 0, s = j<<h-i, t = s|1<<h-i-1;k < 1<<h-i-1;k++,s++,t++){ long u = (dst[s] - dst[t] + 2*P)*wws[k]; dst[s] += dst[t]; if(dst[s] >= 2*P)dst[s] -= 2*P; // long Q = (u&(1L<<32)-1)*J&(1L<<32)-1; long Q = (u<<32)*J>>>32; dst[t] = (u>>>32)-(Q*P>>>32)+P; } } if(i < h-1){ for(int k = 0;k < 1<<h-i-2;k++)wws[k] = wws[k*2]; } } for(int i = 0;i < n;i++){ if(dst[i] >= P)dst[i] -= P; } for(int i = 0;i < n;i++){ int rev = Integer.reverse(i)>>>-h; if(i < rev){ long d = dst[i]; dst[i] = dst[rev]; dst[rev] = d; } } if(inverse){ long in = invl(n, P); for(int i = 0;i < n;i++)dst[i] = modh(dst[i]*in, M, H, P); } return dst; } // Modified Shoup + Barrett private static long[] nttsb(long[] src, int n, boolean inverse, int P, int g) { long[] dst = Arrays.copyOf(src, n); int h = Integer.numberOfTrailingZeros(n); long K = Integer.highestOneBit(P)<<1; int H = Long.numberOfTrailingZeros(K)*2; long M = K*K/P; long dw = inverse ? pow(g, P-1-(P-1)/n, P) : pow(g, (P-1)/n, P); long[] wws = new long[1<<h-1]; long[] ws = new long[1<<h-1]; long w = 1; for(int k = 0;k < 1<<h-1;k++){ wws[k] = (w<<32)/P; ws[k] = w; w = modh(w*dw, M, H, P); } for(int i = 0;i < h;i++){ for(int j = 0;j < 1<<i;j++){ for(int k = 0, s = j<<h-i, t = s|1<<h-i-1;k < 1<<h-i-1;k++,s++,t++){ long ndsts = dst[s] + dst[t]; if(ndsts >= 2*P)ndsts -= 2*P; long T = dst[s] - dst[t] + 2*P; long Q = wws[k]*T>>>32; dst[s] = ndsts; dst[t] = ws[k]*T-Q*P&(1L<<32)-1; } } // dw = dw * dw % P; if(i < h-1){ for(int k = 0;k < 1<<h-i-2;k++){ wws[k] = wws[k*2]; ws[k] = ws[k*2]; } } } for(int i = 0;i < n;i++){ if(dst[i] >= P)dst[i] -= P; } for(int i = 0;i < n;i++){ int rev = Integer.reverse(i)>>>-h; if(i < rev){ long d = dst[i]; dst[i] = dst[rev]; dst[rev] = d; } } if(inverse){ long in = invl(n, P); for(int i = 0;i < n;i++){ dst[i] = modh(dst[i] * in, M, H, P); } } return dst; } static final long mask = (1L<<31)-1; public static long modh(long a, long M, int h, int mod) { long r = a-((M*(a&mask)>>>31)+M*(a>>>31)>>>h-31)*mod; return r < mod ? r : r-mod; } private static long[] garnerPrepare(int[] m) { int n = m.length; assert n == m.length; if(n == 0)return new long[0]; long[] gamma = new long[n]; for(int k = 1;k < n;k++){ long prod = 1; for(int i = 0;i < k;i++){ prod = prod * m[i] % m[k]; } gamma[k] = invl(prod, m[k]); } return gamma; } private static long[] garnerBatch(int[] u, int[] m, long[] gamma) { int n = u.length; assert n == m.length; long[] v = new long[n]; v[0] = u[0]; for(int k = 1;k < n;k++){ long temp = v[k-1]; for(int j = k-2;j >= 0;j--){ temp = (temp * m[j] + v[j]) % m[k]; } v[k] = (u[k] - temp) * gamma[k] % m[k]; if(v[k] < 0)v[k] += m[k]; } return v; } private static long pow(long a, long n, long mod) { // a %= mod; long ret = 1; int x = 63 - Long.numberOfLeadingZeros(n); for (; x >= 0; x--) { ret = ret * ret % mod; if (n << 63 - x < 0) ret = ret * a % mod; } return ret; } private static long invl(long a, long mod) { long b = mod; long p = 1, q = 0; while (b > 0) { long c = a / b; long d; d = a; a = b; b = d % b; d = p; p = q; q = d - c * q; } return p < 0 ? p + mod : p; } public static void main(String[] args) throws Exception { long S = System.currentTimeMillis(); is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); solve(); out.flush(); long G = System.currentTimeMillis(); tr(G-S+"ms"); } private static boolean eof() { if(lenbuf == -1)return true; int lptr = ptrbuf; while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false; try { is.mark(1000); while(true){ int b = is.read(); if(b == -1){ is.reset(); return true; }else if(!isSpaceChar(b)){ is.reset(); return false; } } } catch (IOException e) { return true; } } private static byte[] inbuf = new byte[1024]; static int lenbuf = 0, ptrbuf = 0; private static int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } // private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); } private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private static double nd() { return Double.parseDouble(ns()); } private static char nc() { return (char)skip(); } private static String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b))){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private static char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private static int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private static int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); } }
Main.java:124: error: cannot find symbol int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; ^ symbol: variable NTTPrimes location: class Main Main.java:124: error: cannot find symbol int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; ^ symbol: variable NTTPrimitiveRoots location: class Main Main.java:133: error: cannot find symbol int[] mods = Arrays.copyOf(NTTPrimes, USE); ^ symbol: variable NTTPrimes location: class Main Main.java:151: error: cannot find symbol int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; ^ symbol: variable NTTPrimes location: class Main Main.java:151: error: cannot find symbol int P = NTTPrimes[k], g = NTTPrimitiveRoots[k]; ^ symbol: variable NTTPrimitiveRoots location: class Main Main.java:160: error: cannot find symbol int[] mods = Arrays.copyOf(NTTPrimes, USE); ^ symbol: variable NTTPrimes location: class Main 6 errors
s898602665
p03990
C++
#include<cstdio> #define fr(N,i,x) for (int i=N.lnk[x];i;i=N.nxt[i]) using namespace std; const int maxn=200005,maxe=maxn<<1; int n,X,Y,dst[maxn],fa[maxn],Dst[maxn],Q[maxn],ans;bool vis[maxn]; struct ljb{ int e,lnk[maxn],nxt[maxe],son[maxe]; inline void add_e(int x,int y){son[++e]=y;nxt[e]=lnk[x];lnk[x]=e;} }A,B; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; } inline int read(){ int ret=0;bool f=0;char ch=nc(); while(ch>'9'||ch<'0') f^=ch=='-',ch=nc(); while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc(); return f?-ret:ret; } void DFS(int x){fr(B,i,x) if(B.son[i]^fa[x]) dst[B.son[i]]=dst[x]+1,fa[B.son[i]]=x,DFS(B.son[i]);} inline void BFS(){ int hed=0,til=1;Q[vis[X]=1]=X; while(hed<til) if(Dst[Q[++hed]]<dst[Q[hed]]) fr(A,i,Q[hed]) if(!vis[A.son[i]]) vis[A.son[i]]=1,Dst[A.son[i]]=Dst[Q[hed]]+1; } inline check(int x,int y){ if(dst[x]>dst[y]){int t=x;x=y;y=t;} if(dst[y]-dst[x]==2) return fa[fa[y]]==x; if(dst[y]-dst[x]==1) return fa[y]==x; if(dst[y]-dst[x]==0) return fa[x]==fa[y]; return 0; } int main(){ n=read(),X=read(),Y=read(); for (int i=1,x,y;i<n;i++) x=read(),y=read(),A.add_e(x,y),A.add_e(y,x); for (int i=1,x,y;i<n;i++) x=read(),y=read(),B.add_e(x,y),B.add_e(y,x); dst[Y]=0;DFS(Y);BFS(); for (int i=1;i<=n;i++) if(vis[i]){ if(dst[i]>ans) ans=dst[i]; if(Dst[i]<dst[i]) fr(A,j,i) if(!check(A.son[j],i)) ans=1e9; } printf("%d\n",ans==1e9?-1:ans<<1); return 0; }
a.cc:26:8: error: ISO C++ forbids declaration of 'check' with no type [-fpermissive] 26 | inline check(int x,int y){ | ^~~~~
s900253297
p03990
C++
#include<bis/stdc++.h> using namespace std; const int maxn=2e5+10; int n,x,y,ans,vis[maxn]; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(int x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10+'0'); } void write(int x){print(x);puts("");} struct Heavy_Light_Decomposition{ struct edge{int to,nxt;}e[maxn<<1];int tot,head[maxn]; int idx,fa[maxn],dfn[maxn],dep[maxn],son[maxn],top[maxn],size[maxn]; void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;} void insert(int u,int v){add(u,v);add(v,u);} void build(int x){ dep[x]=dep[fa[x]]+1;size[x]=1;int mx=0; for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){ if(v==fa[x])continue; fa[v]=x;build(v);size[x]+=size[v]; if(size[v]>mx)mx=size[v],son[x]=v; } } void dfs(int x){ if(!x)return ;dfn[x]=++idx; top[x]=son[fa[x]]==x?top[fa[x]]:x; dfs(son[x]); for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to) if(v!=fa[x]&&v!=son[x])dfs(v); } int query(int u,int v){ while(top[u]!=top[v]){ if(dep[top[u]]<dep[top[v]])swap(u,v); u=fa[top[u]]; }if(dep[u]>dep[v])swap(u,v); return u; } int get_dis(int u,int v){return dep[u]+dep[v]-2*dep[query(u,v)];} }HLD[2]; void init(int S){ queue<int >q; q.push(S);vis[S]=1; while(!q.empty()){ int x=q.front();q.pop(); for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to) if(!vis[v]&&HLD[0].dep[v]<HLD[1].dep[v])vis[v]=1,q.push(v); } } void solve(){ for(int x=1;x<=n;x++){ if(!vis[x])continue; ans=max(ans,HLD[1].dep[x]-1); for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to) if(HLD[1].get_dis(v,x)>2){puts("-1");return ;} }write(ans<<1); } int main(){ n=read();x=read();y=read(); if(x==y){puts("0");return 0;} for(int i=1;i<n;i++)HLD[0].insert(read(),read()); for(int i=1;i<n;i++)HLD[1].insert(read(),read()); HLD[0].build(x);HLD[0].dfs(x);HLD[1].build(y);HLD[1].dfs(y); init(x);solve(); return 0; }
a.cc:1:9: fatal error: bis/stdc++.h: No such file or directory 1 | #include<bis/stdc++.h> | ^~~~~~~~~~~~~~ compilation terminated.
s503464709
p03990
C++
#include<bits/stdc++.h> #define N 200005 using namespace std; int n,x,y; int xx[N],yy[N]; int head[N],ver[N*2],nxt[N*2],tot; void add(int a,int b) { tot++;nxt[tot]=head[a];head[a]=tot;ver[tot]=b;return ; } int dis[N]; int f[N][20]; void dfs(int x,int fa) { for(int i=head[x];i;i=nxt[i]) { if(ver[i]==fa)continue; dis[ver[i]]=dis[x]+1; f[ver[i]][0]=x; dfs(ver[i],x); } return 0; } void dffs(int x,int fa) { for(int i=head[x];i;i=nxt[i]) { } return ; } int lca(int a,int b) { if(dis[a]<dis[b])swap(a,b); for(int i=19;i>=0;i--) { if(dis[f[a][i]]>=dis[b])a=f[a][i]; } if(a==b)return a; for(int i=19;i>=0;i--) { } return f[a][0]; } int calc(int a,int b) { return dis[a]+dis[b]-2*dis[lca(a,b)]; } int main() { scanf("%d%d%d",&n,&x,&y); int t1,t2; for(int i=1;i<n;i++) { scanf("%d%d",&xx[i],&yy[i]); } for(int i=1;i<n;i++) { scanf("%d%d",&t1,&t2); add(t1,t2);add(t2,t1); } dis[y]=1;dfs(y); for(int i=1;i<=19;i++) { for(int j=1;j<=n;j++) { f[j][i]=f[f[j][i-1]][i-1]; } } tot=0;memset(head,0,sizeof(head)); dffs(x); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:22:16: error: return-statement with a value, in function returning 'void' [-fpermissive] 22 | return 0; | ^ a.cc: In function 'int main()': a.cc:63:21: error: too few arguments to function 'void dfs(int, int)' 63 | dis[y]=1;dfs(y); | ~~~^~~ a.cc:13:6: note: declared here 13 | void dfs(int x,int fa) | ^~~ a.cc:72:13: error: too few arguments to function 'void dffs(int, int)' 72 | dffs(x); | ~~~~^~~ a.cc:24:6: note: declared here 24 | void dffs(int x,int fa) | ^~~~
s017686212
p03990
C++
include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <iostream> #include <vector> #include <queue> using namespace std; const int maxn = 2e6 + 5; vector<int> blue[maxn], red[maxn]; int dep[maxn], fa[maxn], dp[maxn]; bool safe[maxn]; void dfs(int v, int p) { fa[v] = p; for (int i=0; i<blue[v].size(); i++) if(blue[v][i] != p) { dep[blue[v][i]] = dep[v] + 1; dfs(blue[v][i], v); } } bool atMost2(int x, int y) { return (fa[x] == fa[y]) || (fa[x] == y) || (x == fa[y]) || (fa[fa[x]] == y) || (x == fa[fa[y]]); } int main() { int n, X, Y, x, y; scanf("%d %d %d", &n, &X, &Y); for (int i=1; i<n; i++) { scanf("%d %d", &x, &y); red[x].push_back(y), red[y].push_back(x); } for (int i=1; i<n; i++) { scanf("%d %d", &x, &y); blue[x].push_back(y), blue[y].push_back(x); } dfs(Y, -1); for (int i=1; i<=n; i++) for (int j=0; j<red[i].size(); j++) if (!atMost2(i, red[i][j])) safe[i] = safe[red[i][j]] = 1; if (safe[X]) {puts("-1"); return 0;} memset(dp, -1, sizeof(dp)); queue<int> q; q.push(X); dp[X] = 0; int ans = 0; while (!q.empty()) { int u = q.front(); q.pop(); if (dp[u] >= dep[u]) continue; if (safe[u]) {puts("-1"); return 0;} ans = max(ans, dep[u] * 2); for (int i=0; i<red[u].size(); i++) { int v = red[u][i]; if (dp[u] + 1 < dep[v] && atMost2(u, v)) { dp[v] = dp[u] + 1; q.push(v); } } } printf("%d\n", ans); return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <cstdio> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:4: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:32, from /usr/include/c++/14/cstdlib:79, from a.cc:2: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/ptr_traits.h:156:47: error: 'ptrdiff_t' was not declared in this scope 1
s773726381
p03991
C++
#include <iostream> #include <algorithm> using namespace std ; const int N = 4e5+5,M = N<<1,mod = 924844033,GG = 5,IG = 554906420 ; inline int add(int a,int b){ return a+b >= mod ? a+b-mod : a+b ; } inline int sub(int a,int b){ return a >= b ? a-b : a-b+mod ; } inline int mul(int a,int b){ return 1ll*a*b%mod ; } inline int power(int a,int b){ int res = 1 ; for( ; b ; b >>= 1){ if(b&1) res = mul(res,a) ; a = mul(a,a) ; } return res ; } int rev[M] ; inline void calrev(int limit){ for(int i = 0 ; i < limit ; i++) rev[i] = (rev[i>>1]>>1)|((i&1)?(limit>>1):0) ; } inline void NTT(int *A,int limit,int flg){ for(int i = 0 ; i < limit ; i++) if(i > rev[i]) swap(A[i],A[rev[i]]) ; for(int mid = 1 ; mid < limit ; mid <<= 1){ int Wn = power(flg == 1 ? GG : IG,(mod-1)/(mid<<1)) ; for(int j = 0 ; j < limit ; j += (mid<<1)){ int w = 1 ; for(int k = 0 ; k < mid ; k++,w = mul(w,Wn)){ int x = A[j+k],y = mul(w,A[j+mid+k]) ; A[j+k] = add(x,y) ; A[j+mid+k] = sub(x,y) ; } } } if(flg == -1){ int Inv = power(limit,mod-2) ; for(int i = 0 ; i < limit ; i++) A[i] = mul(A[i],Inv) ; } } int fac[N],inv[N] ; inline int C(int n,int m){ return mul(fac[n],mul(inv[m],inv[n-m])) ; } inline void prework(int n){ fac[0] = inv[0] = inv[1] = 1 ; for(int i = 1 ; i <= n ; i++) fac[i] = mul(fac[i-1],i) ; for(int i = 2 ; i <= n ; i++) inv[i] = mul(sub(mod,mod/i),inv[mod%i]) ; for(int i = 1 ; i <= n ; i++) inv[i] = mul(inv[i],inv[i-1]) ; } int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; inline void adde(int x,int y){ ver[++tot] = y ; Next[tot] = head[x] ; head[x] = tot ;} inline void dfs(int x,int fa){ size[x] = 1 ; for(int i = head[x] ; i ; i = Next[i]){ int y = ver[i] ; if(y == fa) continue ; dfs(y,x) ; size[x] += size[y] ; cnt[size[y]]++ ; } cnt[n-size[x]]++ ; } int f[N],g[N] ; int main(){ //freopen("in.txt","r",stdin) ; cin >> n ; prework(n) ; for(int i = 1 ; i < n ; i++){ int x,y ; scanf("%d%d",&x,&y) ; adde(x,y) ; adde(y,x) ; } dfs(1,0) ; for(int i = 1 ; i <= n ; i++) f[i] = mul(cnt[i],fac[i]),g[i] = inv[i] ; g[0] = 1 ; reverse(f,f+n+1) ; int limit = 1 ; while(limit <= n*2) limit <<= 1 ; calrev(limit) ; NTT(f,limit,1) ; NTT(g,limit,1) ; for(int i = 0 ; i < limit ; i++) f[i] = mul(f[i],g[i]) ; NTT(f,limit,-1) ; reverse(f,f+n+1) ; for(int i = 1 ; i <= n ; i++) printf("%d\n",sub(mul(n,C(n,i)),mul(inv[i],f[i]))) ; return 0 ; }
a.cc: In function 'void dfs(int, int)': a.cc:53:9: error: reference to 'size' is ambiguous 53 | size[x] = 1 ; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:58:17: error: reference to 'size' is ambiguous 58 | size[x] += size[y] ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:58:28: error: reference to 'size' is ambiguous 58 | size[x] += size[y] ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:59:21: error: reference to 'size' is ambiguous 59 | cnt[size[y]]++ ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:61:15: error: reference to 'size' is ambiguous 61 | cnt[n-size[x]]++ ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~
s614721374
p03991
C++
#include <iostream> #include <algorithm> using namespace std ; const int N = 4e5+5,M = N<<1,mod = 924844033,GG = 5,IG = 554906420 ; inline int add(int a,int b){ return a+b >= mod ? a+b-mod : a+b ; } inline int sub(int a,int b){ return a >= b ? a-b : a-b+mod ; } inline int mul(int a,int b){ return 1ll*a*b%mod ; } inline int power(int a,int b){ int res = 1 ; for( ; b ; b >>= 1){ if(b&1) res = mul(res,a) ; a = mul(a,a) ; } return res ; } int rev[M] ; inline void calrev(int limit){ for(int i = 0 ; i < limit ; i++) rev[i] = (rev[i>>1]>>1)|((i&1)?(limit>>1):0) ; } inline void NTT(int *A,int limit,int flg){ for(int i = 0 ; i < limit ; i++) if(i > rev[i]) swap(A[i],A[rev[i]]) ; for(int mid = 1 ; mid < limit ; mid <<= 1){ int Wn = power(flg == 1 ? GG : IG,(mod-1)/(mid<<1)) ; for(int j = 0 ; j < limit ; j += (mid<<1)){ int w = 1 ; for(int k = 0 ; k < mid ; k++,w = mul(w,Wn)){ int x = A[j+k],y = mul(w,A[j+mid+k]) ; A[j+k] = add(x,y) ; A[j+mid+k] = sub(x,y) ; } } } if(flg == -1){ int Inv = power(limit,mod-2) ; for(int i = 0 ; i < limit ; i++) A[i] = mul(A[i],Inv) ; } } int fac[N],inv[N] ; inline int C(int n,int m){ return mul(fac[n],mul(inv[m],inv[n-m])) ; } inline void prework(int n){ fac[0] = inv[0] = inv[1] = 1 ; for(int i = 1 ; i <= n ; i++) fac[i] = mul(fac[i-1],i) ; for(int i = 2 ; i <= n ; i++) inv[i] = mul(sub(mod,mod/i),inv[mod%i]) ; for(int i = 1 ; i <= n ; i++) inv[i] = mul(inv[i],inv[i-1]) ; } int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; inline int adde(int x,int y){ ver[++tot] = y ; Next[tot] = head[x] ; head[x] = tot ;} inline void dfs(int x,int fa){ size[x] = 1 ; for(int i = head[x] ; i ; i = Next[i]){ int y = ver[i] ; if(y == fa) continue ; dfs(y,x) ; size[x] += size[y] ; cnt[size[y]]++ ; } cnt[n-size[x]]++ ; } int f[N],g[N] ; int main(){ //freopen("in.txt","r",stdin) ; cin >> n ; prework(n) ; for(int i = 1 ; i < n ; i++){ int x,y ; scanf("%d%d",&x,&y) ; adde(x,y) ; adde(y,x) ; } dfs(1,0) ; for(int i = 1 ; i <= n ; i++) f[i] = mul(cnt[i],fac[i]),g[i] = inv[i] ; g[0] = 1 ; reverse(f,f+n+1) ; int limit = 1 ; while(limit <= n*2) limit <<= 1 ; calrev(limit) ; NTT(f,limit,1) ; NTT(g,limit,1) ; for(int i = 0 ; i < limit ; i++) f[i] = mul(f[i],g[i]) ; NTT(f,limit,-1) ; reverse(f,f+n+1) ; for(int i = 1 ; i <= n ; i++) printf("%d\n",sub(mul(n,C(n,i)),mul(inv[i],f[i]))) ; return 0 ; }
a.cc: In function 'int adde(int, int)': a.cc:51:85: warning: no return statement in function returning non-void [-Wreturn-type] 51 | inline int adde(int x,int y){ ver[++tot] = y ; Next[tot] = head[x] ; head[x] = tot ;} | ^ a.cc: In function 'void dfs(int, int)': a.cc:53:9: error: reference to 'size' is ambiguous 53 | size[x] = 1 ; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:58:17: error: reference to 'size' is ambiguous 58 | size[x] += size[y] ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:58:28: error: reference to 'size' is ambiguous 58 | size[x] += size[y] ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:59:21: error: reference to 'size' is ambiguous 59 | cnt[size[y]]++ ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~ a.cc:61:15: error: reference to 'size' is ambiguous 61 | cnt[n-size[x]]++ ; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:50:37: note: 'int size [400005]' 50 | int n,head[N],Next[N],ver[N],cnt[N],size[N],tot ; | ^~~~
s016064709
p03991
C
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <vector> #include <cmath> #define re register using namespace std; inline int read() { int X=0,w=1; char c=getchar(); while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); } while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar(); return X*w; } const int N=600000+10; const int mod=924844033; inline int qpow(int a,int b) { int c=1; for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod; return c; } int n; struct edge { int v,nxt; } e[N<<1]; int head[N]; inline void addEdge(int u,int v) { static int c=0; e[++c]=(edge){v,head[u]},head[u]=c; } int fac[N],ifac[N]; inline void init(int n) { fac[0]=1; for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod; ifac[n]=qpow(fac[n],mod-2); for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod; } inline int C(int n,int m) { return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod; } int cnt[N],sz[N]; inline void dfs(int u,int fa) { sz[u]=1; for (re int i=head[u];i;i=e[i].nxt) { int v=e[i].v; if (v==fa) continue; dfs(v,u),sz[u]+=sz[v],++cnt[sz[v]]; } ++cnt[n-sz[u]]; } int r[N],F[N],G[N]; inline void NTT(int* A,int n,int op) { for (re int i=0;i<n;++i) if (i<r[i]) swap(A[i],A[r[i]]); for (re int i=1;i<n;i<<=1) { int rot=qpow(op==1?5:554906420,(mod-1)/(i<<1)); for (re int j=0;j<n;j+=i<<1) for (re int k=0,w=1;k<i;++k,w=1ll*w*rot%mod) { int x=A[j+k],y=1ll*w*A[j+k+i]%mod; A[j+k]=(x+y)%mod,A[j+k+i]=(x-y+mod)%mod; } } if (op==-1) { int inv=qpow(n,mod-2); for (re int i=0;i<n;++i) A[i]=1ll*A[i]*inv%mod; } } int main() { n=read(); for (re int i=1;i<n;++i) { int u=read(),v=read(); addEdge(u,v),addEdge(v,u); } dfs(1,0); init(n); for (re int i=1;i<=n;++i) F[i]=1ll*cnt[i]*fac[i]%mod; reverse(F,F+n+1); for (re int i=0;i<=n;++i) G[i]=ifac[i]; int lim=1,l=0; for (;lim<=n<<1;lim<<=1,++l); for (re int i=0;i<lim;++i) r[i]=(r[i>>1]>>1)|((i&1)<<(l-1)); NTT(F,lim,1),NTT(G,lim,1); for (re int i=0;i<lim;++i) F[i]=1ll*F[i]*G[i]%mod; NTT(F,lim,-1); reverse(F,F+n+1); for (re int i=1;i<=n;++i) printf("%lld\n",(1ll*n*C(n,i)%mod -1ll*ifac[i]*F[i]%mod+mod)%mod); return 0; }
main.c:1:10: fatal error: algorithm: No such file or directory 1 | #include <algorithm> | ^~~~~~~~~~~ compilation terminated.
s988778827
p03991
C++
#include <bits/stdc++.h> using namespace std; inline int read() { int x=0,f=1,c=getchar(); while(c<48) c=='-'&&(f=-1),c=getchar(); while(c>47) x=x*10+c-'0',c=getchar(); return x*f; } const int MAXN = 600005; const int mod = 922844033; std::vector<int> G[MAXN]; int f[MAXN],g[MAXN],rev[MAXN]; int fac[MAXN],ifac[MAXN],cnt[MAXN],size[MAXN];; int n,m; inline void addedge(int u,int v) { G[u].push_back(v); G[v].push_back(u); } inline int qpow(int x,int k) { int res=1; for(int i=k; i; i>>=1,x=1ll*x*x%mod) if(i&1) res=1ll*res*x%mod; return res; } inline void init(int n) { for(int i=fac[0]=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod; ifac[n]=qpow(fac[n],mod-2); for(int i=n; i; --i) ifac[i-1]=1ll*ifac[i]*i%mod; } inline int cat(int n,int k) {return 1ll*fac[n]*ifac[k]%mod*ifac[n-k]%mod;} void dfs(int x,int fa) { size[x]=1; for(int y : G[x]) if(y^fa) dfs(y,x),size[x]+=size[y],++cnt[size[y]]; ++cnt[n-size[x]]; } inline void ntt(int *a,int n,int type) { for(int i=0; i<n; ++i) if(i<rev[i]) swap(a[i],a[rev[i]]); for(int i=1; i<n; i<<=1) { int rt=qpow(5,(mod-1)/(i<<1)); if(type==-1) rt=qpow(rt,mod-2); for(int j=0; j<n; j+=(i<<1)) for(int k=0,w=1; k<i; ++k,w=1ll*w*rt%mod) { int x=a[j+k],y=1ll*w*a[j+k+i]%mod; a[j+k]=(x+y)%mod,a[j+k+i]=(x-y+mod)%mod; } } if(type==1) return; int inv=qpow(n,mod-2); for(int i=0; i<n; ++i) a[i]=1ll*a[i]*inv%mod; } int main(int argc, char const *argv[]) { n=read(); for(int i=1; i<n; ++i) addedge(read(),read()); dfs(1,0); init(n); for(int i=1; i<=n; ++i) f[i]=1ll*cnt[i]*fac[i]%mod; reverse(f,f+n+1); for(int i=0; i<=n; ++i) g[i]=ifac[i]; int lim=1,l=0; while(lim<=n+n) lim<<=1,++l; for(int i=0; i<lim; ++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<(l-1)); ntt(f,lim,1),ntt(g,lim,1); for(int i=0; i<lim; ++i) f[i]=1ll*f[i]*g[i]%mod; ntt(f,lim,-1); reverse(f,f+n+1); for(int i=1; i<=n; ++i) { long long t=1ll*ifac[i]*f[i]%mod; printf("%lld\n", (1ll*n*cat(n,i)%mod-t+mod)%mod); } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:47:9: error: reference to 'size' is ambiguous 47 | size[x]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:16:36: note: 'int size [600005]' 16 | int fac[MAXN],ifac[MAXN],cnt[MAXN],size[MAXN];; | ^~~~ a.cc:49:35: error: reference to 'size' is ambiguous 49 | if(y^fa) dfs(y,x),size[x]+=size[y],++cnt[size[y]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:16:36: note: 'int size [600005]' 16 | int fac[MAXN],ifac[MAXN],cnt[MAXN],size[MAXN];; | ^~~~ a.cc:49:44: error: reference to 'size' is ambiguous 49 | if(y^fa) dfs(y,x),size[x]+=size[y],++cnt[size[y]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:16:36: note: 'int size [600005]' 16 | int fac[MAXN],ifac[MAXN],cnt[MAXN],size[MAXN];; | ^~~~ a.cc:49:58: error: reference to 'size' is ambiguous 49 | if(y^fa) dfs(y,x),size[x]+=size[y],++cnt[size[y]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:16:36: note: 'int size [600005]' 16 | int fac[MAXN],ifac[MAXN],cnt[MAXN],size[MAXN];; | ^~~~ a.cc:50:17: error: reference to 'size' is ambiguous 50 | ++cnt[n-size[x]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:16:36: note: 'int size [600005]' 16 | int fac[MAXN],ifac[MAXN],cnt[MAXN],size[MAXN];; | ^~~~
s302073209
p03991
C++
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=5e5,mod=924844033; int b[N],n,rev[N],w[N],limn,a[N],size[N],fst[N],nxt[N],to[N],fac[N],ifac[N],mm; void ade(int u,int v){to[++mm]=v,nxt[mm]=fst[u],fst[u]=mm;} void dfs(int u,int fa) { size[u]=1;++a[n]; for(int i=fst[u];i;i=nxt[i]) { int v=to[i];if(v==fa)continue; dfs(v,u),size[u]+=size[v]; } if(u!=1)--a[size[u]]; --a[n-size[u]]; } int qpower(int a,int b) { int ans=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ans=1ll*ans*a%mod; return ans; } void prework(int n) { limn=1;while(limn<=(n<<1))limn<<=1; for(int i=1;i<limn;i++)rev[i]=(rev[i>>1]>>1)|((i&1)?(limn>>1):0); for(int i=1;i<limn;i<<=1) { int omg=qpower(5,(mod-1)/(i<<1)); w[i]=1; for(int j=1;j<i;j++)w[i+j]=1ll*w[i+j-1]*omg%mod; } fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod; ifac[n]=qpower(fac[n],mod-2); for(int i=n-1;i>=0;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod; } void DFT(int a[]) { for(int i=0;i<limn;i++)if(i<rev[i])swap(a[i],a[rev[i]]); for(int i=1;i<limn;i<<=1) for(int j=0;j<limn;j+=i<<1) for(int k=0;k<i;k++) { int x=1ll*w[i+k]*a[i+j+k]%mod; a[i+j+k]=(a[j+k]-x)%mod,a[j+k]=(a[j+k]+x)%mod; } } void IDFT(int a[]) { reverse(a+1,a+limn);DFT(a);int iv=mod-(mod-1)/limn; for(int i=0;i<limn;i++)a[i]=1ll*iv*a[i]%mod; } int main() { scanf("%d",&n); for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),ade(u,v),ade(v,u); dfs(1,0); prework(n); for(int i=0;i<=n;i++)a[i]=1ll*a[i]*fac[i]%mod,b[i]=ifac[i]; reverse(a,a+n+1);DFT(a),DFT(b); for(int i=0;i<limn;i++)a[i]=1ll*a[i]*b[i]%mod; IDFT(a);reverse(a,a+n+1); for(int i=1;i<=n;i++)printf("%d\n",(1ll*a[i]*ifac[i]%mod+mod)%mod); }
a.cc: In function 'void dfs(int, int)': a.cc:11:5: error: reference to 'size' is ambiguous 11 | size[u]=1;++a[n]; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:7:34: note: 'int size [500000]' 7 | int b[N],n,rev[N],w[N],limn,a[N],size[N],fst[N],nxt[N],to[N],fac[N],ifac[N],mm; | ^~~~ a.cc:15:18: error: reference to 'size' is ambiguous 15 | dfs(v,u),size[u]+=size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:7:34: note: 'int size [500000]' 7 | int b[N],n,rev[N],w[N],limn,a[N],size[N],fst[N],nxt[N],to[N],fac[N],ifac[N],mm; | ^~~~ a.cc:15:27: error: reference to 'size' is ambiguous 15 | dfs(v,u),size[u]+=size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:7:34: note: 'int size [500000]' 7 | int b[N],n,rev[N],w[N],limn,a[N],size[N],fst[N],nxt[N],to[N],fac[N],ifac[N],mm; | ^~~~ a.cc:17:17: error: reference to 'size' is ambiguous 17 | if(u!=1)--a[size[u]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:7:34: note: 'int size [500000]' 7 | int b[N],n,rev[N],w[N],limn,a[N],size[N],fst[N],nxt[N],to[N],fac[N],ifac[N],mm; | ^~~~ a.cc:18:11: error: reference to 'size' is ambiguous 18 | --a[n-size[u]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:7:34: note: 'int size [500000]' 7 | int b[N],n,rev[N],w[N],limn,a[N],size[N],fst[N],nxt[N],to[N],fac[N],ifac[N],mm; | ^~~~
s601105849
p03991
C++
#include <bits/stdc++.h> #define ll long long using ull = unsigned long long; using namespace std; #define dump(x) \ if (dbg) { \ cerr << #x << " = " << (x) << endl; \ } #define overload4(_1, _2, _3, _4, name, ...) name #define FOR1(n) for (ll i = 0; i < (n); ++i) #define FOR2(i, n) for (ll i = 0; i < (n); ++i) #define FOR3(i, a, b) for (ll i = (a); i < (b); ++i) #define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__) #define FORR(i, a, b) for (int i = (a); i <= (b); ++i) #define bit(n, k) ((n >> k) & 1) /*nのk bit目*/ namespace mydef { const int INF = 1ll << 60; const int MOD = 924844033; template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } else return 0; } template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } else return 0; } void Yes(bool flag = true) { if (flag) cout << "Yes" << endl; else cout << "No" << endl; } void No(bool flag = true) { Yes(!flag); } void YES(bool flag = true) { if (flag) cout << "YES" << endl; else cout << "NO" << endl; } void NO(bool flag = true) { YES(!flag); } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); } bool dbg = true; } // namespace mydef using namespace mydef; #define pb push_back #define mp make_pair #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(), (v).end() #define SZ(x) ((int)(x).size()) #define vi vector<int> #define vvi vector<vector<int>> #define vp vector<pair<int, int>> #define vvp vector<vector<pair<int, int>>> #define pi pair<int, int> //#define P pair<int, int> //#define V vector<int> //#define S set<int> #define asn ans static struct IO { char tmp[1 << 10]; // fast input routines char cur; //#define nextChar() (cur = getc_unlocked(stdin)) //#define peekChar() (cur) inline char nextChar() { return cur = getc_unlocked(stdin); } inline char peekChar() { return cur; } inline operator bool() { return peekChar(); } inline static bool isBlank(char c) { return (c < '-' && c); } inline bool skipBlanks() { while (isBlank(nextChar())) ; return peekChar() != 0; } inline IO& operator>>(char& c) { c = nextChar(); return *this; } inline IO& operator>>(char* buf) { if (skipBlanks()) { if (peekChar()) { *(buf++) = peekChar(); while (!isBlank(nextChar())) *(buf++) = peekChar(); } *(buf++) = 0; } return *this; } inline IO& operator>>(string& s) { if (skipBlanks()) { s.clear(); s += peekChar(); while (!isBlank(nextChar())) s += peekChar(); } return *this; } inline IO& operator>>(double& d) { if ((*this) >> tmp) sscanf(tmp, "%lf", &d); return *this; } #define defineInFor(intType) \ inline IO& operator>>(intType& n) { \ if (skipBlanks()) { \ int sign = +1; \ if (peekChar() == '-') { \ sign = -1; \ n = nextChar() - '0'; \ } else \ n = peekChar() - '0'; \ while (!isBlank(nextChar())) { \ n += n + (n << 3) + peekChar() - 48; \ } \ n *= sign; \ } \ return *this; \ } defineInFor(int) defineInFor(unsigned int) defineInFor(long long) // fast output routines //#define putChar(c) putc_unlocked((c), stdout) inline void putChar(char c) { putc_unlocked(c, stdout); } inline IO& operator<<(char c) { putChar(c); return *this; } inline IO& operator<<(const char* s) { while (*s) putChar(*s++); return *this; } inline IO& operator<<(const string& s) { for (int i = 0; i < (int)s.size(); ++i) putChar(s[i]); return *this; } char* toString(double d) { sprintf(tmp, "%lf%c", d, '\0'); return tmp; } inline IO& operator<<(double d) { return (*this) << toString(d); } #define defineOutFor(intType) \ inline char* toString(intType n) { \ char* p = (tmp + 30); \ if (n) { \ bool isNeg = 0; \ if (n < 0) \ isNeg = 1, n = -n; \ while (n) \ *--p = (n % 10) + '0', n /= 10; \ if (isNeg) \ *--p = '-'; \ } else \ *--p = '0'; \ return p; \ } \ inline IO& operator<<(intType n) { return (*this) << toString(n); } defineOutFor(int) defineOutFor(long long) #define endl ('\n') #define cout __io__ #define cin __io__ } __io__; template <signed mod> struct NumberTheoreticTransform { private: vector<signed> rev, rts; //swap計算用の配列, \omega^iに相当するもの signed base, max_base, root; inline signed mod_add(signed a, signed b) { a += b; if (a >= mod) a -= mod; return a; } inline signed mod_mul(signed a, signed b) { return (1ull * a * b) % (unsigned long long)mod; } inline signed mod_pow(signed a, signed n) { signed ret = 1; while (n) { if (n & 1) ret = mod_mul(ret, a); a = mod_mul(a, a); n >>= 1; } return ret; } inline signed mod_inv(signed a) { return mod_pow(a, mod - 2); } // public: NumberTheoreticTransform() : base(1), rev{0, 1}, rts{0, 1} { assert(mod >= 3 && mod & 1 == 1); signed tmp = mod - 1; max_base = 0; while (tmp % 2 == 0) { tmp >>= 1; max_base++; } root = 2; while (mod_pow(root, (mod - 1) >> 1) == 1) root++; assert(mod_pow(root, mod - 1) == 1); root = mod_pow(root, (mod - 1) >> max_base); } // private: void ensure_base(signed nbase) { if (nbase <= base) return; assert(nbase <= max_base); rev.resize(1 << nbase); rts.resize(1 << nbase); for (signed i = 0; i < (1 << nbase); i++) { rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1)); } while (base < nbase) { signed z = mod_pow(root, 1 << (max_base - 1 - base)); for (signed i = 1 << (base - 1); i < (1 << base); i++) { rts[i << 1] = rts[i]; rts[(i << 1) + 1] = mod_mul(rts[i], z); } base++; } } void ntt(vector<signed>& a) { const signed n = (signed)a.size(); assert((n & (n - 1)) == 0); signed zeros = __builtin_ctz(n); ensure_base(zeros); signed shift = base - zeros; for (signed i = 0; i < n; i++) { if (i < (rev[i] >> shift)) swap(a[i], a[rev[i] >> shift]); } for (signed k = 1; k < n; k <<= 1) { for (signed i = 0; i < n; i += 2 * k) { for (signed j = 0; j < k; j++) { signed z = mod_mul(a[i + j + k], rts[j + k]); a[i + j + k] = mod_add(a[i + j], mod - z); a[i + j] = mod_add(a[i + j], z); } } } } // public: vector<signed> multiply(vector<signed> a, vector<signed> b) { if (a.empty() || b.empty()) return {}; bool eq = (a == b); signed need = a.size() + b.size() - 1; signed nbase = 1; while ((1 << nbase) < need) nbase++; ensure_base(nbase); signed sz = 1 << nbase; a.resize(sz, 0); b.resize(sz, 0); ntt(a); if (eq) b = a; else ntt(b); signed inv_sz = mod_inv(sz); for (signed i = 0; i < sz; i++) { a[i] = mod_mul(a[i], mod_mul(b[i], inv_sz)); } reverse(a.begin() + 1, a.end()); ntt(a); a.resize(need); return a; } vector<long long> multiply(vector<long long> a, vector<long long> b) { vector<signed> A(a.size()), B(b.size()); for (signed i = 0; i < a.size(); i++) { A[i] = a[i]; } for (signed i = 0; i < b.size(); i++) { B[i] = b[i]; } A = multiply(A, B); a.resize(A.size()); for (signed i = 0; i < A.size(); i++) a[i] = A[i]; return a; } }; template <typename sum_t, typename key_t> struct ReRooting { struct Edge { int to; key_t data; sum_t dp, ndp; }; using F = function<sum_t(sum_t, sum_t)>; using G = function<sum_t(sum_t, key_t)>; vector<vector<Edge>> g; vector<sum_t> subdp, dp; const sum_t ident; const F f; const G gg; ReRooting(int V, const F f, const G g, const sum_t& ident) : g(V), f(f), gg(g), ident(ident), subdp(V, ident), dp(V, ident) {} void add_edge(int u, int v, const key_t& d) { g[u].emplace_back((Edge){v, d, ident, ident}); g[v].emplace_back((Edge){u, d, ident, ident}); } void add_edge_bi(int u, int v, const key_t& d, const key_t& e) { g[u].emplace_back((Edge){v, d, ident, ident}); g[v].emplace_back((Edge){u, e, ident, ident}); } void dfs_sub(int idx, int par) { for (auto& e : g[idx]) { if (e.to == par) continue; dfs_sub(e.to, idx); subdp[idx] = f(subdp[idx], gg(subdp[e.to], e.data)); } } void dfs_all(int idx, int par, const sum_t& top) { sum_t buff{ident}; for (int i = 0; i < (int)g[idx].size(); i++) { auto& e = g[idx][i]; e.ndp = buff; e.dp = gg(par == e.to ? top : subdp[e.to], e.data); buff = f(buff, e.dp); } dp[idx] = buff; buff = ident; for (int i = (int)g[idx].size() - 1; i >= 0; i--) { auto& e = g[idx][i]; if (e.to != par) dfs_all(e.to, idx, f(e.ndp, buff)); e.ndp = f(e.ndp, buff); buff = f(buff, e.dp); } } vector<sum_t> build() { dfs_sub(0, -1); dfs_all(0, -1, ident); return dp; } }; int N, a[202020], b[202020]; template <uint MD> struct ModInt { using M = ModInt; const static M G; uint v; ModInt(ll _v = 0) { set_v(_v % MD + MD); } M& set_v(uint _v) { v = (_v < MD) ? _v : _v - MD; return *this; } explicit operator bool() const { return v != 0; } M operator-() const { return M() - *this; } M operator+(const M& r) const { return M().set_v(v + r.v); } M operator-(const M& r) const { return M().set_v(v + MD - r.v); } M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); } M operator/(const M& r) const { return *this * r.inv(); } M& operator+=(const M& r) { return *this = *this + r; } M& operator-=(const M& r) { return *this = *this - r; } M& operator*=(const M& r) { return *this = *this * r; } M& operator/=(const M& r) { return *this = *this / r; } bool operator==(const M& r) const { return v == r.v; } M pow(ll n) const { M x = *this, r = 1; while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } M inv() const { return pow(MD - 2); } /* M inv() const { long long b = MD, u = 1, v = 0; long long a = (*this).v; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MD; if (u < 0) u += MD; return M{u}; } */ friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; } friend istream& operator>>(istream& is, M& r) { return is >> r.v; } }; using Mint = ModInt<MOD>; const int MN = 2000010; Mint fact[MN], iFac[MN]; void first() { fact[0] = Mint(1); for (int i = 1; i < MN; i++) fact[i] = fact[i - 1] * Mint(i); iFac[MN - 1] = fact[MN - 1].inv(); for (int i = MN - 1; i >= 1; i--) { iFac[i - 1] = iFac[i] * Mint(i); } assert(fact[2345] * iFac[2345] == Mint(1)); } Mint C(int n, int k) { if (n < k || k < 0) return Mint(0); return fact[n] * iFac[k] * iFac[n - k]; } void solve() { int memo[202020] = {}; vector<Mint> cnt(N, Mint{0}); ReRooting<int, int> g( N, [](int a, int b) { return a + b; }, [&](int x, int i) { memo[i] = x + 1; return x + 1; }, 0); for (int i = 0; i < N - 1; i++) { g.add_edge(a[i], b[i], i); } g.build(); for (int i = 0; i < N - 1; i++) { if (memo[i] == 0) continue; cnt[memo[i]] += 1; cnt[N - memo[i]] += 1; } first(); vector<int> A(N, 0), B(N + 1, 0); for (int i = 0; i < N; i++) { A[i] = (fact[i] * cnt[i]).v; } for (int i = 0; i <= N; i++) { B[i] = iFac[N - i].v; } //NumberTheoreticTransform<MOD> ntt; //auto ans = ntt.multiply(A, B); ans.resize(A.size() + B.size()); for (int K = 1; K <= N; K++) { cout << (int)(C(N, K) * N - iFac[K] * ans[N + K]).v << endl; } } signed main() { cin >> N; for (int i = 0; i < N - 1; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; } solve(); return 0; }
a.cc:18:21: warning: overflow in conversion from 'long long int' to 'int' changes value from '1152921504606846976' to '0' [-Woverflow] 18 | const int INF = 1ll << 60; | ~~~~^~~~~ a.cc: In function 'void solve()': a.cc:506:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 506 | ans.resize(A.size() + B.size()); | ^~~ | abs
s181004301
p03991
C++
#include <bits/stdc++.h> #define ll long long using ull = unsigned long long; using namespace std; #define dump(x) \ if (dbg) { \ cerr << #x << " = " << (x) << endl; \ } #define overload4(_1, _2, _3, _4, name, ...) name #define FOR1(n) for (ll i = 0; i < (n); ++i) #define FOR2(i, n) for (ll i = 0; i < (n); ++i) #define FOR3(i, a, b) for (ll i = (a); i < (b); ++i) #define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__) #define FORR(i, a, b) for (int i = (a); i <= (b); ++i) #define bit(n, k) ((n >> k) & 1) /*nのk bit目*/ namespace mydef { const int INF = 1ll << 60; const int MOD = 924844033; template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } else return 0; } template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } else return 0; } void Yes(bool flag = true) { if (flag) cout << "Yes" << endl; else cout << "No" << endl; } void No(bool flag = true) { Yes(!flag); } void YES(bool flag = true) { if (flag) cout << "YES" << endl; else cout << "NO" << endl; } void NO(bool flag = true) { YES(!flag); } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); } bool dbg = true; } // namespace mydef using namespace mydef; #define pb push_back #define mp make_pair #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(), (v).end() #define SZ(x) ((int)(x).size()) #define vi vector<int> #define vvi vector<vector<int>> #define vp vector<pair<int, int>> #define vvp vector<vector<pair<int, int>>> #define pi pair<int, int> //#define P pair<int, int> //#define V vector<int> //#define S set<int> #define asn ans static struct IO { char tmp[1 << 10]; // fast input routines char cur; //#define nextChar() (cur = getc_unlocked(stdin)) //#define peekChar() (cur) inline char nextChar() { return cur = getc_unlocked(stdin); } inline char peekChar() { return cur; } inline operator bool() { return peekChar(); } inline static bool isBlank(char c) { return (c < '-' && c); } inline bool skipBlanks() { while (isBlank(nextChar())) ; return peekChar() != 0; } inline IO& operator>>(char& c) { c = nextChar(); return *this; } inline IO& operator>>(char* buf) { if (skipBlanks()) { if (peekChar()) { *(buf++) = peekChar(); while (!isBlank(nextChar())) *(buf++) = peekChar(); } *(buf++) = 0; } return *this; } inline IO& operator>>(string& s) { if (skipBlanks()) { s.clear(); s += peekChar(); while (!isBlank(nextChar())) s += peekChar(); } return *this; } inline IO& operator>>(double& d) { if ((*this) >> tmp) sscanf(tmp, "%lf", &d); return *this; } #define defineInFor(intType) \ inline IO& operator>>(intType& n) { \ if (skipBlanks()) { \ int sign = +1; \ if (peekChar() == '-') { \ sign = -1; \ n = nextChar() - '0'; \ } else \ n = peekChar() - '0'; \ while (!isBlank(nextChar())) { \ n += n + (n << 3) + peekChar() - 48; \ } \ n *= sign; \ } \ return *this; \ } defineInFor(int) defineInFor(unsigned int) defineInFor(long long) // fast output routines //#define putChar(c) putc_unlocked((c), stdout) inline void putChar(char c) { putc_unlocked(c, stdout); } inline IO& operator<<(char c) { putChar(c); return *this; } inline IO& operator<<(const char* s) { while (*s) putChar(*s++); return *this; } inline IO& operator<<(const string& s) { for (int i = 0; i < (int)s.size(); ++i) putChar(s[i]); return *this; } char* toString(double d) { sprintf(tmp, "%lf%c", d, '\0'); return tmp; } inline IO& operator<<(double d) { return (*this) << toString(d); } #define defineOutFor(intType) \ inline char* toString(intType n) { \ char* p = (tmp + 30); \ if (n) { \ bool isNeg = 0; \ if (n < 0) \ isNeg = 1, n = -n; \ while (n) \ *--p = (n % 10) + '0', n /= 10; \ if (isNeg) \ *--p = '-'; \ } else \ *--p = '0'; \ return p; \ } \ inline IO& operator<<(intType n) { return (*this) << toString(n); } defineOutFor(int) defineOutFor(long long) #define endl ('\n') #define cout __io__ #define cin __io__ } __io__; template <signed mod> struct NumberTheoreticTransform { private: vector<signed> rev, rts; //swap計算用の配列, \omega^iに相当するもの signed base, max_base, root; inline signed mod_add(signed a, signed b) { a += b; if (a >= mod) a -= mod; return a; } inline signed mod_mul(signed a, signed b) { return (1ull * a * b) % (unsigned long long)mod; } inline signed mod_pow(signed a, signed n) { signed ret = 1; while (n) { if (n & 1) ret = mod_mul(ret, a); a = mod_mul(a, a); n >>= 1; } return ret; } inline signed mod_inv(signed a) { return mod_pow(a, mod - 2); } // public: NumberTheoreticTransform() : base(1), rev{0, 1}, rts{0, 1} { assert(mod >= 3 && mod & 1 == 1); signed tmp = mod - 1; max_base = 0; while (tmp % 2 == 0) { tmp >>= 1; max_base++; } root = 2; while (mod_pow(root, (mod - 1) >> 1) == 1) root++; assert(mod_pow(root, mod - 1) == 1); root = mod_pow(root, (mod - 1) >> max_base); } // private: void ensure_base(signed nbase) { if (nbase <= base) return; assert(nbase <= max_base); rev.resize(1 << nbase); rts.resize(1 << nbase); for (signed i = 0; i < (1 << nbase); i++) { rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1)); } while (base < nbase) { signed z = mod_pow(root, 1 << (max_base - 1 - base)); for (signed i = 1 << (base - 1); i < (1 << base); i++) { rts[i << 1] = rts[i]; rts[(i << 1) + 1] = mod_mul(rts[i], z); } base++; } } void ntt(vector<signed>& a) { const signed n = (signed)a.size(); assert((n & (n - 1)) == 0); signed zeros = __builtin_ctz(n); ensure_base(zeros); signed shift = base - zeros; for (signed i = 0; i < n; i++) { if (i < (rev[i] >> shift)) swap(a[i], a[rev[i] >> shift]); } for (signed k = 1; k < n; k <<= 1) { for (signed i = 0; i < n; i += 2 * k) { for (signed j = 0; j < k; j++) { signed z = mod_mul(a[i + j + k], rts[j + k]); a[i + j + k] = mod_add(a[i + j], mod - z); a[i + j] = mod_add(a[i + j], z); } } } } // public: vector<signed> multiply(vector<signed> a, vector<signed> b) { if (a.empty() || b.empty()) return {}; bool eq = (a == b); signed need = a.size() + b.size() - 1; signed nbase = 1; while ((1 << nbase) < need) nbase++; ensure_base(nbase); signed sz = 1 << nbase; a.resize(sz, 0); b.resize(sz, 0); ntt(a); if (eq) b = a; else ntt(b); signed inv_sz = mod_inv(sz); for (signed i = 0; i < sz; i++) { a[i] = mod_mul(a[i], mod_mul(b[i], inv_sz)); } reverse(a.begin() + 1, a.end()); ntt(a); a.resize(need); return a; } vector<long long> multiply(vector<long long> a, vector<long long> b) { vector<signed> A(a.size()), B(b.size()); for (signed i = 0; i < a.size(); i++) { A[i] = a[i]; } for (signed i = 0; i < b.size(); i++) { B[i] = b[i]; } A = multiply(A, B); a.resize(A.size()); for (signed i = 0; i < A.size(); i++) a[i] = A[i]; return a; } }; template <typename sum_t, typename key_t> struct ReRooting { struct Edge { int to; key_t data; sum_t dp, ndp; }; using F = function<sum_t(sum_t, sum_t)>; using G = function<sum_t(sum_t, key_t)>; vector<vector<Edge>> g; vector<sum_t> subdp, dp; const sum_t ident; const F f; const G gg; ReRooting(int V, const F f, const G g, const sum_t& ident) : g(V), f(f), gg(g), ident(ident), subdp(V, ident), dp(V, ident) {} void add_edge(int u, int v, const key_t& d) { g[u].emplace_back((Edge){v, d, ident, ident}); g[v].emplace_back((Edge){u, d, ident, ident}); } void add_edge_bi(int u, int v, const key_t& d, const key_t& e) { g[u].emplace_back((Edge){v, d, ident, ident}); g[v].emplace_back((Edge){u, e, ident, ident}); } void dfs_sub(int idx, int par) { for (auto& e : g[idx]) { if (e.to == par) continue; dfs_sub(e.to, idx); subdp[idx] = f(subdp[idx], gg(subdp[e.to], e.data)); } } void dfs_all(int idx, int par, const sum_t& top) { sum_t buff{ident}; for (int i = 0; i < (int)g[idx].size(); i++) { auto& e = g[idx][i]; e.ndp = buff; e.dp = gg(par == e.to ? top : subdp[e.to], e.data); buff = f(buff, e.dp); } dp[idx] = buff; buff = ident; for (int i = (int)g[idx].size() - 1; i >= 0; i--) { auto& e = g[idx][i]; if (e.to != par) dfs_all(e.to, idx, f(e.ndp, buff)); e.ndp = f(e.ndp, buff); buff = f(buff, e.dp); } } vector<sum_t> build() { dfs_sub(0, -1); dfs_all(0, -1, ident); return dp; } }; int N, a[202020], b[202020]; template <uint MD> struct ModInt { using M = ModInt; const static M G; uint v; ModInt(ll _v = 0) { set_v(_v % MD + MD); } M& set_v(uint _v) { v = (_v < MD) ? _v : _v - MD; return *this; } explicit operator bool() const { return v != 0; } M operator-() const { return M() - *this; } M operator+(const M& r) const { return M().set_v(v + r.v); } M operator-(const M& r) const { return M().set_v(v + MD - r.v); } M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); } M operator/(const M& r) const { return *this * r.inv(); } M& operator+=(const M& r) { return *this = *this + r; } M& operator-=(const M& r) { return *this = *this - r; } M& operator*=(const M& r) { return *this = *this * r; } M& operator/=(const M& r) { return *this = *this / r; } bool operator==(const M& r) const { return v == r.v; } M pow(ll n) const { M x = *this, r = 1; while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } M inv() const { return pow(MD - 2); } /* M inv() const { long long b = MD, u = 1, v = 0; long long a = (*this).v; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MD; if (u < 0) u += MD; return M{u}; } */ friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; } friend istream& operator>>(istream& is, M& r) { return is >> r.v; } }; using Mint = ModInt<MOD>; const int MN = 2000010; Mint fact[MN], iFac[MN]; void first() { fact[0] = Mint(1); for (int i = 1; i < MN; i++) fact[i] = fact[i - 1] * Mint(i); iFac[MN - 1] = fact[MN - 1].inv(); for (int i = MN - 1; i >= 1; i--) { iFac[i - 1] = iFac[i] * Mint(i); } assert(fact[2345] * iFac[2345] == Mint(1)); } Mint C(int n, int k) { if (n < k || k < 0) return Mint(0); return fact[n] * iFac[k] * iFac[n - k]; } void solve() { int memo[202020] = {}; vector<Mint> cnt(N, Mint{0}); ReRooting<int, int> g( N, [](int a, int b) { return a + b; }, [&](int x, int i) { memo[i] = x + 1; return x + 1; }, 0); for (int i = 0; i < N - 1; i++) { g.add_edge(a[i], b[i], i); } g.build(); for (int i = 0; i < N - 1; i++) { if (memo[i] == 0) continue; cnt[memo[i]] += 1; cnt[N - memo[i]] += 1; } first(); vector<int> A(N, 0), B(N + 1, 0); for (int i = 0; i < N; i++) { A[i] = (fact[i] * cnt[i]).v; } for (int i = 0; i <= N; i++) { B[i] = iFac[N - i].v; } //NumberTheoreticTransform<MOD> ntt; //auto ans = ntt.multiply(A, B); ans.resize(A.size() + B.size()); for (int K = 1; K <= N; K++) { cout << (int)(C(N, K) * N - iFac[K] * ans[N + K]).v << endl; } } signed main() { cin >> N; for (int i = 0; i < N - 1; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; } solve(); return 0; }
a.cc:18:21: warning: overflow in conversion from 'long long int' to 'int' changes value from '1152921504606846976' to '0' [-Woverflow] 18 | const int INF = 1ll << 60; | ~~~~^~~~~ a.cc: In function 'void solve()': a.cc:506:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 506 | ans.resize(A.size() + B.size()); | ^~~ | abs
s903122602
p03991
C++
#pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native") #include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define pb push_back using namespace std; using ll = long long; using vi = vector<ll>; using pi = pair<ll, ll>; using vpi = vector<pi>; const int maxn = 1<<18, mod = 924844033; namespace algebra { const int inf = 1e9; const int magic = 0; // threshold for sizes to run the naive algo namespace fft { const int maxn = 1 << 18; typedef double ftype; typedef complex<ftype> point; point w[maxn]; const ftype pi = acos(-1); bool initiated = false; void init(){ if(!initiated){ for(int i = 1; i < maxn; i <<= 1) for(int j = 0; j < i; ++ j) w[i + j] = polar(ftype(1), pi * j / i); initiated = true; } } template<typename T> void fft(T *in, point *out, int n, int k = 1){ if(n == 1) *out = *in; else{ n >>= 1; fft(in, out, n, 2 * k); fft(in + k, out + n, n, 2 * k); for(int i = 0; i < n; ++ i){ auto t = out[i + n] * w[i + n]; out[i + n] = out[i] - t; out[i] += t; } } } template<typename T> void mul_slow(vector<T> &a, const vector<T> &b){ vector<T> res(int(a.size() + b.size()) - 1); for(size_t i = 0; i < a.size(); ++ i){ for(size_t j = 0; j < int(b.size()); ++ j){ res[i + j] += a[i] * b[j]; } } a = res; } template<typename T> void mul(vector<T> &a, const vector<T> &b){ if(int(min(a.size(), b.size())) < magic){ mul_slow(a, b); return; } init(); static const int shift = 15, mask = (1 << shift) - 1; size_t n = a.size() + b.size() - 1; while(__builtin_popcount(n) != 1) ++ n; a.resize(n); static point A[maxn], B[maxn]; static point C[maxn], D[maxn]; for(size_t i = 0; i < n; ++ i){ A[i] = point(a[i] & mask, a[i] >> shift); if(i < b.size()) { B[i] = point(b[i] & mask, b[i] >> shift); } else { B[i] = 0; } } fft(A, C, n); fft(B, D, n); for(size_t i = 0; i < n; i++) { point c0 = C[i] + conj(C[(n - i) % n]); point c1 = C[i] - conj(C[(n - i) % n]); point d0 = D[i] + conj(D[(n - i) % n]); point d1 = D[i] - conj(D[(n - i) % n]); A[i] = c0 * d0 - point(0, 1) * c1 * d1; B[i] = c0 * d1 + d0 * c1; } fft(A, C, n); fft(B, D, n); reverse(C + 1, C + n); reverse(D + 1, D + n); int t = 4 * n; for(size_t i = 0; i < n; i++) { long long A0 = llround(real(C[i]) / t); T A1 = llround(imag(D[i]) / t); T A2 = llround(imag(C[i]) / t); a[i] = A0 + (A1 << shift) + (A2 << 2 * shift); } return; } } template<typename T> T bpow(T x, size_t n) { return n ? n % 2 ? x * bpow(x, n - 1) : bpow(x * x, n / 2) : T(1); } template<typename T> T bpow(T x, size_t n, T m) { return n ? n % 2 ? x * bpow(x, n - 1, m) % m : bpow(x * x % m, n / 2, m) : T(1); } template<typename T> T gcd(const T &a, const T &b) { return b == T(0) ? a : gcd(b, a % b); } template<typename T> T nCr(T n, int r) { // runs in O(r) T res(1); for(int i = 0; i < r; i++) { res *= (n - T(i)); res /= (i + 1); } return res; } struct modular { long long r; modular() : r(0) {} modular(long long rr) : r(rr) {if(abs(r) >= mod) r %= mod; if(r < 0) r += mod;} modular inv() const {return bpow(*this, mod - 2);} modular operator * (const modular &t) const {return (r * t.r) % mod;} modular operator / (const modular &t) const {return *this * t.inv();} modular operator += (const modular &t) {r += t.r; if(r >= mod) r -= mod; return *this;} modular operator -= (const modular &t) {r -= t.r; if(r < 0) r += mod; return *this;} modular operator + (const modular &t) const {return modular(*this) += t;} modular operator - (const modular &t) const {return modular(*this) -= t;} modular operator *= (const modular &t) {return *this = *this * t;} modular operator /= (const modular &t) {return *this = *this / t;} bool operator == (const modular &t) const {return r == t.r;} bool operator != (const modular &t) const {return r != t.r;} operator long long() const {return r;} }; istream& operator >> (istream &in, modular &x) { return in >> x.r; } template<typename T> struct poly { vector<T> a; void normalize() { // get rid of leading zeroes while(!a.empty() && a.back() == T(0)) { a.pop_back(); } } poly(){} poly(T a0) : a{a0}{normalize();} poly(vector<T> t) : a(t){normalize();} poly operator += (const poly &t) { a.resize(max(a.size(), t.a.size())); for(size_t i = 0; i < t.a.size(); i++) { a[i] += t.a[i]; } normalize(); return *this; } poly operator -= (const poly &t) { a.resize(max(a.size(), t.a.size())); for(size_t i = 0; i < t.a.size(); i++) { a[i] -= t.a[i]; } normalize(); return *this; } poly operator + (const poly &t) const {return poly(*this) += t;} poly operator - (const poly &t) const {return poly(*this) -= t;} poly mod_xk(size_t k) const { // get same polynomial mod x^k k = min(k, a.size()); return vector<T>(begin(a), begin(a) + k); } poly mul_xk(size_t k) const { // multiply by x^k poly res(*this); res.a.insert(begin(res.a), k, 0); return res; } poly div_xk(size_t k) const { // divide by x^k, dropping coefficients k = min(k, a.size()); return vector<T>(begin(a) + k, end(a)); } poly substr(size_t l, size_t r) const { // return mod_xk(r).div_xk(l) l = min(l, a.size()); r = min(r, a.size()); return vector<T>(begin(a) + l, begin(a) + r); } poly inv(size_t n) const { // get inverse series mod x^n assert(!is_zero()); poly ans = a[0].inv(); size_t a = 1; while(a < n) { poly C = (ans * mod_xk(2 * a)).substr(a, 2 * a); ans -= (ans * C).mod_xk(a).mul_xk(a); a *= 2; } return ans.mod_xk(n); } poly operator *= (const poly &t) {fft::mul(a, t.a); normalize(); return *this;} poly operator * (const poly &t) const {return poly(*this) *= t;} poly reverse(size_t n, bool rev = 0) const { // reverses and leaves only n terms poly res(*this); if(rev) { // If rev = 1 then tail goes to head res.a.resize(max(n, res.a.size())); } std::reverse(res.a.begin(), res.a.end()); return res.mod_xk(n); } pair<poly, poly> divmod_slow(const poly &b) const { // when divisor or quotient is small vector<T> A(a); vector<T> res; while(A.size() >= b.a.size()) { res.push_back(A.back() / b.a.back()); if(res.back() != T(0)) { for(size_t i = 0; i < b.a.size(); i++) { A[A.size() - i - 1] -= res.back() * b.a[b.a.size() - i - 1]; } } A.pop_back(); } std::reverse(begin(res), end(res)); return {res, A}; } pair<poly, poly> divmod(const poly &b) const { // returns quotiend and remainder of a mod b if(deg() < b.deg()) { return {poly{0}, *this}; } int d = deg() - b.deg(); if(min(d, b.deg()) < magic) { return divmod_slow(b); } poly D = (reverse(d + 1) * b.reverse(d + 1).inv(d + 1)).mod_xk(d + 1).reverse(d + 1, 1); return {D, *this - D * b}; } poly operator / (const poly &t) const {return divmod(t).first;} poly operator % (const poly &t) const {return divmod(t).second;} poly operator /= (const poly &t) {return *this = divmod(t).first;} poly operator %= (const poly &t) {return *this = divmod(t).second;} poly operator *= (const T &x) { for(auto &it: a) { it *= x; } normalize(); return *this; } poly operator /= (const T &x) { for(auto &it: a) { it /= x; } normalize(); return *this; } poly operator * (const T &x) const {return poly(*this) *= x;} poly operator / (const T &x) const {return poly(*this) /= x;} void print() const { for(auto it: a) { cout << it << ' '; } cout << endl; } T eval(T x) const { // evaluates in single point x T res(0); for(int i = int(a.size()) - 1; i >= 0; i--) { res *= x; res += a[i]; } return res; } T& lead() { // leading coefficient return a.back(); } int deg() const { // degree return a.empty() ? -inf : a.size() - 1; } bool is_zero() const { // is polynomial zero return a.empty(); } T operator [](int idx) const { return idx >= (int)a.size() || idx < 0 ? T(0) : a[idx]; } T& coef(size_t idx) { // mutable reference at coefficient return a[idx]; } bool operator == (const poly &t) const {return a == t.a;} bool operator != (const poly &t) const {return a != t.a;} poly deriv() { // calculate derivative vector<T> res; for(int i = 1; i <= deg(); i++) { res.push_back(T(i) * a[i]); } return res; } poly integr() { // calculate integral with C = 0 vector<T> res = {0}; for(int i = 0; i <= deg(); i++) { res.push_back(a[i] / T(i + 1)); } return res; } size_t leading_xk() const { // Let p(x) = x^k * t(x), return k if(is_zero()) { return inf; } int res = 0; while(a[res] == T(0)) { res++; } return res; } poly log(size_t n) { // calculate log p(x) mod x^n assert(a[0] == T(1)); return (deriv().mod_xk(n) * inv(n)).integr().mod_xk(n); } poly exp(size_t n) { // calculate exp p(x) mod x^n if(is_zero()) { return T(1); } assert(a[0] == T(0)); poly ans = T(1); size_t a = 1; while(a < n) { poly C = ans.log(2 * a).div_xk(a) - substr(a, 2 * a); ans -= (ans * C).mod_xk(a).mul_xk(a); a *= 2; } return ans.mod_xk(n); } poly pow_slow(size_t k, size_t n) { // if k is small return k ? k % 2 ? (*this * pow_slow(k - 1, n)).mod_xk(n) : (*this * *this).mod_xk(n).pow_slow(k / 2, n) : T(1); } poly pow(size_t k, size_t n) { // calculate p^k(n) mod x^n if(is_zero()) { return *this; } if(k < magic) { return pow_slow(k, n); } int i = leading_xk(); T j = a[i]; poly t = div_xk(i) / j; return bpow(j, k) * (t.log(n) * T(k)).exp(n).mul_xk(i * k).mod_xk(n); } poly mulx(T x) { // component-wise multiplication with x^k T cur = 1; poly res(*this); for(int i = 0; i <= deg(); i++) { res.coef(i) *= cur; cur *= x; } return res; } poly mulx_sq(T x) { // component-wise multiplication with x^{k^2} T cur = x; T total = 1; T xx = x * x; poly res(*this); for(int i = 0; i <= deg(); i++) { res.coef(i) *= total; total *= cur; cur *= xx; } return res; } vector<T> chirpz_even(T z, int n) { // P(1), P(z^2), P(z^4), ..., P(z^2(n-1)) int m = deg(); if(is_zero()) { return vector<T>(n, 0); } vector<T> vv(m + n); T zi = z.inv(); T zz = zi * zi; T cur = zi; T total = 1; for(int i = 0; i <= max(n - 1, m); i++) { if(i <= m) {vv[m - i] = total;} if(i < n) {vv[m + i] = total;} total *= cur; cur *= zz; } poly w = (mulx_sq(z) * vv).substr(m, m + n).mulx_sq(z); vector<T> res(n); for(int i = 0; i < n; i++) { res[i] = w[i]; } return res; } vector<T> chirpz(T z, int n) { // P(1), P(z), P(z^2), ..., P(z^(n-1)) auto even = chirpz_even(z, (n + 1) / 2); auto odd = mulx(z).chirpz_even(z, n / 2); vector<T> ans(n); for(int i = 0; i < n / 2; i++) { ans[2 * i] = even[i]; ans[2 * i + 1] = odd[i]; } if(n % 2 == 1) { ans[n - 1] = even.back(); } return ans; } template<typename iter> vector<T> eval(vector<poly> &tree, int v, iter l, iter r) { // auxiliary evaluation function if(r - l == 1) { return {eval(*l)}; } else { auto m = l + (r - l) / 2; auto A = (*this % tree[2 * v]).eval(tree, 2 * v, l, m); auto B = (*this % tree[2 * v + 1]).eval(tree, 2 * v + 1, m, r); A.insert(end(A), begin(B), end(B)); return A; } } vector<T> eval(vector<T> x) { // evaluate polynomial in (x1, ..., xn) int n = x.size(); if(is_zero()) { return vector<T>(n, T(0)); } vector<poly> tree(4 * n); build(tree, 1, begin(x), end(x)); return eval(tree, 1, begin(x), end(x)); } template<typename iter> poly inter(vector<poly> &tree, int v, iter l, iter r, iter ly, iter ry) { // auxiliary interpolation function if(r - l == 1) { return {*ly / a[0]}; } else { auto m = l + (r - l) / 2; auto my = ly + (ry - ly) / 2; auto A = (*this % tree[2 * v]).inter(tree, 2 * v, l, m, ly, my); auto B = (*this % tree[2 * v + 1]).inter(tree, 2 * v + 1, m, r, my, ry); return A * tree[2 * v + 1] + B * tree[2 * v]; } } }; template<typename T> poly<T> operator * (const T& a, const poly<T>& b) { return b * a; } template<typename T> poly<T> xk(int k) { // return x^k return poly<T>{1}.mul_xk(k); } template<typename T> T resultant(poly<T> a, poly<T> b) { // computes resultant of a and b if(b.is_zero()) { return 0; } else if(b.deg() == 0) { return bpow(b.lead(), a.deg()); } else { int pw = a.deg(); a %= b; pw -= a.deg(); T mul = bpow(b.lead(), pw) * T((b.deg() & a.deg() & 1) ? -1 : 1); T ans = resultant(b, a); return ans * mul; } } template<typename iter> poly<typename iter::value_type> kmul(iter L, iter R) { // computes (x-a1)(x-a2)...(x-an) without building tree if(R - L == 1) { return vector<typename iter::value_type>{-*L, 1}; } else { iter M = L + (R - L) / 2; return kmul(L, M) * kmul(M, R); } } template<typename T, typename iter> poly<T> build(vector<poly<T>> &res, int v, iter L, iter R) { // builds evaluation tree for (x-a1)(x-a2)...(x-an) if(R - L == 1) { return res[v] = vector<T>{-*L, 1}; } else { iter M = L + (R - L) / 2; return res[v] = build(res, 2 * v, L, M) * build(res, 2 * v + 1, M, R); } } template<typename T> poly<T> inter(vector<T> x, vector<T> y) { // interpolates minimum polynomial from (xi, yi) pairs int n = x.size(); vector<poly<T>> tree(4 * n); return build(tree, 1, begin(x), end(x)).deriv().inter(tree, 1, begin(x), end(x), begin(y), end(y)); } }; using namespace algebra; int n; vector<int> g[maxn]; vector<modular> sub; int dfs(int v, int p) { int sz = 1; for(auto &i : g[v]) if(i != p) { int t = dfs(i, v); sz += t; sub[t]+=1; } sub[n - sz]+=1; return sz; } modular fact[maxn], inv[maxn]; void setup() { fact[0] = inv[0] = 1; for(int i = 1; i < maxn; i++) { fact[i] = fact[i-1]*modular(i); inv[i] = fact[i].inv(); } } modular nck(ll n, ll k) { if(k>n) return 0; return fact[n]*inv[k]*inv[n-k]; } int main() { cin.tie(0)->sync_with_stdio(0); setup(); cin >> n; for(int f, t, i = 1; i < n; i++) { cin >> f >> t; g[f].push_back(t); g[t].push_back(f); } sub.resize(n+1); dfs(1, 1); poly<modular> P(sub); vector<modular> x; for(int i = 1; i <= n+1; i++) x.push_back(i); auto y = P.eval(x); for(auto &i : x) i-=1; auto S = inter(x, y); //cout << S.a.size() << " " << x.size() << " " << y.size() << " " << P.a.size() << '\n'; for(int i = 1; i < n; i++) cout << nck(n, i)*modular(n) - S.a[i] << "\n"; cout << n << '\n'; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:4: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53: /usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here 132 | struct _Vector_impl | ^~~~~~~~~~~~
s377611044
p03991
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define poly vector<ll> #define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++) #define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--) #define pb push_back inline char gc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; } #define gc getchar inline ll read(){ ll x=0;char ch=gc();bool positive=1; for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0; for(;isdigit(ch);ch=gc()) x=x*10+ch-'0'; return positive?x:-x; } inline void write(ll x){ if(x<0){ x=-x;putchar('-'); } if(x>=10) write(x/10); putchar('0'+x%10); } inline void writeln(ll x){write(x);puts("");} inline void writep(ll x){write(x);putchar(' ');} inline ull rnd(){ return ((ull)rand()<<30^rand())<<4|rand()%4; } const int N=4e5+5,mo=924844033,FFTN=1<<19; int W[N],w[N],p[N]; poly R; int ksm(int x,int p){ int res=1; for(;p;p>>=1,x=(ll)x*x%mo){ if(p&1) res=(ll)res*x%mo; } return res; } void FFTinit(){ W[0]=1;W[1]=ksm(5,(mo-1)/FFTN); For(i,2,N-1) W[i]=(ll)W[i-1]*W[1]%mo; } int FFTinit(int n){ int L=1;for(;L<=n;L<<=1);R.resize(L); For(i,0,L-1) R[i]=(R[i>>1]>>1)|((i&1)?(L>>1):0); return L; } void DFT(poly &a,int n){ a.resize(n);For(i,0,n-1) p[R[i]]=a[i]; for(int d=1;d<n;d<<=1){ int len=FFTN/(d<<1); for(int i=0,j=0;i<d;i++,j+=len) w[i]=W[j]; for(int i=0;i<n;i+=(d<<1)){ For(j,0,d-1){ int y=(ll)w[j]*p[i+j+d]%mo; p[i+j+d]=(p[i+j]-y+mo)%mo; p[i+j]=(p[i+j]+y)%mo; } } } For(i,0,n-1) a[i]=p[i]; } void IDFT(poly &a,int n){ DFT(a,n);reverse(a.begin()+1,a.end()); int inv=ksm(n,mo-2); For(i,0,n-1) a[i]=(ll)a[i]*inv%mo; } int head[N],opt,f[N]; struct info{ int to,nxt; }e[N<<1]; void add(int x,int y){ e[++opt]=(info){y,head[x]};head[x]=opt; e[++opt]=(info){x,head[y]};head[y]=opt; } int size[N]; void dfs(int n,int u,int fa){ size[u]=1; for(int i=head[u];i;i=e[i].nxt){ int k=e[i].to; if(k==fa) continue; dfs(n,k,u);size[u]+=size[k]; f[size[k]]++; } if(fa) f[n-size[u]]++; } int fac[N],inv[N]; void init(int n){ For(i,fac[0]=1,n) fac[i]=(ll)fac[i-1]*i%mo; inv[n]=ksm(fac[n],mo-2); Rep(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo; } int C(int n,int m){ if(n<m) return 0; return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo; } poly a,b; poly mul(poly a,poly b){ int n=a.size(),m=b.size(),len=FFTinit(n+m); DFT(a,len);DFT(b,len); For(i,0,len-1) a[i]=(ll)a[i]*b[i]%mo; IDFT(a,len);return a; } int main(){ init(N-1);FFTinit(); int n=read(); For(i,1,n-1) add(read(),read()); dfs(n,1,0); a.resize(n+1);For(i,0,n) a[i]=(ll)f[i]*fac[i]%mo; b.resize(n+1);For(i,0,n) b[i]=inv[i]; reverse(b.begin(),b.end()); a=mul(a,b); For(i,1,n) a[n+i]=(ll)a[n+i]*inv[i]%mo; For(i,1,n) writeln(((ll)C(n,i)*n%mo-a[n+i]+mo)%mo); }
a.cc: In function 'void dfs(int, int, int)': a.cc:86:9: error: reference to 'size' is ambiguous 86 | size[u]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:84:5: note: 'int size [400005]' 84 | int size[N]; | ^~~~ a.cc:90:28: error: reference to 'size' is ambiguous 90 | dfs(n,k,u);size[u]+=size[k]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:84:5: note: 'int size [400005]' 84 | int size[N]; | ^~~~ a.cc:90:37: error: reference to 'size' is ambiguous 90 | dfs(n,k,u);size[u]+=size[k]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:84:5: note: 'int size [400005]' 84 | int size[N]; | ^~~~ a.cc:91:19: error: reference to 'size' is ambiguous 91 | f[size[k]]++; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:84:5: note: 'int size [400005]' 84 | int size[N]; | ^~~~ a.cc:93:20: error: reference to 'size' is ambiguous 93 | if(fa) f[n-size[u]]++; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:84:5: note: 'int size [400005]' 84 | int size[N]; | ^~~~
s015121993
p03991
C++
#include<bits/stdc++.h> #define mod 924844033 using namespace std; int n,x,y; int fir[200005],nxt[400005],to[400005],cnt; int size[200005],Cnt[200005]; int fac[200005],ifac[200005]; int lim=1,L=0,f[800005],g[800005],R[800005],Inv; int read(){ int x=0;char ch=getchar(); while(!isdigit(ch)) ch=getchar(); while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); return x; } void print(int x){ if(x>=10) print(x/10); putchar(x%10+'0'); } void dfs(int x,int f){ size[x]=1; for(int i=fir[x];i;i=nxt[i]){ if(to[i]==f) continue; dfs(to[i],x); size[x]+=size[to[i]]; Cnt[size[to[i]]]++; } if(x!=1) Cnt[n-size[x]]++; } int ksm(int x,int y){ int res=1; while(y){ if(y&1) res=1ll*res*x%mod; x=1ll*x*x%mod,y/=2; } return res; } int C(int x,int y){ int res=1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod; return res; } void NTT(int *x,int on){ for(int i=0;i<lim;i++) if(i<R[i]) swap(x[i],x[R[i]]); for(int i=2;i<=lim;i*=2){ int wn=ksm(5,(mod-1)/i); if(on==-1) wn=ksm(wn,mod-2); for(int j=0;j<lim;j+=i){ int w=1; for(int k=0;k<i/2;k++){ int u=x[j+k],v=1ll*w*x[j+k+i/2]%mod; x[j+k]=(u+v)%mod; x[j+k+i/2]=(u+mod-v)%mod; w=1ll*w*wn%mod; } } } } int main(){ n=read(); fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*i*fac[i-1]%mod; ifac[n]=ksm(fac[n],mod-2); for(int i=n-1;i>=0;i--) ifac[i]=1ll*(i+1)*ifac[i+1]%mod; for(int i=1;i<n;i++){ x=read(),y=read(); to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt; to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt; } dfs(1,0); while(lim<=2*n) lim*=2,L++; for(int i=0;i<lim;i++) R[i]=(R[i>>1]>>1)|((i&1)<<(L-1)); for(int i=1;i<=n;i++) f[i]=1ll*Cnt[i]*fac[i]%mod; for(int i=0;i<=n;i++) g[i]=ifac[n-i]; NTT(f,1),NTT(g,1); for(int i=0;i<lim;i++) f[i]=1ll*f[i]*g[i]%mod; NTT(f,-1); Inv=ksm(lim,mod-2); for(int i=1,v;i<=n;i++){ v=(1ll*n*C(n,i)%mod+mod-1ll*ifac[i]*f[n+i]%mod*Inv%mod)%mod; print(v),puts(""); } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:23:5: error: reference to 'size' is ambiguous 23 | size[x]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:27:9: error: reference to 'size' is ambiguous 27 | size[x]+=size[to[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:27:18: error: reference to 'size' is ambiguous 27 | size[x]+=size[to[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:28:13: error: reference to 'size' is ambiguous 28 | Cnt[size[to[i]]]++; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:30:20: error: reference to 'size' is ambiguous 30 | if(x!=1) Cnt[n-size[x]]++; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~
s339503427
p03991
C++
#include<bits/stdc++.h> #define mod 924844033 using namespace std; int n,x,y; int fir[200005],nxt[400005],to[400005],cnt; int size[200005],Cnt[200005]; int fac[200005],ifac[200005]; int lim=1,L=0,f[800005],g[800005],R[800005],Inv; int read(){ int x=0;char ch=getchar(); while(!isdigit(ch)) ch=getchar(); while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); return x; } void print(int x){ if(x>=10) print(x/10); putchar(x%10+'0'); } void dfs(int x,int f){ size[x]=1; for(int i=fir[x];i;i=nxt[i]){ if(to[i]==f) continue; dfs(to[i],x); size[x]+=size[to[i]]; Cnt[size[to[i]]]++; } if(x!=1) Cnt[n-size[x]]++; } int ksm(int x,int y){ int res=1; while(y){ if(y&1) res=1ll*res*x%mod; x=1ll*x*x%mod,y/=2; } return res; } int C(int x,int y){ int res=1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod; return res; } void NTT(int *x,int on){ for(int i=0;i<lim;i++) if(i<R[i]) swap(x[i],x[R[i]]); for(int i=2;i<=lim;i*=2){ int wn=ksm(5,(mod-1)/i); if(on==-1) wn=ksm(wn,mod-2); for(int j=0;j<lim;j+=i){ int w=1; for(int k=0;k<i/2;k++){ int u=x[j+k],v=1ll*w*x[j+k+i/2]%mod; x[j+k]=(u+v)%mod; x[j+k+i/2]=(u+mod-v)%mod; w=1ll*w*wn%mod; } } } } int main(){ n=read(); fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*i*fac[i-1]%mod; ifac[n]=ksm(fac[n],mod-2); for(int i=n-1;i>=0;i--) ifac[i]=1ll*(i+1)*ifac[i+1]%mod; for(int i=1;i<n;i++){ x=read(),y=read(); to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt; to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt; } dfs(1,0); while(lim<=2*n) lim*=2,L++; for(int i=0;i<lim;i++) R[i]=(R[i>>1]>>1)|((i&1)<<(L-1)); for(int i=1;i<=n;i++) f[i]=1ll*Cnt[i]*fac[i]%mod; for(int i=0;i<=n;i++) g[i]=ifac[n-i]; NTT(f,1),NTT(g,1); for(int i=0;i<lim;i++) f[i]=1ll*f[i]*g[i]%mod; NTT(f,-1); Inv=ksm(lim,mod-2); for(int i=1,v;i<=n;i++){ v=(1ll*n*C(n,i)%mod+mod-1ll*ifac[i]*f[n+i]%mod*Inv%mod)%mod; print(v),puts(""); } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:23:5: error: reference to 'size' is ambiguous 23 | size[x]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:27:9: error: reference to 'size' is ambiguous 27 | size[x]+=size[to[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:27:18: error: reference to 'size' is ambiguous 27 | size[x]+=size[to[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:28:13: error: reference to 'size' is ambiguous 28 | Cnt[size[to[i]]]++; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~ a.cc:30:20: error: reference to 'size' is ambiguous 30 | if(x!=1) Cnt[n-size[x]]++; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:5: note: 'int size [200005]' 6 | int size[200005],Cnt[200005]; | ^~~~
s873029942
p03991
C++
#include <iostream> #include <cstdio> using namespace std; const int maxn = 2e5 + 50,maxm = 5.3e5,mod = 924844033,g = 5; int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; struct edge{ int v,nxt; }e[2 * maxn]; int read(){ int x = 0; char c = getchar(); while(c < '0' || c > '9') c = getchar(); while(c >= '0' && c <= '9') x = x * 10 + (c ^ 48),c = getchar(); return x; } inline int add(int x,int y){ if(x + y < mod) return x + y; else return x + y - mod; } inline int dec(int x,int y){ if(x - y >= 0) return x - y; else return x - y + mod; } int qpow(int x,int k){ int d = 1,t = x; while(k){ if(k & 1) d = 1ll * d * t % mod; t = 1ll * t * t % mod,k >>= 1; } return d; } void NTT_init(int n){ N = 1; int cnt = 0; while(N <= n) N <<= 1,cnt ++; for(int i = 0; i < N; i ++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (cnt - 1)); } void NTT(int *F,int n,int p){ for(int i = 0; i < n; i ++) if(i < rev[i]) swap(F[i],F[rev[i]]); int cnt = 1; for(int i = 1; i < n; i <<= 1){ int w1 = (p == 1 ? W[cnt] : inv_W[cnt]); for(int j = 0; j < n; j += i << 1){ int w = 1; for(int k = j; k < j + i; k ++){ int t1 = F[k],t2 = 1ll * w * F[k + i] % mod; F[k] = add(t1,t2),F[k + i] = dec(t1,t2); w = 1ll * w * w1 % mod; } } cnt ++; } if(p == -1) for(int i = 0; i < n; i ++) F[i] = 1ll * F[i] * inv[cnt - 1] % mod; } void Mul(int *F,int *G,int n){ NTT_init(n << 1); NTT(F,N,1),NTT(G,N,1); for(int i = 0; i < N; i ++) F[i] = 1ll * F[i] * G[i] % mod; NTT(F,N,-1); } void init(int n){ NTT_init(n << 1); int t = qpow(2,mod - 2); inv[0] = 1; for(int i = 1; (1 << i) <= N; i ++) inv[i] = 1ll * inv[i - 1] * t % mod; for(int i = 1; (1 << i) <= N; i ++) W[i] = qpow(g,(mod - 1) / (1 << i)),inv_W[i] = qpow(W[i],mod - 2); } inline void insert(int x,int y){ cnt ++,e[cnt].v = y,e[cnt].nxt = last[x],last[x] = cnt; } void dfs(int u,int fa){ size[u] = 1; for(int i = last[u]; i; i = e[i].nxt){ int v = e[i].v; if(v == fa) continue; dfs(v,u); size[u] += size[v]; } if(u != fa) d[size[u]] --,d[n - size[u]] --; } int main(){ n = read(); for(int i = 1; i < n; i ++){ x = read(),y = read(); insert(x,y),insert(y,x); } dfs(1,1); d[n] = n; init(n); int p = 1; for(int i = 0; i <= n; i ++) p = 1ll * p * (i ? i : 1) % mod,F[n - i] = 1ll * p * dec(d[i],0) % mod; int t = qpow(p,mod - 2); for(int i = n; i >= 0; i --) G[i] = ifac[i] = t,t = 1ll * t * i % mod; // for(int i = 0; i <= n; i ++) cout << F[i] << ' ' << G[i] << endl; Mul(F,G,n); for(int i = 1; i <= n; i ++) printf("%d\n",1ll * ifac[i] * F[n - i] % mod); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:72:9: error: reference to 'size' is ambiguous 72 | size[u] = 1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:77:17: error: reference to 'size' is ambiguous 77 | size[u] += size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:77:28: error: reference to 'size' is ambiguous 77 | size[u] += size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:79:23: error: reference to 'size' is ambiguous 79 | if(u != fa) d[size[u]] --,d[n - size[u]] --; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:79:41: error: reference to 'size' is ambiguous 79 | if(u != fa) d[size[u]] --,d[n - size[u]] --; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~
s573960071
p03991
C
#include <iostream> #include <cstdio> using namespace std; const int maxn = 2e5 + 50,maxm = 5.3e5,mod = 924844033,g = 5; int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; struct edge{ int v,nxt; }e[2 * maxn]; int read(){ int x = 0; char c = getchar(); while(c < '0' || c > '9') c = getchar(); while(c >= '0' && c <= '9') x = x * 10 + (c ^ 48),c = getchar(); return x; } inline int add(int x,int y){ if(x + y < mod) return x + y; else return x + y - mod; } inline int dec(int x,int y){ if(x - y >= 0) return x - y; else return x - y + mod; } int qpow(int x,int k){ int d = 1,t = x; while(k){ if(k & 1) d = 1ll * d * t % mod; t = 1ll * t * t % mod,k >>= 1; } return d; } void NTT_init(int n){ N = 1; int cnt = 0; while(N <= n) N <<= 1,cnt ++; for(int i = 0; i < N; i ++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (cnt - 1)); } void NTT(int *F,int n,int p){ for(int i = 0; i < n; i ++) if(i < rev[i]) swap(F[i],F[rev[i]]); int cnt = 1; for(int i = 1; i < n; i <<= 1){ int w1 = (p == 1 ? W[cnt] : inv_W[cnt]); for(int j = 0; j < n; j += i << 1){ int w = 1; for(int k = j; k < j + i; k ++){ int t1 = F[k],t2 = 1ll * w * F[k + i] % mod; F[k] = add(t1,t2),F[k + i] = dec(t1,t2); w = 1ll * w * w1 % mod; } } cnt ++; } if(p == -1) for(int i = 0; i < n; i ++) F[i] = 1ll * F[i] * inv[cnt - 1] % mod; } void Mul(int *F,int *G,int n){ NTT_init(n << 1); NTT(F,N,1),NTT(G,N,1); for(int i = 0; i < N; i ++) F[i] = 1ll * F[i] * G[i] % mod; NTT(F,N,-1); } void init(int n){ NTT_init(n << 1); int t = qpow(2,mod - 2); inv[0] = 1; for(int i = 1; (1 << i) <= N; i ++) inv[i] = 1ll * inv[i - 1] * t % mod; for(int i = 1; (1 << i) <= N; i ++) W[i] = qpow(g,(mod - 1) / (1 << i)),inv_W[i] = qpow(W[i],mod - 2); } inline void insert(int x,int y){ cnt ++,e[cnt].v = y,e[cnt].nxt = last[x],last[x] = cnt; } void dfs(int u,int fa){ size[u] = 1; for(int i = last[u]; i; i = e[i].nxt){ int v = e[i].v; if(v == fa) continue; dfs(v,u); size[u] += size[v]; } if(u != fa) d[size[u]] --,d[n - size[u]] --; } int main(){ n = read(); for(int i = 1; i < n; i ++){ x = read(),y = read(); insert(x,y),insert(y,x); } dfs(1,1); d[n] = n; init(n); int p = 1; for(int i = 0; i <= n; i ++) p = 1ll * p * (i ? i : 1) % mod,F[n - i] = 1ll * p * dec(d[i],0) % mod; int t = qpow(p,mod - 2); for(int i = n; i >= 0; i --) G[i] = ifac[i] = t,t = 1ll * t * i % mod; // for(int i = 0; i <= n; i ++) cout << F[i] << ' ' << G[i] << endl; Mul(F,G,n); for(int i = 1; i <= n; i ++) printf("%d\n",1ll * ifac[i] * F[n - i] % mod); return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s412699305
p03991
C++
#include <iostream> #include <cstdio> using namespace std; const int maxn = 2e5 + 50,maxm = 5.3e5,mod = 924844033,g = 5; int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; struct edge{ int v,nxt; }e[2 * maxn]; int read(){ int x = 0; char c = getchar(); while(c < '0' || c > '9') c = getchar(); while(c >= '0' && c <= '9') x = x * 10 + (c ^ 48),c = getchar(); return x; } inline int add(int x,int y){ if(x + y < mod) return x + y; else return x + y - mod; } inline int dec(int x,int y){ if(x - y >= 0) return x - y; else return x - y + mod; } int qpow(int x,int k){ int d = 1,t = x; while(k){ if(k & 1) d = 1ll * d * t % mod; t = 1ll * t * t % mod,k >>= 1; } return d; } void NTT_init(int n){ N = 1; int cnt = 0; while(N <= n) N <<= 1,cnt ++; for(int i = 0; i < N; i ++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (cnt - 1)); } void NTT(int *F,int n,int p){ for(int i = 0; i < n; i ++) if(i < rev[i]) swap(F[i],F[rev[i]]); int cnt = 1; for(int i = 1; i < n; i <<= 1){ int w1 = (p == 1 ? W[cnt] : inv_W[cnt]); for(int j = 0; j < n; j += i << 1){ int w = 1; for(int k = j; k < j + i; k ++){ int t1 = F[k],t2 = 1ll * w * F[k + i] % mod; F[k] = add(t1,t2),F[k + i] = dec(t1,t2); w = 1ll * w * w1 % mod; } } cnt ++; } if(p == -1) for(int i = 0; i < n; i ++) F[i] = 1ll * F[i] * inv[cnt - 1] % mod; } void Mul(int *F,int *G,int n){ NTT_init(n << 1); NTT(F,N,1),NTT(G,N,1); for(int i = 0; i < N; i ++) F[i] = 1ll * F[i] * G[i] % mod; NTT(F,N,-1); } void init(int n){ NTT_init(n << 1); int t = qpow(2,mod - 2); inv[0] = 1; for(int i = 1; (1 << i) <= N; i ++) inv[i] = 1ll * inv[i - 1] * t % mod; for(int i = 1; (1 << i) <= N; i ++) W[i] = qpow(g,(mod - 1) / (1 << i)),inv_W[i] = qpow(W[i],mod - 2); } inline void insert(int x,int y){ cnt ++,e[cnt].v = y,e[cnt].nxt = last[x],last[x] = cnt; } void dfs(int u,int fa){ size[u] = 1; for(int i = last[u]; i; i = e[i].nxt){ int v = e[i].v; if(v == fa) continue; dfs(v,u); size[u] += size[v]; } if(u != fa) d[size[u]] --,d[n - size[u]] --; } int main(){ n = read(); for(int i = 1; i < n; i ++){ x = read(),y = read(); insert(x,y),insert(y,x); } dfs(1,1); d[n] = n; init(n); int p = 1; for(int i = 0; i <= n; i ++) p = 1ll * p * (i ? i : 1) % mod,F[n - i] = 1ll * p * dec(d[i],0) % mod; int t = qpow(p,mod - 2); for(int i = n; i >= 0; i --) G[i] = ifac[i] = t,t = 1ll * t * i % mod; // for(int i = 0; i <= n; i ++) cout << F[i] << ' ' << G[i] << endl; Mul(F,G,n); for(int i = 1; i <= n; i ++) printf("%d\n",1ll * ifac[i] * F[n - i] % mod); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:72:9: error: reference to 'size' is ambiguous 72 | size[u] = 1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:77:17: error: reference to 'size' is ambiguous 77 | size[u] += size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:77:28: error: reference to 'size' is ambiguous 77 | size[u] += size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:79:23: error: reference to 'size' is ambiguous 79 | if(u != fa) d[size[u]] --,d[n - size[u]] --; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~ a.cc:79:41: error: reference to 'size' is ambiguous 79 | if(u != fa) d[size[u]] --,d[n - size[u]] --; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:5:36: note: 'int size [200050]' 5 | int n,x,y,cnt,N,last[maxn],d[maxn],size[maxn],ifac[maxn],inv[20],W[20],inv_W[20],rev[maxm],F[maxm],G[maxm]; | ^~~~
s428244857
p03991
C++
#include <cstdio> #include <iostream> #include <vector> using namespace std; const int g = 5, mod = 924844033, N = 3e5 + 10; int F[N], G[N], cnt[N], fac[N], inv[N], pos[N], sz[N], n; vector<int> gr[N]; void dfs(int u, int fa) { sz[u] = 1; for(auto v : gr[u]) { if(v == fa) continue; dfs(v, u); sz[u] += sz[v]; ++cnt[sz[v]]; } ++cnt[n - sz[u]]; } int qpow(int a, int b) { int c = 1; while(b) { if(b & 1) c = 1ll * c * a % mod; a = 1ll * a * a % mod; b >>= 1; } return c; } void NTT(int * a, int len, int op) { for(int i = 0; i < len; ++i) if(i < pos[i]) swap(a[i], a[pos[i]]); for(int i = 1; i < len; i <<= 1) { int s = i << 1; int wn = qpow(g, (mod - 1) / s); if(op == -1) wn = qpow(wn, mod - 2); for(int j = 0; j < len; j += s) { int w = 1; for(int k = 0; k < i; ++k, w = 1ll * w * wn % mod) { int x = a[k + j]; int y = 1ll * w * a[i + j + k] % mod; a[k + j] = (x + y) % mod; a[i + k + j] = (x - y + mod) % mod; } } } if(op == -1) { int inv = qpow(len, mod - 2); for(int i = 0; i < len; ++i) a[i] = 1ll * a[i] * inv % mod; } } int main() { scanf("%d", &n); for(int i = 1, u, v; i < n; ++i) { scanf("%d %d", &u, &v); gr[u].push_back(v); gr[v].push_back(u); } dfs(1, 0); fac[0] = 1; for(int i = 1; i <= n; ++i) fac[i] = 1ll * i * fac[i - 1] % mod; inv[n] = qpow(fac[n], mod - 2); for(int i = n; i >= 1; --i) inv[i - 1] = 1ll * i * inv[i] % mod; for(int i = 1; i <= n; ++i) F[i] = 1ll * cnt[i] * fac[i] % mod; reverse(F, F + 1 + n); for(int i = 0; i <= n; ++i) G[i] = inv[i]; int len = 1, num = 0; while(len <= (n << 1)) len <<= 1, ++num; for(int i = 0; i < len; ++i) pos[i] = (pos[i >> 1] >> 1) | ((i & 1) << (num - 1)); NTT(F, len, 1); NTT(G, len, 1); for(int i = 0; i < len; ++i) F[i] = 1ll * F[i] * G[i] % mod; NTT(F, len, -1); reverse(F, F + 1 + n); for(int i = 1; i <= n; ++i) { int ans = 1ll * n * fac[n] % mod * inv[i] % mod * inv[n - i] % mod; ans = (ans - 1ll * inv[i] * F[i] % mod + mod) % mod; printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:61:5: error: 'reverse' was not declared in this scope 61 | reverse(F, F + 1 + n); | ^~~~~~~
s384080194
p03991
C
#include<bits/stdc++.h> #define ll long long #define poly vector<ll> using namespace std; const int N=5250007; const int mod=924844033; int n; int rev[N],g[N],sz[N]; vector<int> ve[N]; ll fac[N],finv[N]; poly f,h; inline ll qpow(ll x,int k,ll r=1){ for(;k;k>>=1,x=x*x%mod) if(k&1) r=r*x%mod; return r; } inline void ntt(poly &a,int len,int opt){ a.resize(len); for(int i=0;i<len;++i) if(i<rev[i]) swap(a[i],a[rev[i]]); for(int i=1;i<len;i<<=1) for(int j=0;j<len;j+=i<<1) for(int k=0;k<i;++k){ int x=a[j+k],y=a[j+k+i]*g[i+k]%mod; a[j+k]=x+y>=mod?x+y-mod:x+y; a[j+k+i]=x-y<0?x-y+mod:x-y; } if(~opt) return ; reverse(a.begin()+1,a.end()); const int inv=qpow(len,mod-2); for(int i=0;i<len;++i) a[i]=a[i]*inv%mod; } void dfs(int x,int fa){ sz[x]=1; for(auto to:ve[x]) if(to!=fa) dfs(to,x),sz[x]+=sz[to]; ++f[n]; if(fa) --f[sz[x]],--f[n-sz[x]]; } int main(){ scanf("%d",&n); int len=1,bit=0; for(;len<=n+n;len<<=1,++bit); for(int i=0;i<len;++i) rev[i]=rev[i>>1]>>1|(i&1)<<bit-1; for(int i=fac[0]=1;i<=n;++i) fac[i]=fac[i-1]*i%mod; finv[n]=qpow(fac[n],mod-2); for(int i=n;i;--i) finv[i-1]=finv[i]*i%mod; for(int i=1,a,b;i<n;++i) scanf("%d%d",&a,&b),ve[a].push_back(b),ve[b].push_back(a); for(int i=len/2,wn=qpow(5,(mod-1)/len),w=1;i<len;++i,w=1ll*w*wn%mod) g[i]=w; for(int i=len/2-1;i;--i) g[i]=g[i<<1]; f.resize(n+1); h.resize(n+1); dfs(1,0); for(int i=1;i<=n;++i) f[i]=(f[i]+mod)*fac[i]%mod; for(int i=0;i<=n;++i) h[i]=finv[n-i]; ntt(f,len,1); ntt(h,len,1); for(int i=0;i<len;++i) f[i]=f[i]*h[i]%mod; ntt(f,len,-1); for(int i=1;i<=n;++i) printf("%lld\n",f[i+n]*finv[i]%mod); return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s867690498
p03991
C++
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define poly vector<ll> #define ll long long using namespace std; const int N=540000; const int mod=943718401; int r[N],siz[N],tong[N]; ll n,m,ni[N],js[N]; ll a[N],b[N],ans; vector<int> g[N]; inline ll C(int x,int y){ return js[x]*ni[y]%mod*ni[x-y]%mod; } inline ll qpow(ll x,ll y,ll ans=1){ for(;y;y>>=1,x=x*x%mod) if(y&1) ans=ans*x%mod; return ans; } inline void NTT(ll *a,int len,int opt){ for(int i=0;i<len;++i) if(i<r[i]) swap(a[i],a[r[i]]); for(int i=1;i<len;i<<=1){ ll u=qpow(7,opt*(mod-1)/(i<<1)+mod-1); for(int j=0,w=1;j<len;j+=i<<1,w=1) for(int k=0;k<i;++k,w=w*u%mod){ ll x=a[j+k],y=a[j+k+i]*w%mod; a[j+k]=(x+y)%mod,a[j+k+i]=(x-y)%mod; } } if(~opt) return; for(int i=0,inv=qpow(len,mod-2);i<len;++i) a[i]=a[i]*inv%mod; } inline int init(int k){ int len=1,l=0; for(;len<k;len<<=1,++l); for(int i=0;i<len;++i) r[i]=(r[i>>1]>>1)|((i&1)<<l-1); return len; } void dfs(int x,int fa){ siz[x]=1; for(int i=0;i<g[x].size();++i){ int y=g[x][i]; if(y^fa) dfs(y,x),siz[x]+=siz[y],tong[siz[y]]++; } tong[n-siz[x]]++; } int main(){ cin>>n; for(int i=1,x,y;i<n;++i) cin>>x>>y,g[x].push_back(y),g[y].push_back(x); for(int i=js[0]=1;i<=n;++i) js[i]=js[i-1]*i%mod; ni[n]=qpow(js[n],mod-2); for(int i=n;i;--i) ni[i-1]=ni[i]*i%mod; dfs(1,0); for(int i=0;i<=n;++i) a[i]=tong[n-i]*js[n-i]%mod,b[i]=ni[i]; int len=init(n<<1|1); NTT(a,len,1); NTT(b,len,1); for(int i=0;i<len;++i) a[i]=a[i]*b[i]%mod; NTT(a,len,-1); ll ans=0; for(int i=1;i<=n;++i) printf("%lld\n",((n*C(n,i)%mod-a[n-i]*ni[i])%mod+mod)%mod); return 0; }
a.cc:13:1: error: 'vector' does not name a type 13 | vector<int> g[N]; | ^~~~~~ a.cc: In function 'void dfs(int, int)': a.cc:41:23: error: 'g' was not declared in this scope 41 | for(int i=0;i<g[x].size();++i){ | ^ a.cc: In function 'int main()': a.cc:49:44: error: 'g' was not declared in this scope 49 | for(int i=1,x,y;i<n;++i) cin>>x>>y,g[x].push_back(y),g[y].push_back(x); | ^
s807491094
p03991
C
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define poly vector<ll> #define ll long long using namespace std; const int N=540000; const int mod=943718401; int r[N],siz[N],tong[N]; ll n,m,ni[N],js[N]; ll a[N],b[N],ans; vector<int> g[N]; inline ll C(int x,int y){ return js[x]*ni[y]%mod*ni[x-y]%mod; } inline ll qpow(ll x,ll y,ll ans=1){ for(;y;y>>=1,x=x*x%mod) if(y&1) ans=ans*x%mod; return ans; } inline void NTT(ll *a,int len,int opt){ for(int i=0;i<len;++i) if(i<r[i]) swap(a[i],a[r[i]]); for(int i=1;i<len;i<<=1){ ll u=qpow(7,opt*(mod-1)/(i<<1)+mod-1); for(int j=0,w=1;j<len;j+=i<<1,w=1) for(int k=0;k<i;++k,w=w*u%mod){ ll x=a[j+k],y=a[j+k+i]*w%mod; a[j+k]=(x+y)%mod,a[j+k+i]=(x-y)%mod; } } if(~opt) return; for(int i=0,inv=qpow(len,mod-2);i<len;++i) a[i]=a[i]*inv%mod; } inline int init(int k){ int len=1,l=0; for(;len<k;len<<=1,++l); for(int i=0;i<len;++i) r[i]=(r[i>>1]>>1)|((i&1)<<l-1); return len; } void dfs(int x,int fa){ siz[x]=1; for(int i=0;i<g[x].size();++i){ int y=g[x][i]; if(y^fa) dfs(y,x),siz[x]+=siz[y],tong[siz[y]]++; } tong[n-siz[x]]++; } int main(){ cin>>n; for(int i=1,x,y;i<n;++i) cin>>x>>y,g[x].push_back(y),g[y].push_back(x); for(int i=js[0]=1;i<=n;++i) js[i]=js[i-1]*i%mod; ni[n]=qpow(js[n],mod-2); for(int i=n;i;--i) ni[i-1]=ni[i]*i%mod; dfs(1,0); for(int i=0;i<=n;++i) a[i]=tong[n-i]*js[n-i]%mod,b[i]=ni[i]; int len=init(n<<1|1); NTT(a,len,1); NTT(b,len,1); for(int i=0;i<len;++i) a[i]=a[i]*b[i]%mod; NTT(a,len,-1); ll ans=0; for(int i=1;i<=n;++i) printf("%lld\n",((n*C(n,i)%mod-a[n-i]*ni[i])%mod+mod)%mod); return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s193919019
p03991
C
#include<bits/stdc++.h> #define poly vector<ll> #define ll long long using namespace std; const int N=540000; const int mod=943718401; int r[N],siz[N],tong[N]; ll n,m,ni[N],js[N]; ll a[N],b[N],ans; vector<int> g[N]; inline ll C(int x,int y){ return js[x]*ni[y]%mod*ni[x-y]%mod; } inline ll qpow(ll x,ll y,ll ans=1){ for(;y;y>>=1,x=x*x%mod) if(y&1) ans=ans*x%mod; return ans; } inline void NTT(ll *a,int len,int opt){ for(int i=0;i<len;++i) if(i<r[i]) swap(a[i],a[r[i]]); for(int i=1;i<len;i<<=1){ ll u=qpow(7,opt*(mod-1)/(i<<1)+mod-1); for(int j=0,w=1;j<len;j+=i<<1,w=1) for(int k=0;k<i;++k,w=w*u%mod){ ll x=a[j+k],y=a[j+k+i]*w%mod; a[j+k]=(x+y)%mod,a[j+k+i]=(x-y)%mod; } } if(~opt) return; for(int i=0,inv=qpow(len,mod-2);i<len;++i) a[i]=a[i]*inv%mod; } inline int init(int k){ int len=1,l=0; for(;len<k;len<<=1,++l); for(int i=0;i<len;++i) r[i]=(r[i>>1]>>1)|((i&1)<<l-1); return len; } void dfs(int x,int fa){ siz[x]=1; for(int y:g[x]) if(y^fa) dfs(y,x),siz[x]+=siz[y],tong[siz[y]]++; tong[n-siz[x]]++; } int main(){ cin>>n; for(int i=1,x,y;i<n;++i) cin>>x>>y,g[x].push_back(y),g[y].push_back(x); for(int i=js[0]=1;i<=n;++i) js[i]=js[i-1]*i%mod; ni[n]=qpow(js[n],mod-2); for(int i=n;i;--i) ni[i-1]=ni[i]*i%mod; dfs(1,0); for(int i=0;i<=n;++i) a[i]=tong[n-i]*js[n-i]%mod,b[i]=ni[i]; int len=init(n<<1|1); NTT(a,len,1); NTT(b,len,1); for(int i=0;i<len;++i) a[i]=a[i]*b[i]%mod; NTT(a,len,-1); ll ans=0; for(int i=1;i<=n;++i) printf("%lld\n",((n*C(n,i)%mod-a[n-i]*ni[i])%mod+mod)%mod); return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s902937128
p03991
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long LL; const int N = 200000 + 10; const int MOD = 924844033; const int root = 44009197; // root ^ (2^21) % MOD = 1 const int root_1 = 921713838; // root * root_1 = 1 const int root_pw = 1 << 21; // 998244353 = 119 * 2^23 + 1 LL mpow(LL a,LL x){ if(x==0)return 1; LL t=mpow(a,x>>1); if(x%2==0)return t*t%MOD; return t*t%MOD*a%MOD; } LL modinv(LL a){ LL x0=0,x1=1,r0=MOD,r1=a; while(r1){ LL q=r0/r1; x0-=q*x1;swap(x0,x1); r0-=q*r1;swap(r0,r1); } return x0<0?x0+MOD:x0; } void fft(vector<int> &a, bool inv) { // a.size()不为2的幂会原地爆炸。 int n=(int)a.size(); // 迷 の butterfly操作 for(int i=1,j=0;i<n;i++) { int bit=n>>1; for(;j>=bit;bit>>=1) j-=bit; j+=bit; if(i<j)swap(a[i],a[j]); } // 施展 DFT for(int len=2;len<=n;len<<=1) { int wlen=inv?root_1:root; for(int i=len;i<root_pw;i<<=1) wlen=wlen*1LL*wlen%MOD; for(int i=0;i<n;i+=len) { int w=1; for(int j=0;j<len/2;j++) { int u=a[i+j],v=int(a[i+j+len/2]*1LL*w%MOD); a[i+j] = (u+v<MOD)?u+v:u+v-MOD; a[i+j+len/2] = (u-v>=0)?u-v:u-v+MOD; w = w*1LL*wlen%MOD; } } } if(inv) { int nrev = modinv(n); for(int i=0;i<n;i++) a[i]=a[i]*1LL*nrev%MOD; } } void pro(const vector<int> &a, const vector<int> &b, vector<int> &res) { vector<int> fa(a.begin(), a.end()),fb(b.begin(), b.end()); int n=1; while (n<(int) max(a.size(), b.size())) n<<=1; n<<=1; fa.resize(n),fb.resize(n); fft(fa,false), fft(fb,false); for(int i=0;i<n;i++) fa[i] = 1LL*fa[i]*fb[i]%MOD; fft(fa,true); res = fa; } LL inv[N],fac[N]; void init() { inv[1]=1; for(int i=2;i<N;i++){ inv[i]=1LL * (MOD-(MOD/i)) * inv[MOD%i] % MOD; } inv[0]=fac[0]=1; for(int i=1;i<N;i++){ inv[i]=inv[i-1]*inv[i]%MOD; fac[i]=fac[i-1]*i%MOD; } } vector<int> g[N]; int n,sz[N]; void dfs(int u,int p) { sz[u]=1; for(auto v: g[u]) { if(v==p) continue; dfs(v,u); sz[u]+=sz[v]; } } int c[N]; int comb(int x,int y){ return 1LL * fac[x] * inv[y] % MOD * inv[x-y] % MOD; } int ans[N]; void getAns(vector<int> vec) { memset(c,0,sizeof(c)); for(auto x: vec) c[x]++; vector<int> res; vector<int> p1, p2, p; p1.push_back(0); for(int i=1;i<n;i++){ p1.push_back(1LL * c[i] * fac[i] % MOD); } for(int i=0;i<=n;i++){ p2.push_back(inv[i]); } /* printf("pro\n"); for(auto x: p1) printf("%d ", x); printf("\n"); for(auto x: p2) printf("%d ", x); printf("\n"); */ reverse(p2.begin(), p2.end()); pro(p1,p2,p); for(int i=p2.size();i<p.size();i++){ p[i] = p[i] * inv[i - (int)p2.size() + 1] % MOD; //printf("# %d, %d\n", i-(int)p2.size(), p[i]); ans[i - (int)p2.size()] -= p[i]; ans[i - (int)p2.size()] = ((ans[i - (int)p2.size()] % MOD) + MOD) % MOD; } } int main() { init(); scanf("%d",&n); for(int i=1;i<n;i++) { int u,v; scanf("%d%d",&u,&v); g[u].push_back(v); g[v].push_back(u); } dfs(1,1); for(int i=0;i<n;i++) { ans[i] = 1LL * comb(n,i+1) * n % MOD; } vector<int> v; for(int i=1;i<=n;i++) v.push_back(sz[i]); getAns(v); v.clear(); for(int i=1;i<=n;i++) v.push_back(n-sz[i]); getAns(v); for(int i=0;i<n;i++) printf("%d\n", ans[i]); }
a.cc: In function 'void getAns(std::vector<int>)': a.cc:91:5: error: 'memset' was not declared in this scope 91 | memset(c,0,sizeof(c)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <algorithm> +++ |+#include <cstring> 4 | using namespace std;
s688510172
p03991
C++
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> static constexpr int MOD = 924844033; using ll = long long; using u32 = uint32_t; using namespace std; #pragma GCC optimize ("O1") template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; template <class T> T pow_ (T x, T n, T M){ uint64_t u = 1, xx = x; while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; } return static_cast<T>(u); }; template <class T> class Factorial { T mod; vector<uint64_t> facts, factinv; public: Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { facts[0] = 1; for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; } T fact(int k) const { if(k >= 0) return static_cast<T>(facts[k]); else return static_cast<T>(factinv[-k]); } T operator[](const int &k) const { if(k >= 0) return static_cast<T>(facts[k]); else return static_cast<T>(factinv[-k]); } T C(int p, int q) const { if(q < 0 || p < q) return 0; return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); } T P(int p, int q) const { if(q < 0 || p < q) return 0; return static_cast<T>((facts[p] * factinv[p-q]) % mod); } T H(int p, int q) const { if(p < 0 || q < 0) return 0; return static_cast<T>(q == 0 ? 1 : C(p+q-1, q)); } }; #include <cmath> namespace FFT { const int max_base = 19, maxN = 1 << max_base; // N <= 2e5 const double PI = acos(-1); struct num { double x{}, y{}; num() = default; num(double x, double y): x(x), y(y) {} explicit num(double r): x(cos(r)), y(sin(r)) {} }; using ar = array<num, 1<<19>; using arr = array<ll, 1<<19>; num operator+(num a, num b) { return {a.x + b.x, a.y + b.y}; } num operator-(num a, num b) { return {a.x - b.x, a.y - b.y}; } num operator*(num a, num b) { return {a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x}; } num conj(num a) {return {a.x, -a.y}; } ar root; arr rev; bool is_root_prepared = false; void prepare_root(){ if(is_root_prepared) return; is_root_prepared = true; root[1] = num(1, 0); for (int i = 1; i < max_base; ++i) { num x(2*PI / (1LL << (i+1))); for (ll j = (1LL << (i-1)); j < (1LL << (i)); ++j) { root[2*j] = root[j]; root[2*j+1] = root[j]*x; } } } int base, N; int lastN = -1; void prepare_rev(){ if(lastN == N) return; lastN = N; for (int i = 0; i < N; ++i) rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (base - 1)); } void fft(ar &a, ar &f){ for (int i = 0; i < N; ++i) f[i] = a[rev[i]]; for (int k = 1; k < N; k <<= 1) { for (int i = 0; i < N; i += 2*k) { for (int j = 0; j < k; ++j) { num z = f[i+j+k]* root[j+k]; f[i+j+k] = f[i+j] - z; f[i+j] = f[i+j] + z; } } } } ar a, b, f, g; arr A, B, C; void multi_mod(int m){ for (int i = 0; i < N; ++i) { ll x = A[i] % m; a[i] = num(x & ((1LL << 15)-1), x >> 15); } for (int i = 0; i < N; ++i) { ll x = B[i] % m; b[i] = num(x & ((1LL << 15)-1), x >> 15); } fft(a, f); fft(b, g); for (int i = 0; i < N; ++i) { int j = (N-i) &(N-1); num a1 = (f[i] + conj(f[j])) * num(0.5, 0); num a2 = (f[i] - conj(f[j])) * num(0, -0.5); num b1 = (g[i] + conj(g[j])) * num(0.5/N, 0); num b2 = (g[i] - conj(g[j])) * num(0, -0.5/N); a[j] = a1*b1 + a2*b2 * num(0, 1); b[j] = a1*b2 + a2*b1; } fft(a, f); fft(b, g); for (int i = 0; i < N; ++i) { ll aa = f[i].x + 0.5; ll bb = g[i].x + 0.5; ll cc = f[i].y + 0.5; C[i] = (aa + bb % m * (1LL << 15) + cc% m *(1LL << 30)) % m; } } void prepare_AB(int n1, int n2){ base = 1; N = 2; while(N < n1+n2) base++, N <<= 1; for (int i = n1; i < N; ++i) A[i] = 0; for (int i = n2; i < N; ++i) B[i] = 0; prepare_root(); prepare_rev(); } void multi_mod(int n1, int n2, int m){ prepare_AB(n1, n2); multi_mod(m); } } struct poly { vector<int> v; poly() = default; explicit poly(vector<int> vv) : v(std::move(vv)) {}; int size() {return (int)v.size(); } poly cut(int len){ if(len < v.size()) v.resize(static_cast<unsigned long>(len)); return *this; } inline int& operator[] (int i) {return v[i]; } }; poly operator+(poly &A, poly &B){ poly C; C.v = vector<int>(max(A.size(), B.size())); for (int i = 0; i < A.size(); ++i) C[i] = A[i]; for (int i = 0; i < B.size(); ++i) (C[i] += B[i]) %= MOD; return C; } poly operator-(poly &A, poly &B){ poly C; C.v = vector<int>(max(A.size(), B.size())); for (int i = 0; i < A.size(); ++i) C[i] = A[i]; for (int i = 0; i < B.size(); ++i) (C[i] += MOD-B[i]) %= MOD; return C; } poly operator* (poly &A, poly &B){ poly C; C.v = vector<int>(A.size() + B.size()-1); for (int i = 0; i < A.size(); ++i) FFT::A[i] = A[i]; for (int i = 0; i < B.size(); ++i) FFT::B[i] = B[i]; FFT::multi_mod(A.size(), B.size(), MOD); for (int i = 0; i < C.size(); ++i) C[i] = FFT::C[i]; return C; } int main() { int n; cin >> n; vector<vector<int>> G(n); for (int i = 0; i < n-1; ++i) { int a, b; scanf("%d %d", &a, &b); G[a-1].emplace_back(b-1); G[b-1].emplace_back(a-1); } deque<int> Q; vector<int> num(n); { stack<int> s; int cnt = 0; vector<int> visited(n, 0); s.emplace(0); while(!s.empty()){ int a = s.top(); s.pop(); visited[a]++; num[a] = cnt++; Q.emplace_front(a); for (auto &&i : G[a]) { if(!visited[i]) s.emplace(i); } } } vector<int> v(n, 1); vector<int> u(n+1); while(!Q.empty()){ int i = Q.front(); Q.pop_front(); for (auto &&j : G[i]) { if(num[i] < num[j]) v[i] += v[j]; } } for (int i = 0; i < n; ++i) { for (auto &&j : G[i]) { if(i < j){ int p = min(v[i], v[j]); u[p]++; u[n-p]++; } } } Factorial<ll> fact(n, MOD); for (int i = 0; i <= n; ++i) { u[i] = static_cast<int>((fact[i] * u[i]) % MOD); } vector<int> uu(n+1); for (int i = 0; i <= n; ++i) { uu[i] = static_cast<int>(fact[i-n]); } poly f(u), g(uu); poly h = f*g; for (int k = 1; k <= n; ++k) { ll ans = (fact.C(n, k)*n%MOD + (MOD - fact[-k]*h[n+k]%MOD)) % MOD; printf("%lld\n", ans); } return 0; }
a.cc:13:13: error: 'uint32_t' does not name a type 13 | using u32 = uint32_t; | ^~~~~~~~ a.cc:10:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 9 | #include <bitset> +++ |+#include <cstdint> 10 | a.cc:16:39: error: '::numeric_limits' has not been declared 16 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ^~~~~~~~~~~~~~ a.cc:16:55: error: expected primary-expression before '>' token 16 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ^ a.cc:16:61: error: no matching function for call to 'max()' 16 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ~~~~~^~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In function 'T pow_(T, T, T)': a.cc:20:5: error: 'uint64_t' was not declared in this scope 20 | uint64_t u = 1, xx = x; | ^~~~~~~~ a.cc:20:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:22:18: error: 'u' was not declared in this scope 22 | if (n&1) u = u * xx % M; | ^ a.cc:22:26: error: 'xx' was not declared in this scope; did you mean 'x'? 22 | if (n&1) u = u * xx % M; | ^~ | x a.cc:23:9: error: 'xx' was not declared in this scope; did you mean 'x'? 23 | xx = xx * xx % M; | ^~ | x a.cc:26:27: error: 'u' was not declared in this scope 26 | return static_cast<T>(u); | ^ a.cc: At global scope: a.cc:31:12: error: 'uint64_t' was not declared in this scope 31 | vector<uint64_t> facts, factinv; | ^~~~~~~~ a.cc:31:12: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:31:20: error: template argument 1 is invalid 31 | vector<uint64_t> facts, factinv; | ^ a.cc:31:20: error: template argument 2 is invalid a.cc: In constructor 'Factorial<T>::Factorial(int, T)': a.cc:34:49: error: 'u32' does not name a type 34 | Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { | ^~~ a.cc:34:81: error: 'u32' does not name a type 34 | Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { | ^~~ a.cc:35:14: error: invalid types 'int[int]' for array subscript 35 | facts[0] = 1; | ^ a.cc:36:44: error: invalid types 'int[int]' for array subscript 36 | for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; | ^ a.cc:36:55: error: invalid types 'int[int]' for array subscript 36 | for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; | ^ a.cc:37:16: error: invalid types 'int[int]' for array subscript 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^ a.cc:37:32: error: invalid types 'int[int]' for array subscript 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^ a.cc:37:49: error: 'uint64_t' does not name a type 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^~~~~~~~ a.cc:37:49: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:37:81: error: 'uint64_t' does not name a type 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^~~~~~~~ a.cc:37:81: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:38:47: error: invalid types 'int[int]' for array subscript 38 | for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; | ^ a.cc:38:60: error: invalid types 'int[int]' for array subscript 38 | for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; | ^ a.cc: In member function 'T Factorial<T>::fact(int) const': a.cc:42:47: error: invalid types 'const int[int]' for array subscript 42 | if(k >= 0) return static_cast<T>(facts[k]); | ^ a.cc:43:43: error: invalid types 'const int[int]' for array subscript 43 | else return static_cast<T>(factinv[-k]); | ^ a.cc: In member function 'T Factorial<T>::operator[](const int&) const': a.cc:47:47: error: invalid types 'const int[const int]' for array subscript 47 | if(k >= 0) return static_cast<T>(facts[k]); | ^ a.cc:48:43: error: invalid types 'const int[int]' for array subscript 48 | else return static_cast<T>(factinv[-k]); | ^ a.cc: In member function 'T Factorial<T>::C(int, int) const': a.cc:53:36: error: invalid types 'const int[int]' for array subscript 53 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc:53:49: error: invalid types 'const int[int]' for array subscript 53 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc:53:68: error: invalid types 'const int[int]' for array subscript 53 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc: In member function 'T Factorial<T>::P(int, int) const': a.cc:58:37: error: invalid types 'const int[int]' for array subscript 58 | return static_cast<T>((facts[p] * factinv[p-q]) % mod); | ^ a.cc:58:50: error: invalid types 'const int[int]' for array subscript 58 | return static_cast<T>((facts[p] * factinv[p-q]) % mod); | ^ a.cc: At global scope: a.cc:84:8: error: aggregate 'FFT::ar FFT::root' has incomplete type and cannot be defined 84 | ar root; | ^~~~ a.cc:85:9: error: aggregate 'FFT::arr FFT::rev' has incomplete type and cannot be defined 85 | arr rev; | ^~~ a.cc: In function 'void FFT::fft(ar&, ar&)': a.cc:111:38: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 111 | for (int i = 0; i < N; ++i) f[i] = a[rev[i]]; | ^ a.cc:115:30: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 115 | num z = f[i+j+k]* root[j+k]; | ^ a.cc:116:22: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 116 | f[i+j+k] = f[i+j] - z; | ^ a.cc:116:33: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 116 | f[i+j+k] = f[i+j] - z; | ^ a.cc:117:22: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 117 | f[i+j] = f[i+j] + z; | ^ a.cc:117:31: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 117 | f[i+j] = f[i+j] + z; | ^ a.cc: At global scope: a.cc:122:8: error: aggregate 'FFT::ar FFT::a' has in
s912085562
p03991
C++
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> static const int MOD = 924844033; using ll = long long; using u32 = uint32_t; using namespace std; #pragma GCC optimize ("O2") template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; template <class T> T pow_ (T x, T n, T M){ uint64_t u = 1, xx = x; while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; } return static_cast<T>(u); }; template <class T> class Factorial { T mod; vector<uint64_t> facts, factinv; public: Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { facts[0] = 1; for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; } T fact(int k) const { if(k >= 0) return static_cast<T>(facts[k]); else return static_cast<T>(factinv[-k]); } T operator[](const int &k) const { if(k >= 0) return static_cast<T>(facts[k]); else return static_cast<T>(factinv[-k]); } T C(int p, int q) const { if(q < 0 || p < q) return 0; return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); } T P(int p, int q) const { if(q < 0 || p < q) return 0; return static_cast<T>((facts[p] * factinv[p-q]) % mod); } T H(int p, int q) const { if(p < 0 || q < 0) return 0; return static_cast<T>(q == 0 ? 1 : C(p+q-1, q)); } }; #include <cmath> namespace FFT { const int max_base = 19, maxN = 1 << max_base; // N <= 2e5 const double PI = acos(-1); struct num { double x{}, y{}; num() = default; num(double x, double y): x(x), y(y) {} explicit num(double r): x(cos(r)), y(sin(r)) {} }; using ar = array<num, maxN>; using arr = array<ll, maxN>; num operator+(num a, num b) { return {a.x + b.x, a.y + b.y}; } num operator-(num a, num b) { return {a.x - b.x, a.y - b.y}; } num operator*(num a, num b) { return {a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x}; } num conj(num a) {return {a.x, -a.y}; } ar root; arr rev; bool is_root_prepared = false; void prepare_root(){ if(is_root_prepared) return; is_root_prepared = true; root[1] = num(1, 0); for (int i = 1; i < max_base; ++i) { num x(2*PI / (1LL << (i+1))); for (ll j = (1LL << (i-1)); j < (1LL << (i)); ++j) { root[2*j] = root[j]; root[2*j+1] = root[j]*x; } } } int base, N; int lastN = -1; void prepare_rev(){ if(lastN == N) return; lastN = N; for (int i = 0; i < N; ++i) rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (base - 1)); } void fft(ar &a, ar &f){ for (int i = 0; i < N; ++i) f[i] = a[rev[i]]; for (int k = 1; k < N; k <<= 1) { for (int i = 0; i < N; i += 2*k) { for (int j = 0; j < k; ++j) { num z = f[i+j+k]* root[j+k]; f[i+j+k] = f[i+j] - z; f[i+j] = f[i+j] + z; } } } } ar a, b, f, g; arr A, B, C; void multi_mod(int m){ for (int i = 0; i < N; ++i) { ll x = A[i] % m; a[i] = num(x & ((1LL << 15)-1), x >> 15); } for (int i = 0; i < N; ++i) { ll x = B[i] % m; b[i] = num(x & ((1LL << 15)-1), x >> 15); } fft(a, f); fft(b, g); for (int i = 0; i < N; ++i) { int j = (N-i) &(N-1); num a1 = (f[i] + conj(f[j])) * num(0.5, 0); num a2 = (f[i] - conj(f[j])) * num(0, -0.5); num b1 = (g[i] + conj(g[j])) * num(0.5/N, 0); num b2 = (g[i] - conj(g[j])) * num(0, -0.5/N); a[j] = a1*b1 + a2*b2 * num(0, 1); b[j] = a1*b2 + a2*b1; } fft(a, f); fft(b, g); for (int i = 0; i < N; ++i) { ll aa = f[i].x + 0.5; ll bb = g[i].x + 0.5; ll cc = f[i].y + 0.5; C[i] = (aa + bb % m * (1LL << 15) + cc% m *(1LL << 30)) % m; } } void prepare_AB(int n1, int n2){ base = 1; N = 2; while(N < n1+n2) base++, N <<= 1; for (int i = n1; i < N; ++i) A[i] = 0; for (int i = n2; i < N; ++i) B[i] = 0; prepare_root(); prepare_rev(); } void multi_mod(int n1, int n2, int m){ prepare_AB(n1, n2); multi_mod(m); } } struct poly { vector<int> v; poly() = default; explicit poly(vector<int> vv) : v(std::move(vv)) {}; int size() {return (int)v.size(); } poly cut(int len){ if(len < v.size()) v.resize(static_cast<unsigned long>(len)); return *this; } inline int& operator[] (int i) {return v[i]; } }; poly operator+(poly &A, poly &B){ poly C; C.v = vector<int>(max(A.size(), B.size())); for (int i = 0; i < A.size(); ++i) C[i] = A[i]; for (int i = 0; i < B.size(); ++i) (C[i] += B[i]) %= MOD; return C; } poly operator-(poly &A, poly &B){ poly C; C.v = vector<int>(max(A.size(), B.size())); for (int i = 0; i < A.size(); ++i) C[i] = A[i]; for (int i = 0; i < B.size(); ++i) (C[i] += MOD-B[i]) %= MOD; return C; } poly operator* (poly &A, poly &B){ poly C; C.v = vector<int>(A.size() + B.size()-1); for (int i = 0; i < A.size(); ++i) FFT::A[i] = A[i]; for (int i = 0; i < B.size(); ++i) FFT::B[i] = B[i]; FFT::multi_mod(A.size(), B.size(), MOD); for (int i = 0; i < C.size(); ++i) C[i] = FFT::C[i]; return C; } int main() { int n; cin >> n; vector<vector<int>> G(n); for (int i = 0; i < n-1; ++i) { int a, b; scanf("%d %d", &a, &b); G[a-1].emplace_back(b-1); G[b-1].emplace_back(a-1); } deque<int> Q; vector<int> num(n); { stack<int> s; int cnt = 0; vector<int> visited(n, 0); s.emplace(0); while(!s.empty()){ int a = s.top(); s.pop(); visited[a]++; num[a] = cnt++; Q.emplace_front(a); for (auto &&i : G[a]) { if(!visited[i]) s.emplace(i); } } } vector<int> v(n, 1); vector<int> u(n+1); while(!Q.empty()){ int i = Q.front(); Q.pop_front(); for (auto &&j : G[i]) { if(num[i] < num[j]) v[i] += v[j]; } } for (int i = 0; i < n; ++i) { for (auto &&j : G[i]) { if(i < j){ int p = min(v[i], v[j]); u[p]++; u[n-p]++; } } } Factorial<ll> fact(n, MOD); for (int i = 0; i <= n; ++i) { u[i] = static_cast<int>((fact[i] * u[i]) % MOD); } vector<int> uu(n+1); for (int i = 0; i <= n; ++i) { uu[i] = static_cast<int>(fact[i-n]); } poly f(u), g(uu); poly h = f*g; for (int k = 1; k <= n; ++k) { ll ans = (fact.C(n, k)*n%MOD + (MOD - fact[-k]*h[n+k]%MOD)) % MOD; printf("%lld\n", ans); } return 0; }
a.cc:13:13: error: 'uint32_t' does not name a type 13 | using u32 = uint32_t; | ^~~~~~~~ a.cc:10:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 9 | #include <bitset> +++ |+#include <cstdint> 10 | a.cc:17:39: error: '::numeric_limits' has not been declared 17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ^~~~~~~~~~~~~~ a.cc:17:55: error: expected primary-expression before '>' token 17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ^ a.cc:17:61: error: no matching function for call to 'max()' 17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ~~~~~^~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In function 'T pow_(T, T, T)': a.cc:21:5: error: 'uint64_t' was not declared in this scope 21 | uint64_t u = 1, xx = x; | ^~~~~~~~ a.cc:21:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:23:18: error: 'u' was not declared in this scope 23 | if (n&1) u = u * xx % M; | ^ a.cc:23:26: error: 'xx' was not declared in this scope; did you mean 'x'? 23 | if (n&1) u = u * xx % M; | ^~ | x a.cc:24:9: error: 'xx' was not declared in this scope; did you mean 'x'? 24 | xx = xx * xx % M; | ^~ | x a.cc:27:27: error: 'u' was not declared in this scope 27 | return static_cast<T>(u); | ^ a.cc: At global scope: a.cc:32:12: error: 'uint64_t' was not declared in this scope 32 | vector<uint64_t> facts, factinv; | ^~~~~~~~ a.cc:32:12: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:32:20: error: template argument 1 is invalid 32 | vector<uint64_t> facts, factinv; | ^ a.cc:32:20: error: template argument 2 is invalid a.cc: In constructor 'Factorial<T>::Factorial(int, T)': a.cc:35:49: error: 'u32' does not name a type 35 | Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { | ^~~ a.cc:35:81: error: 'u32' does not name a type 35 | Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { | ^~~ a.cc:36:14: error: invalid types 'int[int]' for array subscript 36 | facts[0] = 1; | ^ a.cc:37:44: error: invalid types 'int[int]' for array subscript 37 | for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; | ^ a.cc:37:55: error: invalid types 'int[int]' for array subscript 37 | for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; | ^ a.cc:38:16: error: invalid types 'int[int]' for array subscript 38 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^ a.cc:38:32: error: invalid types 'int[int]' for array subscript 38 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^ a.cc:38:49: error: 'uint64_t' does not name a type 38 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^~~~~~~~ a.cc:38:49: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:38:81: error: 'uint64_t' does not name a type 38 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^~~~~~~~ a.cc:38:81: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:39:47: error: invalid types 'int[int]' for array subscript 39 | for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; | ^ a.cc:39:60: error: invalid types 'int[int]' for array subscript 39 | for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; | ^ a.cc: In member function 'T Factorial<T>::fact(int) const': a.cc:43:47: error: invalid types 'const int[int]' for array subscript 43 | if(k >= 0) return static_cast<T>(facts[k]); | ^ a.cc:44:43: error: invalid types 'const int[int]' for array subscript 44 | else return static_cast<T>(factinv[-k]); | ^ a.cc: In member function 'T Factorial<T>::operator[](const int&) const': a.cc:48:47: error: invalid types 'const int[const int]' for array subscript 48 | if(k >= 0) return static_cast<T>(facts[k]); | ^ a.cc:49:43: error: invalid types 'const int[int]' for array subscript 49 | else return static_cast<T>(factinv[-k]); | ^ a.cc: In member function 'T Factorial<T>::C(int, int) const': a.cc:54:36: error: invalid types 'const int[int]' for array subscript 54 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc:54:49: error: invalid types 'const int[int]' for array subscript 54 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc:54:68: error: invalid types 'const int[int]' for array subscript 54 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc: In member function 'T Factorial<T>::P(int, int) const': a.cc:59:37: error: invalid types 'const int[int]' for array subscript 59 | return static_cast<T>((facts[p] * factinv[p-q]) % mod); | ^ a.cc:59:50: error: invalid types 'const int[int]' for array subscript 59 | return static_cast<T>((facts[p] * factinv[p-q]) % mod); | ^ a.cc: At global scope: a.cc:85:8: error: aggregate 'FFT::ar FFT::root' has incomplete type and cannot be defined 85 | ar root; | ^~~~ a.cc:86:9: error: aggregate 'FFT::arr FFT::rev' has incomplete type and cannot be defined 86 | arr rev; | ^~~ a.cc: In function 'void FFT::fft(ar&, ar&)': a.cc:112:38: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 112 | for (int i = 0; i < N; ++i) f[i] = a[rev[i]]; | ^ a.cc:116:30: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 116 | num z = f[i+j+k]* root[j+k]; | ^ a.cc:117:22: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 117 | f[i+j+k] = f[i+j] - z; | ^ a.cc:117:33: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 117 | f[i+j+k] = f[i+j] - z; | ^ a.cc:118:22: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 118 | f[i+j] = f[i+j] + z; | ^ a.cc:118:31: error: no match for 'operator[]' (operand types are 'FFT::ar' {aka 'std::array<FFT::num, 524288>'} and 'int') 118 | f[i+j] = f[i+j] + z; | ^ a.cc: At global scope: a.cc:123:8: error: aggregate 'FFT::ar FFT::a' has in
s486346709
p03991
C++
#include<vector> #include<iostream> #include<functional> using namespace std; using ll=long long; const ll MOD=924844033; using Graph=vector<vector<int>>; vector<ll> fact; vector<ll> factInv; ll powm(ll x,ll k){ ll res=1; while(k){ if(k&1) res=res*x%MOD; k>>=1; x=x*x%MOD; } return res; } ll modInv(ll x){ return powm(x,MOD-2); } inline ll comb(int x,int k){ return fact[x]*factInv[k]%MOD*factInv[x-k]%MOD; } void init(int n){ fact.resize(n+1),factInv.resize(n+1); fact[0]=1; for(int i=0;i<n;i++){ fact[i+1]=fact[i]*(i+1)%MOD; } factInv[n]=modInv(fact[n]); for(int i=n-1;i>=0;i--){ factInv[i]=factInv[i+1]*(i+1)%MOD; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; assert(n<=10000); init(n); Graph g(n); for(int i=0;i+1<n;i++){ int a,b; cin>>a>>b; a--,b--; g[a].push_back(b); g[b].push_back(a); } vector<int> sz(n); function<int(int,int)> dfs=[&](int v,int pre){ sz[v]=1; for(auto to:g[v]){ if(to==pre) continue; sz[v]+=dfs(to,v); } return sz[v]; }; dfs(0,-1); vector<int> szcnt(n+1); for(int i=0;i<n;i++){ for(auto to:g[i]){ if(sz[i]<sz[to]) continue; szcnt[sz[to]]++; szcnt[n-sz[to]]++; } } vector<ll> res(n+1); for(int k=1;k<n;k++) res[k]=n*comb(n-1,k-1)+n*comb(n-1,k); res[n]=n*comb(n-1,n-1); for(int k=1;k<=n;k++){ ll sc=0; for(int i=k;i<=n-k;i++) sc+=szcnt[i]*comb(i,k); res[k]-=sc; res[k]=(res[k]%MOD+MOD)%MOD; } for(int i=1;i<=n;i++){ cout<<res[i]<<"\n"; } return 0; }
a.cc: In function 'int main()': a.cc:44:5: error: 'assert' was not declared in this scope 44 | assert(n<=10000); | ^~~~~~ a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 3 | #include<functional> +++ |+#include <cassert> 4 |
s753966954
p03991
C++
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> static const int MOD = 924844033; using ll = int64_t; using u32 = uint32_t; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; template <class T> T pow_ (T x, T n, T M){ uint64_t u = 1, xx = x; while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; } return static_cast<T>(u); }; template <class T> class Factorial { T mod; vector<uint64_t> facts, factinv; public: Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { facts[0] = 1; for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; } T fact(int k) const { if(k >= 0) return static_cast<T>(facts[k]); else return static_cast<T>(factinv[-k]); } T operator[](const int &k) const { if(k >= 0) return static_cast<T>(facts[k]); else return static_cast<T>(factinv[-k]); } T C(int p, int q) const { if(q < 0 || p < q) return 0; return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); } T P(int p, int q) const { if(q < 0 || p < q) return 0; return static_cast<T>((facts[p] * factinv[p-q]) % mod); } T H(int p, int q) const { if(p < 0 || q < 0) return 0; return static_cast<T>(q == 0 ? 1 : C(p+q-1, q)); } }; #include <cmath> namespace FFT { const int max_base = 19, maxN = 1 << max_base; // N <= 2e5 const double PI = acos(-1); struct num { double x{}, y{}; num() = default; num(double x, double y): x(x), y(y) {} explicit num(double r): x(cos(r)), y(sin(r)) {} }; num operator+(num a, num b) { return {a.x + b.x, a.y + b.y}; } num operator-(num a, num b) { return {a.x - b.x, a.y - b.y}; } num operator*(num a, num b) { return {a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x}; } num conj(num a) {return {a.x, -a.y}; } array<num, maxN> root; array<int, maxN> rev; bool is_root_prepared = false; void prepare_root(){ if(is_root_prepared) return; is_root_prepared = true; root[1] = num(1, 0); for (int i = 1; i < max_base; ++i) { num x(2*PI / (1LL << (i+1))); for (ll j = (1LL << (i-1)); j < (1LL << (i)); ++j) { root[2*j] = root[j]; root[2*j+1] = root[j]*x; } } } int base, N; int lastN = -1; void prepare_rev(){ if(lastN == N) return; lastN = N; for (int i = 0; i < N; ++i) rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (base - 1)); } void fft(array<num, maxN> &a, array<num, maxN> &f){ for (int i = 0; i < N; ++i) f[i] = a[rev[i]]; for (int k = 1; k < N; k <<= 1) { for (int i = 0; i < N; i += 2*k) { for (int j = 0; j < k; ++j) { num z = f[i+j+k]* root[j+k]; f[i+j+k] = f[i+j] - z; f[i+j] = f[i+j] + z; } } } } array<num, maxN> a, b, f, g; array<ll, maxN> A, B, C; void multi_mod(int m){ for (int i = 0; i < N; ++i) { ll x = A[i] % m; a[i] = num(x & ((1LL << 15)-1), x >> 15); } for (int i = 0; i < N; ++i) { ll x = B[i] % m; b[i] = num(x & ((1LL << 15)-1), x >> 15); } fft(a, f); fft(b, g); for (int i = 0; i < N; ++i) { int j = (N-i) &(N-1); num a1 = (f[i] + conj(f[j])) * num(0.5, 0); num a2 = (f[i] - conj(f[j])) * num(0, -0.5); num b1 = (g[i] + conj(g[j])) * num(0.5/N, 0); num b2 = (g[i] - conj(g[j])) * num(0, -0.5/N); a[j] = a1*b1 + a2*b2 * num(0, 1); b[j] = a1*b2 + a2*b1; } fft(a, f); fft(b, g); for (int i = 0; i < N; ++i) { ll aa = f[i].x + 0.5; ll bb = g[i].x + 0.5; ll cc = f[i].y + 0.5; C[i] = (aa + bb % m * (1LL << 15) + cc% m *(1LL << 30)) % m; } } void prepare_AB(int n1, int n2){ base = 1; N = 2; while(N < n1+n2) base++, N <<= 1; for (int i = n1; i < N; ++i) A[i] = 0; for (int i = n2; i < N; ++i) B[i] = 0; prepare_root(); prepare_rev(); } void multi_mod(int n1, int n2, int m){ prepare_AB(n1, n2); multi_mod(m); } } struct poly { vector<int> v; poly() = default; explicit poly(vector<int> vv) : v(std::move(vv)) {}; int size() {return (int)v.size(); } poly cut(int len){ if(len < v.size()) v.resize(static_cast<unsigned long>(len)); return *this; } inline int& operator[] (int i) {return v[i]; } }; poly operator+(poly &A, poly &B){ poly C; C.v = vector<int>(max(A.size(), B.size())); for (int i = 0; i < A.size(); ++i) C[i] = A[i]; for (int i = 0; i < B.size(); ++i) (C[i] += B[i]) %= MOD; return C; } poly operator-(poly &A, poly &B){ poly C; C.v = vector<int>(max(A.size(), B.size())); for (int i = 0; i < A.size(); ++i) C[i] = A[i]; for (int i = 0; i < B.size(); ++i) (C[i] += MOD-B[i]) %= MOD; return C; } poly operator* (poly &A, poly &B){ poly C; C.v = vector<int>(A.size() + B.size()-1); for (int i = 0; i < A.size(); ++i) FFT::A[i] = A[i]; for (int i = 0; i < B.size(); ++i) FFT::B[i] = B[i]; FFT::multi_mod(A.size(), B.size(), MOD); for (int i = 0; i < C.size(); ++i) C[i] = FFT::C[i]; return C; } int main() { int n; cin >> n; vector<vector<int>> G(n); for (int i = 0; i < n-1; ++i) { int a, b; scanf("%d %d", &a, &b); G[a-1].emplace_back(b-1); G[b-1].emplace_back(a-1); } deque<int> Q; vector<int> num(n); { stack<int> s; int cnt = 0; vector<int> visited(n, 0); s.emplace(0); while(!s.empty()){ int a = s.top(); s.pop(); visited[a]++; num[a] = cnt++; Q.emplace_front(a); for (auto &&i : G[a]) { if(!visited[i]) s.emplace(i); } } } vector<int> v(n, 1); vector<int> u(n+1); while(!Q.empty()){ int i = Q.front(); Q.pop_front(); for (auto &&j : G[i]) { if(num[i] < num[j]) v[i] += v[j]; } } for (int i = 0; i < n; ++i) { for (auto &&j : G[i]) { if(i < j){ int p = min(v[i], v[j]); u[p]++; u[n-p]++; } } } Factorial<ll> fact(n, MOD); for (int i = 0; i <= n; ++i) { u[i] = static_cast<int>((fact[i] * u[i]) % MOD); } vector<int> uu(n+1); for (int i = 0; i <= n; ++i) { uu[i] = static_cast<int>(fact[i-n]); } poly f(u), g(uu); poly h = f*g; for (int k = 1; k <= n; ++k) { ll ans = (fact.C(n, k)*n%MOD + (MOD - fact[-k]*h[n+k]%MOD)) % MOD; cout << ans << "\n"; } return 0; }
a.cc:13:13: error: 'uint32_t' does not name a type 13 | using u32 = uint32_t; | ^~~~~~~~ a.cc:10:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 9 | #include <bitset> +++ |+#include <cstdint> 10 | a.cc:16:39: error: '::numeric_limits' has not been declared 16 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ^~~~~~~~~~~~~~ a.cc:16:55: error: expected primary-expression before '>' token 16 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ^ a.cc:16:61: error: no matching function for call to 'max()' 16 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; | ~~~~~^~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In function 'T pow_(T, T, T)': a.cc:20:5: error: 'uint64_t' was not declared in this scope 20 | uint64_t u = 1, xx = x; | ^~~~~~~~ a.cc:20:5: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:22:18: error: 'u' was not declared in this scope 22 | if (n&1) u = u * xx % M; | ^ a.cc:22:26: error: 'xx' was not declared in this scope; did you mean 'x'? 22 | if (n&1) u = u * xx % M; | ^~ | x a.cc:23:9: error: 'xx' was not declared in this scope; did you mean 'x'? 23 | xx = xx * xx % M; | ^~ | x a.cc:26:27: error: 'u' was not declared in this scope 26 | return static_cast<T>(u); | ^ a.cc: At global scope: a.cc:31:12: error: 'uint64_t' was not declared in this scope 31 | vector<uint64_t> facts, factinv; | ^~~~~~~~ a.cc:31:12: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:31:20: error: template argument 1 is invalid 31 | vector<uint64_t> facts, factinv; | ^ a.cc:31:20: error: template argument 2 is invalid a.cc: In constructor 'Factorial<T>::Factorial(int, T)': a.cc:34:49: error: 'u32' does not name a type 34 | Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { | ^~~ a.cc:34:81: error: 'u32' does not name a type 34 | Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) { | ^~~ a.cc:35:14: error: invalid types 'int[int]' for array subscript 35 | facts[0] = 1; | ^ a.cc:36:44: error: invalid types 'int[int]' for array subscript 36 | for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; | ^ a.cc:36:55: error: invalid types 'int[int]' for array subscript 36 | for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod; | ^ a.cc:37:16: error: invalid types 'int[int]' for array subscript 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^ a.cc:37:32: error: invalid types 'int[int]' for array subscript 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^ a.cc:37:49: error: 'uint64_t' does not name a type 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^~~~~~~~ a.cc:37:49: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:37:81: error: 'uint64_t' does not name a type 37 | factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod)); | ^~~~~~~~ a.cc:37:81: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:38:47: error: invalid types 'int[int]' for array subscript 38 | for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; | ^ a.cc:38:60: error: invalid types 'int[int]' for array subscript 38 | for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod; | ^ a.cc: In member function 'T Factorial<T>::fact(int) const': a.cc:42:47: error: invalid types 'const int[int]' for array subscript 42 | if(k >= 0) return static_cast<T>(facts[k]); | ^ a.cc:43:43: error: invalid types 'const int[int]' for array subscript 43 | else return static_cast<T>(factinv[-k]); | ^ a.cc: In member function 'T Factorial<T>::operator[](const int&) const': a.cc:47:47: error: invalid types 'const int[const int]' for array subscript 47 | if(k >= 0) return static_cast<T>(facts[k]); | ^ a.cc:48:43: error: invalid types 'const int[int]' for array subscript 48 | else return static_cast<T>(factinv[-k]); | ^ a.cc: In member function 'T Factorial<T>::C(int, int) const': a.cc:53:36: error: invalid types 'const int[int]' for array subscript 53 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc:53:49: error: invalid types 'const int[int]' for array subscript 53 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc:53:68: error: invalid types 'const int[int]' for array subscript 53 | return static_cast<T>(facts[p]* factinv[q] % mod * factinv[p-q] % mod); | ^ a.cc: In member function 'T Factorial<T>::P(int, int) const': a.cc:58:37: error: invalid types 'const int[int]' for array subscript 58 | return static_cast<T>((facts[p] * factinv[p-q]) % mod); | ^ a.cc:58:50: error: invalid types 'const int[int]' for array subscript 58 | return static_cast<T>((facts[p] * factinv[p-q]) % mod); | ^ a.cc: At global scope: a.cc:81:22: error: aggregate 'std::array<FFT::num, 524288> FFT::root' has incomplete type and cannot be defined 81 | array<num, maxN> root; | ^~~~ a.cc:68:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>' 67 | #include <cmath> +++ |+#include <array> 68 | namespace FFT { a.cc:82:22: error: aggregate 'std::array<int, 524288> FFT::rev' has incomplete type and cannot be defined 82 | array<int, maxN> rev; | ^~~ a.cc:82:22: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>' a.cc: In function 'void FFT::fft(std::array<num, 524288>&, std::array<num, 524288>&)': a.cc:108:38: error: no match for 'operator[]' (operand types are 'std::array<FFT::num, 524288>' and 'int') 108 | for (int i = 0; i < N; ++i) f[i] = a[rev[i]]; | ^ a.cc:112:30: error: no match for 'operator[]' (operand types are 'std::array<FFT::num, 524288>' and 'int') 112 | num z = f[i+j+k]* root[j+k]; | ^ a.cc:113:22: error: no match for 'operator[]' (operand types are 'std::array<FFT::num, 524288>' and 'int') 113 | f[i+j+k] = f[i+j] - z; | ^ a.cc:113:33: error: no match for 'operator[]' (operand types are 'std::array<FFT::num, 524288>' and 'int') 113 | f[i+j+k] = f[i+j] - z; | ^ a.cc:114:22: error: no match for 'operator[]' (operand types are 'std::array<FFT::num, 524288>' and 'int') 114
s642448436
p03991
C++
#include <smmintrin.h> #include <immintrin.h> #pragma GCC target("avx2") #pragma GCC target("fma") #pragma GCC optimize("Ofast") #include <stdio.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #pragma warning(disable:4996) #pragma comment(linker, "/STACK:336777216") using namespace std; #define mp make_pair #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) ((int)(x).size()) #define rep(i, n) for(int i=0;i<n;i++) #define all(x) (x).begin(), (x).end() #define ldb ldouble typedef unsigned int uint; typedef tuple<int, int, int> t3; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef pair <ll, int> pli; typedef pair <db, db> pdd; int IT_MAX = 1 << 19; const ll MOD = 1000000007; const int INF = 0x3f3f3f3f; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; const db PI = acos(-1); const db ERR = 1e-10; namespace FFT{ const int P = 924844033, R = 5; const int SZ = 19, N = 1 << SZ; uint Pow(int x, int y) { int r = 1; while (y) { if (y & 1) r = (ll) r * x % P; x = (ll) x * x % P; y >>= 1; } return r; } const uint RP = Pow((1ll<<32)%P, P-2), MP = P-2; // MP = P^-1 mod 2^32 const uint QP = ((ll)Pow(R, (P-1)/4) << 32) % P; const uint OP = ((ll)Pow(R, (P-1)/8) << 32) % P; const uint RQP = ((ll)Pow(R, (P-1)/4*3) << 32) % P; const uint ROP = ((ll)Pow(R, (P-1)/8*7) << 32) % P; uint A[N] __attribute__ ((aligned (0x100))); uint B[N] __attribute__ ((aligned (0x100))); __m256i Pa; void init(){ Pa = _mm256_set1_epi32(P); } inline uint fit(uint a){ return a >= P? a-P : a; } __m256i avx_add(__m256i a, __m256i b){ __m256i c = _mm256_add_epi32(a, b); __m256i d = _mm256_sub_epi32(c, Pa); return _mm256_min_epu32(c, d); } __m256i avx_sub(__m256i a, __m256i b){ __m256i c = _mm256_sub_epi32(a, b); __m256i d = _mm256_add_epi32(c, Pa); return _mm256_min_epu32(c, d); } __m256i avx_fit(__m256i a){ __m256i b = _mm256_sub_epi32(a, Pa); return _mm256_min_epu32(a, b); } uint my_mul(uint a, uint b){ return fit(((ull)a*b + (ull)P*(a*b*MP)) >> 32); } __m256i avx_mul(__m256i a, __m256i b){ __m256i res[2]; __m256i p = _mm256_mullo_epi32(_mm256_mullo_epi32(a, b), _mm256_set1_epi32(MP)); __m256i ax = _mm256_shuffle_epi32(a, 0x50); __m256i bx = _mm256_shuffle_epi32(b, 0x50); __m256i px = _mm256_shuffle_epi32(p, 0x50); __m256i c = _mm256_mul_epu32(ax, bx); __m256i f = _mm256_mul_epu32(px, Pa); res[0] = _mm256_add_epi64(c, f); ax = _mm256_shuffle_epi32(a, 0xfa); bx = _mm256_shuffle_epi32(b, 0xfa); px = _mm256_shuffle_epi32(p, 0xfa); c = _mm256_mul_epu32(ax, bx); f = _mm256_mul_epu32(px, Pa); res[1] = _mm256_add_epi64(c, f); return avx_fit(_mm256_hadd_epi32(res[0], res[1])); } inline void run(uint* A, bool rv) { int j = 0, k = 0; A[0] = ((ull)A[0] << 32) % P; // Encode for (int i = 1; i < N; i++) { for (k = N >> 1; j >= k; k >>= 1) j -= k; j += k; if (i < j) swap(A[i], A[j]); A[i] = ((ull)A[i] << 32) % P; // Encode } uint x = ((ull)Pow(rv ? Pow(R, P - 2) : R, P >> 3) << 32) % P; for (int j = 0; j < N; j += 8) { uint y = (1ll<<32) % P; uint v[8], z; auto f = [](uint &v1, uint &v2, uint a, uint b){ v1 = fit(a+b); v2 = fit(a-b+P); }; for(int t = 0; t < 8; t++) v[t] = A[j+t]; z = my_mul(y, y); z = my_mul(z, z); for(int k = 0; k < 8; k += 2) f(v[k], v[k+1], v[k], my_mul(v[k+1], z)); z = my_mul(y, y); for(int k = 0; k < 2; k ++, z = my_mul(z, rv? RQP : QP)) f(v[k], v[k+2], v[k], my_mul(v[k+2], z)); z = my_mul(y, y); for(int k = 4; k < 6; k ++, z = my_mul(z, rv? RQP : QP)) f(v[k], v[k+2], v[k], my_mul(v[k+2], z)); z = y; for(int k = 0; k < 4; k ++, z = my_mul(z, rv? ROP : OP)) f(v[k], v[k+4], v[k], my_mul(v[k+4], z)); for(int t = 0; t < 8; t++) A[j+t] = v[t]; y = my_mul(y, x); } // */ //* for (int i = 8; i < N; i <<= 1) { uint t = ((ull)Pow(rv ? Pow(R, P - 2) : R, P / i >> 1) << 32) % P; uint u = (1ll << 32) % P; __m256i yi, x; for(int j = 0; j < 8; j++, u = my_mul(u, t)) yi = _mm256_insert_epi32(yi, u, j); x = _mm256_set1_epi32(u); for (int j = 0; j < N; j += i << 1) { __m256i y = yi; for(int l = 0; l < i; l += 8){ __m256i v[2]; auto f = [](__m256i &v1, __m256i &v2, __m256i a, __m256i b){ v1 = avx_add(a, b); v2 = avx_sub(a, b); }; for(int t = 0; t < 2; t++) v[t] = _mm256_stream_load_si256((__m256i *)(A+j+i*t+l)); f(v[0], v[1], v[0], avx_mul(v[1], y)); for(int t = 0; t < 2; t++) _mm256_store_si256((__m256i *)(A+j+i*t+l), v[t]); y = avx_mul(y, x); } } } // */ if(rv){ uint v = ((ull)Pow(N, P - 2) << 32) % P; for (int i = 0; i < N; i++) A[i] = my_mul(A[i], v); } for(int i = 0; i < N; i++) A[i] = (ull)A[i] * RP % P; // Decode } void runA(bool rv){ return run(A, rv); } void runB(bool rv){ return run(B, rv); } void multiplication(){ runA(false); runB(false); for(int i = 0; i < N; i++) A[i] = (ll)A[i] * B[i] % P; runA(true); } } const int MX = 200005; const int MM = 924844033; int cnt[MX]; ll I[MX]; vector<int> T[MX]; void dfs(int x, int p = -1){ cnt[x]++; for(int c : T[x]){ if( c == p ) continue; dfs(c, x); cnt[x] += cnt[c]; } } int ans[1<<21]; int main() { FFT::init(); int N, K; scanf("%d", &N); I[1] = 1; for(int i = 2; i <= N; i++) I[i] = (MM - MM/i) * I[MM%i] % MM; for(int i = 1; i < N; i++){ int a, b; scanf("%d%d", &a, &b); T[a].push_back(b); T[b].push_back(a); } dfs(1); uint* F = FFT::A, *G = FFT::B; ans[0] = G[0] = 1; for(int i = 1; i <= N; i++) ans[i] = G[i] = G[i-1] * I[i] % MM; F[0] += N; for(int c : T[1]){ F[N-cnt[c]] -= 1; } for(int i = 2; i <= N; i++){ int mx = 0; for(int c : T[i]) mx = max(mx, cnt[c]); for(int c : T[i]){ if( cnt[c] != mx ){ F[N-cnt[c]] -= 1; } } F[cnt[i]] -= 1; } ll mul = 1; for(int i = 0; i <= N; i++){ F[N-i] = mul * (MM+F[N-i]) % MM; mul = mul * (i+1) % MM; } FFT::multiplication(); for(int i = N-1; i >= 0; i--) printf("%lld\n", (ll)F[i] * ans[N-i] % MM); }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from a.cc:10: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from a.cc:14: /usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here 132 | struct _Vector_impl | ^~~~~~~~~~~~
s629560677
p03991
C++
#include <cstdio> typedef long long LL; const int N = 2e5 + 10; const int Mod = 924844033; const int M = (1 << 20) + 10; struct E {int v, nt;} e[N<<1]; int n, L, tot, a[M], b[M], h[N], wn[30], fac[N], inv[N], rev[M]; inline int mls(int x) {return x < 0 ? x + Mod : x;} inline int pls(int x) {return x >= Mod ? x - Mod : x;} inline void add(int u, int v) { e[++tot] = (E){v, h[u]}, h[u] = tot; e[++tot] = (E){u, h[v]}, h[v] = tot; } template <class T> inline void swap(T &a, T &b) {T t = a; a = b, b = t;} template <class T> inline void in(T &x) { x = 0; int f = 1; char ch = getchar(); for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();} for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar(); x *= f; } inline int qpow(int A, int B) { int S = 1; for (; B; B >>= 1, A = 1LL * A * A % Mod) if (B & 1) S = 1LL * S * A % Mod; return S; } inline int dfs(int x, int f) { int sz = 1; for (int v, i = h[x]; i; i = e[i].nt) if ((v = e[i].v) != f) sz += dfs(v, x); if (x != 1) ++a[sz], ++a[n - sz]; return sz } inline void FFT(int *a, int n) { for (int i = 0; i < n; ++i) if (i < rev[i]) swap(a[i], a[rev[i]]); for (int i = 1, l = L-1; i < n; i <<= 1, --l) for (int j = 0; j < n; j += i << 1) for (int u, v, k = 0, w = 1; k < i; ++k, w = 1LL * w * wn[l] % Mod) u = a[j + k], v = 1LL * w * a[i + j + k] % Mod, a[j + k] = pls(u + v), a[i + j + k] = mls(u - v); } inline void Mul(int m) { int invn, n = 1; for (L = 0; n <= m; n <<= 1, ++L); invn = qpow(n, Mod - 2); for (int i = 1; i < n; ++i) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << L-1); wn[0] = qpow(5, Mod-1 >> L); for (int i = 1; i < L; ++i) wn[i] = 1LL * wn[i-1] * wn[i-1] % Mod; FFT(a, n), FFT(b, n); for (int i = 0; i < n; ++i) a[i] = 1LL * a[i] * b[i] % Mod; wn[0] = qpow(wn[0], Mod - 2); for (int i = 1; i < L; ++i) wn[i] = 1LL * wn[i-1] * wn[i-1] % Mod; FFT(a, n); for (int i = 0; i < n; ++i) a[i] = 1LL * a[i] * invn % Mod; } int main() { int u, v, ret; in(n); for (int i = 1; i < n; ++i) in(u), in(v), add(u, v); dfs(1, 0), fac[0] = fac[1] = inv[0] = inv[1] = 1; for (int i = 2; i <= n; ++i) inv[i] = 1LL * (Mod - Mod / i) * inv[Mod % i] % Mod; for (int i = 1; i <= n; ++i) inv[i] = 1LL * inv[i - 1] * inv[i] % Mod; for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % Mod; for (int i = 0; i <= n; ++i) a[i] = 1LL * a[i] * fac[n - i] % Mod, b[i] = inv[i]; Mul(n << 1); for (int i = 1; i <= n; ++i) { ret = mls(1LL*n*fac[n]%Mod*inv[n-i]%Mod*inv[i]%Mod - 1LL*a[n-i]*inv[i]%Mod); printf("%d\n", ret); } return 0; }
a.cc: In function 'int dfs(int, int)': a.cc:36:18: error: expected ';' before '}' token 36 | return sz | ^ | ; 37 | } | ~
s695345277
p03991
C++
//~ #pragma GCC optimize ("Ofast") #include <bits/stdc++.h> using namespace std; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge {c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " typedef long long ll; const int mod = 924844033; int add(int a, int b) { a += b; if(a >= mod) a -= mod; return a; } void add_self(int & a, int b) { a = add(a, b); } int mul(int a, int b) { return (ll) a * b % mod; } void mul_self(int & a, int b) { a = mul(a, b); } int my_pow(int a, int b) { int r = 1; while(b) { if(b % 2) mul_self(r, a); mul_self(a, a); b /= 2; } return r; } int my_inv(int a) { return my_pow(a, mod - 2); } #define div div_ok int div(int a, int b) { return mul(a, my_inv(b)); } int sub(int a, int b) { a -= b; if(a < 0) a += mod; return a; } #define REP(i,n) for(int i = 0; i < int(n); ++i) int gen; void dft(vector<int> & a, bool rev) { const int n = a.size(); for(int i = 1, k = 0; i < n; ++i) { for(int bit = n / 2; (k ^= bit) < bit; bit /= 2);;; if(i < k) swap(a[i], a[k]); } for(int len = 1, who = 0; len < n; len *= 2, ++who) { static vector<int> t[2][30]; vector<int> & om = t[rev][who]; if(om.empty()) { om.resize(len); om[0] = 1; int pierw = gen; //my_pow(3, 7 * 17); for(int rep = 0; rep < 20 - who; ++rep) pierw = mul(pierw, pierw); if(rev) pierw = my_inv(pierw); for(int i = 1; i < len; ++i) om[i] = mul(om[i-1], pierw); } for(int i = 0; i < n; i += 2 * len) REP(k, len) { int x = a[i+k]; int y = mul(a[i+k+len], om[k]); a[i+k] = x + y; if(a[i+k] >= mod) a[i+k] -= mod; a[i+k+len] = x - y; if(a[i+k+len] < 0) a[i+k+len] += mod; } } int tmp = my_inv(n); if(rev) REP(i, n) a[i] = mul(a[i], tmp); } vector<int> multiply( vector<int> a, vector<int> b) { if(a.empty() || b.empty()) return {}; int n = a.size() + b.size(); /*vector<T> ans(n - 1); if(min(a.size(),b.size()) < 190) { // BRUTE FORCE REP(i, a.size()) REP(j, b.size()) ans[i+j] += a[i]*b[j]; return ans; } */ while(n&(n-1)) ++n; a.resize(n); b.resize(n); dft(a, false); dft(b, false); for(int i = 0; i < n; ++i) a[i] = mul(a[i], b[i]); dft(a, true); return a; } #define C C2 //~ #warning small nax //~ const int nax = 205; const int nax = 2e5 + 5; vector<int> w[nax]; int n; int subtree[nax], cnt[nax], fac[nax], inv_fac[nax]; int C(int a, int b) { assert(a >= b && b >= 0); return mul(fac[a], mul(inv_fac[b], inv_fac[a-b])); } void dfs(int a, int par) { subtree[a] = 1; for(int b : w[a]) if(b != par) { dfs(b, a); subtree[a] += subtree[b]; ++cnt[subtree[b]]; ++cnt[n-subtree[b]]; } } void read_uint(int *x){ char c=0; while(c<'0') c = getchar_unlocked(); *x = c-'0'; c = getchar_unlocked(); while(c>='0') { *x *= 10; *x += c-'0'; c = getchar_unlocked(); } } void write_uint(int x){ static char buf[13]=" \n"; if(x==0){ fputs_unlocked("0\n", stdout); return; } int i = 10; while(x) { buf[i--] = '0' + x % 10; x /= 10; } fputs_unlocked(buf+1+i, stdout); } bool okk(int x) { for(int rep = 0; rep < 20; ++rep) x = mul(x, x); if(x == 1) return false; return mul(x, x) == 1; } int main() { gen = 2; while(!okk(gen)) ++gen; fac[0] = 1; for(int i = 1; i < nax; ++i) fac[i] = mul(fac[i-1], i); inv_fac[nax-1] = my_inv(fac[nax-1]); for(int i = nax - 2; i >= 0; --i) inv_fac[i] = mul(inv_fac[i+1], i+1); //~ for(int i = 0; i < nax; ++i) inv_fac[i] = my_inv(fac[i]); //~ scanf("%d", &n); read_uint(&n); for(int rep = 0; rep < n - 1; ++rep) { int a, b; read_uint(&a); read_uint(&b); //~ scanf("%d%d", &a, &b); w[a].push_back(b); w[b].push_back(a); } dfs(1, -1); for(int i = 1; i <= n; ++i) mul_self(cnt[i], fac[i]); vector<int> a(n+1), b(n+1); for(int i = 0; i <= n; ++i) { a[i] = cnt[n-i]; b[i] = inv_fac[i]; } vector<int> c = multiply(a, b); for(int k = 1; k <= n; ++k) { int answer = c[n-k]; //~ for(int s = k; s <= n; ++s) //~ add_self(answer, mul(cnt[s], inv_fac[s-k])); mul_self(answer, inv_fac[k]); int whole = mul(n, C(n, k)); write_uint(sub(whole, answer)); } }\
a.cc:231:2: error: stray '\' in program 231 | }\ | ^
s194035815
p03991
C++
// <easy.cpp> - Mon Mar 27 20:17:23 2017 // This file is created by XuYike's black technology automatically. // Copyright (C) 2015 ChangJun High School, Inc. // I don't know what this program is. #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <cstdio> #include <cmath> using namespace std; typedef long long lol; #define next NEXT template<typename T> inline void gg(T &res){ res=0;T fh=1;char ch=getchar(); while((ch>'9'||ch<'0')&&ch!='-')ch=getchar(); if(ch=='-')fh=-1,ch=getchar(); while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar(); res*=fh; } inline int gi(){int x;gg(x);return x;} inline lol gl(){lol x;gg(x);return x;} const int MAXN=400010; const int INF=1e9; const int MOD=924844033; int bt,b[MAXN],next[MAXN],to[MAXN]; inline void add(int x,int y){ next[++bt]=b[x];b[x]=bt;to[bt]=y; next[++bt]=b[y];b[y]=bt;to[bt]=x; } int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; void dfs(int x,int f){ A[n]++;size[x]=1; for(int i=b[x];i;i=next[i]){ if(to[i]==f)continue; dfs(to[i],x); size[x]+=size[to[i]]; if(--A[size[to[i]]]<0)A[size[to[i]]]+=MOD; } if(--A[n-size[x]]<0)A[n-size[x]]+=MOD; } int qpow(int x,int y){ int res=1; while(y){ if(y&1)res=1ll*res*x%MOD; x=1ll*x*x%MOD; y>>=1; } return res; } void ntt(int *a,int f){ for(int i=0;i<n;i++)if(i<R[i])swap(a[i],a[R[i]]); for(int i=1;i<n;i<<=1){ int gn=qpow(5,(MOD-1)/(i<<1)); if(f < 0) gn = qpow(gn, mod - 2); for(int j=0;j<n;j+=i<<1){ int g=1; for(int k=0;k<i;k++,g=1ll*g*gn%MOD){ int x=a[j+k],y=1ll*g*a[j+k+i]%MOD; a[j+k]=(x+y)%MOD; a[j+k+i]=(x-y+MOD)%MOD; } } } if(f==-1){ // reverse(a+1,a+n); int ny=qpow(n,MOD-2); for(int i=0;i<n;i++)a[i]=1ll*a[i]*ny%MOD; } } int nj[MAXN]; int main(){ n=gi(); for(int i=1;i<n;i++)add(gi(),gi()); dfs(1,0); int jc=1; for(int i=1;i<=n;i++)A[i]=1ll*A[i]*(jc=1ll*jc*i%MOD)%MOD; nj[n]=qpow(jc,MOD-2);for(int i=n;i;i--)nj[i-1]=1ll*nj[i]*i%MOD; for(int i=1;i<=n;i++)B[i]=nj[n-i]; int m=n; for(n=1;n<=m<<1;n<<=1)L++; for(int i=0;i<n;i++)R[i]=R[i>>1]>>1|((i&1)<<(L-1)); ntt(A,1);ntt(B,1); for(int i=0;i<n;i++)A[i]=1ll*A[i]*B[i]%MOD; ntt(A,-1); for(int i=1;i<=m;i++)printf("%d\n",1ll*A[m+i]*nj[i]%MOD); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:35:12: error: reference to 'size' is ambiguous 35 | A[n]++;size[x]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:6: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc:39:9: error: reference to 'size' is ambiguous 39 | size[x]+=size[to[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc:39:18: error: reference to 'size' is ambiguous 39 | size[x]+=size[to[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc:40:16: error: reference to 'size' is ambiguous 40 | if(--A[size[to[i]]]<0)A[size[to[i]]]+=MOD; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc:40:33: error: reference to 'size' is ambiguous 40 | if(--A[size[to[i]]]<0)A[size[to[i]]]+=MOD; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc:42:14: error: reference to 'size' is ambiguous 42 | if(--A[n-size[x]]<0)A[n-size[x]]+=MOD; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc:42:29: error: reference to 'size' is ambiguous 42 | if(--A[n-size[x]]<0)A[n-size[x]]+=MOD; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:33:7: note: 'int size [400010]' 33 | int n,size[MAXN],A[MAXN<<1],B[MAXN<<1],L,R[MAXN<<1]; | ^~~~ a.cc: In function 'void ntt(int*, int)': a.cc:57:25: error: 'mod' was not declared in this scope; did you mean 'modf'? 57 | if(f < 0) gn = qpow(gn, mod - 2); | ^~~ | modf
s545868453
p03991
C++
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 2e5, maxm = 19; const int mod = 924844033, gen = 5; int n; vector<int> g[maxn]; int size[maxn], cnt[maxn]; int fact[maxn + 1], ifact[maxn + 1]; int a[maxn], b[maxn]; void Dfs(int u, int p) { size[u] = 1; for (int v : g[u]) { if (v == p) continue; Dfs(v, u); size[u] += size[v]; ++cnt[size[v]]; ++cnt[n - size[v]]; } } inline int Mul(int a, int b) { return (long long)a * b % mod; } inline int Add(int a) { return a >= mod ? a - mod : a; } inline int Sub(int a) { return a < 0 ? a + mod : a; } int Pow(int a, int b) { int c = 1; for (; b; b >>= 1) { if (b & 1) c = Mul(c, a); a = Mul(a, a); } return c; } void FFT(int *a, int n) { for (int i = 0; i < 1 << n; ++i) { int j = 0, x = i; for (int k = 0; k < n; ++k) { j = (j << 1) | (x & 1); x >>= 1; } if (i < j) { swap(a[i], a[j]); } } for (int i = 0; i < n; ++i) { int root = Pow(gen, (mod - 1) / (2 << i)); for (int j = 0; j < 1 << n; j += 2 << i) { int *l = a + j, *r = l + (1 << i), w = 1; for (int k = 0; k < 1 << i; ++k, w = Mul(w, root)) { int t = Mul(w, r[k]); r[k] = Sub(l[k] - t); l[k] = Add(l[k] + t); } } } } void IFFT(int *a, int n) { reverse(a + 1, a + (1 << n)); FFT(a, n); int inv = Pow(1 << n, mod - 2); for (int i = 0; i < 1 << n; ++i) { a[i] = Mul(a[i], inv); } } int main(void) { scanf("%d", &n); for (int i = 0; i < n - 1; ++i) { int a, b; scanf("%d%d", &a, &b); --a; --b; g[a].push_back(b); g[b].push_back(a); } Dfs(0, -1); fact[0] = 1; for (int i = 1; i <= n; ++i) { fact[i] = Mul(fact[i - 1], i); } ifact[n] = Pow(fact[n], mod - 2); for (int i = n; i >= 1; --i) { ifact[i - 1] = Mul(ifact[i], i); } for (int i = 0; i < n; ++i) { a[i] = ifact[i]; } for (int i = 1; i < n; ++i) { b[i] = Mul(cnt[n - i], fact[n - i]); } int m = 0; while (1 << m < n << 1) { ++m; } FFT(a, m); FFT(b, m); for (int i = 0; i < 1 << m; ++i) { a[i] = Mul(a[i], b[i]); } IFFT(a, m); for (int k = 1; k <= n; ++k) { int t = Mul(a[n - k], ifact[k]); int c = Mul(fact[n], Mul(ifact[k], ifact[n - k])); printf("%d\n", Sub(Mul(n, c) - t)); } return 0; }
a.cc:10:1: error: 'vector' does not name a type 10 | vector<int> g[maxn]; | ^~~~~~ a.cc: In function 'void Dfs(int, int)': a.cc:17:16: error: 'g' was not declared in this scope 17 | for (int v : g[u]) { | ^ a.cc: In function 'int main()': a.cc:85:5: error: 'g' was not declared in this scope 85 | g[a].push_back(b); | ^
s711518246
p03991
C++
#include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int MAXN = 524290; const int MOD = 924844033; int a[MAXN], b[MAXN]; int n, m, i, j, k, x, y; int size[MAXN]; int first[MAXN], next[MAXN], go[MAXN], t, pre[MAXN]; int bit[MAXN], f[MAXN]; inline int get() { char c; while ((c = getchar()) < 48 || c > 57); int res = c - 48; while ((c = getchar()) >= 48 && c <= 57) res = res * 10 + c - 48; return res; } inline void add(int x, int y) { next[++t] = first[x]; first[x] = t; go[t] = y; } inline void dfs(int now, int las) { size[now] = 1; for(int i = first[now]; i; i = next[i]) if (go[i] != las) dfs(go[i], now), size[now] += size[go[i]]; a[n - size[now]] --; a[n] ++; for(int i = first[now]; i; i = next[i]) if (go[i] != las) a[size[go[i]]] --; } inline int ksm(int x, int y, int z) { int b = 1; while (y) { if (y & 1) b = 1ll * b * x % z; x = 1ll * x * x % z; y >>= 1; } return b; } inline int ntt_init(int m) { int n = 1, nn = 0; while (n <= m) n <<= 1, nn ++; int g = ksm(5, (MOD - 1) / n, MOD); f[0] = 1; for(int i = 1; i < n; i ++) f[i] = 1ll * f[i - 1] * g % MOD, bit[i] = (bit[i >> 1] >> 1) | ((i & 1) << nn - 1); return nn; } inline void ntt(int *a, int nn, int ty) { int n = 1 << nn; for(int i = 0; i < n; i ++) if (i < bit[i]) swap(a[i], a[bit[i]]); for(int k = 1; k <= nn; k ++) { int len = 1 << k, wn = (ty == 1) ? f[n / len] : f[n - n / len]; for(int j = 0; j < n; j += len) { int m = len >> 1, w = 1; for(int i = j; i < j + m; i ++) { int l = a[i], t = 1ll * a[i + m] * w % MOD; a[i] = (l + t) % MOD; a[i + m] = (l - t + MOD) % MOD; w = 1ll * w * wn % MOD; } } } } int main() { cin >> n; for(i = 1; i < n; i ++) { x = get(); y = get(); add(x, y); add(y, x); } int nn = ntt_init(n << 1), N = 1 << nn; dfs(1, 0); for(i = 1; i <= n; i ++) if (a[i] < 0) a[i] += MOD; pre[0] = 1; for(i = 1; i < N; i ++) pre[i] = 1ll * pre[i - 1] * i % MOD, a[i] = 1ll * a[i] * pre[i] % MOD; for(i = 0; i <= n; i ++) b[i] = ksm(pre[n - i], MOD - 2, MOD); ntt(a, nn, 1); ntt(b, nn, 1); for(i = 0; i < N; i ++) a[i] = 1ll * a[i] * b[i] % MOD; ntt(a, nn, -1); int po = ksm(N, MOD - 2, MOD); for(i = 0; i < N; i ++) a[i] = 1ll * a[i] * po % MOD; for(i = n + 1; i <= n + n; i ++) printf("%d\n", 1ll * a[i] * ksm(pre[i - n], MOD - 2, MOD) % MOD); }
a.cc: In function 'void add(int, int)': a.cc:26:9: error: reference to 'next' is ambiguous 26 | next[++t] = first[x]; first[x] = t; go[t] = y; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:13:18: note: 'int next [524290]' 13 | int first[MAXN], next[MAXN], go[MAXN], t, pre[MAXN]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:30:9: error: reference to 'size' is ambiguous 30 | size[now] = 1; | ^~~~ In file included from /usr/include/c++/14/vector:69, from a.cc:2: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:12:5: note: 'int size [524290]' 12 | int size[MAXN]; | ^~~~ a.cc:31:40: error: reference to 'next' is ambiguous 31 | for(int i = first[now]; i; i = next[i]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:13:18: note: 'int next [524290]' 13 | int first[MAXN], next[MAXN], go[MAXN], t, pre[MAXN]; | ^~~~ a.cc:32:52: error: reference to 'size' is ambiguous 32 | if (go[i] != las) dfs(go[i], now), size[now] += size[go[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:12:5: note: 'int size [524290]' 12 | int size[MAXN]; | ^~~~ a.cc:32:65: error: reference to 'size' is ambiguous 32 | if (go[i] != las) dfs(go[i], now), size[now] += size[go[i]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:12:5: note: 'int size [524290]' 12 | int size[MAXN]; | ^~~~ a.cc:33:15: error: reference to 'size' is ambiguous 33 | a[n - size[now]] --; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:12:5: note: 'int size [524290]' 12 | int size[MAXN]; | ^~~~ a.cc:35:40: error: reference to 'next' is ambiguous 35 | for(int i = first[now]; i; i = next[i]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:13:18: note: 'int next [524290]' 13 | int first[MAXN], next[MAXN], go[MAXN], t, pre[MAXN]; | ^~~~ a.cc:36:37: error: reference to 'size' is ambiguous 36 | if (go[i] != las) a[size[go[i]]] --; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:12:5: note: 'int size [524290]' 12 | int size[MAXN]; | ^~~~
s685983040
p03991
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e6+10,p=924844033; int inc(int x,int y){x+=y;return x>=p?x-p:x;} int dec(int x,int y){x-=y;return x<0?x+p:x;} int mul(int x,int y){return (ll)x*y%p;} int power(int x,int y){ int ans=1; for (;y;y>>=1,x=mul(x,x)) if (y&1) ans=mul(ans,x); return ans; } int w[N],iw[N]; void init(int n){ w[0]=1;w[1]=power(5,(p-1)/n); for (int i=2;i<=n;i++) w[i]=mul(w[i-1],w[1]); for (int i=0;i<=n;i++) iw[i]=w[n-i]; } void fft(int n,int *a,int *w){ for (int i=0,j=0;i<n;i++){ if (i<j) swap(a[i],a[j]); for (int k=n>>1;(j^=k)<k;k>>=1); } for (int i=2;i<=n;i<<=1){ int m=i>>1,step=n/i; for (int j=0;j<n;j+=i) for (int k=0,pos=0;k<m;k++,pos+=step){ int t=mul(a[j+k+m],w[pos]); a[j+k+m]=dec(a[j+k],t); a[j+k]=inc(a[j+k],t); } } if (w==iw){ int del=power(n,p-2); for (int i=0;i<n;i++) a[i]=mul(a[i],del); } } int n,e[N],head[N],next[N]; void add(int f,int t){ static int cnt=0; e[++cnt]=t; next[cnt]=head[f]; head[f]=cnt; } int size[N]; void dfs(int x,int fa){ size[x]=1; for (int i=head[x];i;i=next[i]){ int v=e[i]; if (v==fa) continue; dfs(v,x); size[x]+=size[v]; } } int cnt[N],fac[N],ifac[N],f[N],g[N]; int main() { scanf("%d",&n); for (int i=1;i<n;i++){ int u,v; scanf("%d%d",&u,&v); add(u,v);add(v,u); } dfs(1,0); cnt[n]=n; for (int i=2;i<=n;i++) cnt[size[i]]--,cnt[n-size[i]]--; for (int i=1;i<=n;i++) if (cnt[i]<0) cnt[i]+=p; fac[0]=1; for (int i=1;i<=n;i++) fac[i]=mul(fac[i-1],i); ifac[n]=power(fac[n],p-2); for (int i=n;i;i--) ifac[i-1]=mul(ifac[i],i); for (int i=0;i<=n;i++) g[i]=mul(cnt[i],fac[i]),f[i]=ifac[n-i]; int size=1; while (size<=n+n) size<<=1; init(size); fft(size,f,w);fft(size,g,w); for (int i=0;i<size;i++) f[i]=mul(f[i],g[i]); fft(size,f,iw); for (int i=1;i<=n;i++) printf("%d\n",mul(f[i+n],ifac[i])); return 0; }
a.cc: In function 'void add(int, int)': a.cc:43:5: error: reference to 'next' is ambiguous 43 | next[cnt]=head[f]; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:39:20: note: 'int next [1000010]' 39 | int n,e[N],head[N],next[N]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:48:5: error: reference to 'size' is ambiguous 48 | size[x]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:46:5: note: 'int size [1000010]' 46 | int size[N]; | ^~~~ a.cc:49:28: error: reference to 'next' is ambiguous 49 | for (int i=head[x];i;i=next[i]){ | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:39:20: note: 'int next [1000010]' 39 | int n,e[N],head[N],next[N]; | ^~~~ a.cc:53:9: error: reference to 'size' is ambiguous 53 | size[x]+=size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:46:5: note: 'int size [1000010]' 46 | int size[N]; | ^~~~ a.cc:53:18: error: reference to 'size' is ambiguous 53 | size[x]+=size[v]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:46:5: note: 'int size [1000010]' 46 | int size[N]; | ^~~~ a.cc: In function 'int main()': a.cc:68:13: error: reference to 'size' is ambiguous 68 | cnt[size[i]]--,cnt[n-size[i]]--; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:46:5: note: 'int size [1000010]' 46 | int size[N]; | ^~~~ a.cc:68:30: error: reference to 'size' is ambiguous 68 | cnt[size[i]]--,cnt[n-size[i]]--; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:46:5: note: 'int size [1000010]' 46 | int size[N]; | ^~~~
s756818142
p03991
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #define N 200005 #define M 524289 #define LL long long #define oo (1<<30) #define V 32768 #define LD long double using namespace std; const int mo=924844303; const LD Pi=acos(-1.0); int n,m,head[N],num[2*N],next[2*N],ans[N],fc[N],xf[N],sz[N],a[N],b[N],e,ep; void inc(int &x,int y){ x+=y; if(x>=mo) x-=mo;} LL fpm(LL x,LL y) { LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1 , x=(x*x)%mo; } return s; } void dfs(int t,int fa) { int i; sz[t]=1; for(i=head[t];i;i=next[i]) if(num[i]!=fa){ dfs(num[i],t); sz[t]+=sz[num[i]]; } } struct cp{ LD x,y; cp(LD _x=0,LD _y=0){ x=_x,y=_y;} }A[M],B[M],C[M],D[M],tmp[M],F[M]; cp operator +(cp p,cp q){ return cp(p.x+q.x,p.y+q.y);} cp operator -(cp p,cp q){ return cp(p.x-q.x,p.y-q.y);} cp operator *(cp p,double r){ return cp(p.x*r,p.y*r);} cp operator *(double r,cp p){ return cp(p.x*r,p.y*r);} cp operator *(cp p,cp q){ return cp(p.x*q.x-p.y*q.y,p.x*q.y+p.y*q.x);} int rev(int x) { int i,y=0; for(i=0;i<ep;i++) y+=((x>>i)&1)*(1<<(ep-i-1)); return y; } void FFT(cp *x,int op) { int i,j,k; cp p,q,w,wn; for(i=0;i<e;i++) tmp[i]=x[i]; for(i=0;i<e;i++) x[i]=tmp[rev(i)]; for(i=1;i<=e;i<<=1){ wn=cp(cos(2*Pi*op/i),sin(2*Pi*op/i)); for(j=0;j<e;j+=i){ w=cp(1,0); for(k=0;k<i/2;k++){ p=x[j+k],q=x[j+k+i/2]*w; x[j+k]=p+q,x[j+k+i/2]=p-q; w=w*wn; } } } } LL com(int n,int m) { return 1LL*fc[n]*xf[m]%mo*xf[n-m]%mo; } int main() { int i,x,y; scanf("%d",&n); for(i=1;i<n;i++){ scanf("%d %d",&x,&y); num[++m]=y,next[m]=head[x],head[x]=m; num[++m]=x,next[m]=head[y],head[y]=m; } dfs(1,0),fc[0]=xf[0]=1; for(i=1;i<=n;i++){ fc[i]=(1LL*fc[i-1]*i)%mo; xf[i]=fpm(fc[i],mo-2); } for(i=1;i<=n;i++){ (a[sz[i]]+=fc[sz[i]])%=mo; (a[n-sz[i]]+=fc[n-sz[i]])%=mo; } for(i=0;i<=n;i++) b[i]=xf[n-i]; a[0]=b[0]=0; for(e=1,ep=0;e<=2*n;e<<=1,ep++); for(i=0;i<=n;i++){ A[i].x=a[i]/V,B[i].x=a[i]%V; C[i].x=b[i]/V,D[i].x=b[i]%V; } FFT(A,1),FFT(B,1); FFT(C,1),FFT(D,1); for(i=0;i<e;i++) F[i]=A[i]*C[i]; FFT(F,-1); for(i=n+1;i<=2*n;i++) ans[i-n]=(ans[i-n]+(LL)(F[i].x/e+0.5)%mo*V%mo*V)%mo; for(i=0;i<e;i++) F[i]=B[i]*D[i]; FFT(F,-1); for(i=n+1;i<=2*n;i++) ans[i-n]=(ans[i-n]+(LL)(F[i].x/e+0.5))%mo; for(i=0;i<e;i++) F[i]=A[i]*D[i]; FFT(F,-1); for(i=n+1;i<=2*n;i++) ans[i-n]=(ans[i-n]+(LL)(F[i].x/e+0.5)%mo*V)%mo; for(i=0;i<e;i++) F[i]=B[i]*C[i]; FFT(F,-1); for(i=n+1;i<=2*n;i++) ans[i-n]=(ans[i-n]+(LL)(F[i].x/e+0.5)%mo*V)%mo; for(i=1;i<=n;i++){ ans[i]=(1LL*ans[i]*xf[i])%mo; ans[i]=(1LL*(n+1)*com(n,i)-ans[i]+mo)%mo; } for(i=1;i<=n;i++) printf("%d\n",ans[i]); return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:30:27: error: reference to 'next' is ambiguous 30 | for(i=head[t];i;i=next[i]) | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:16:26: note: 'int next [400010]' 16 | int n,m,head[N],num[2*N],next[2*N],ans[N],fc[N],xf[N],sz[N],a[N],b[N],e,ep; | ^~~~ a.cc: In function 'int main()': a.cc:79:28: error: reference to 'next' is ambiguous 79 | num[++m]=y,next[m]=head[x],head[x]=m; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:16:26: note: 'int next [400010]' 16 | int n,m,head[N],num[2*N],next[2*N],ans[N],fc[N],xf[N],sz[N],a[N],b[N],e,ep; | ^~~~ a.cc:80:28: error: reference to 'next' is ambiguous 80 | num[++m]=x,next[m]=head[y],head[y]=m; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:16:26: note: 'int next [400010]' 16 | int n,m,head[N],num[2*N],next[2*N],ans[N],fc[N],xf[N],sz[N],a[N],b[N],e,ep; | ^~~~
s866878556
p03991
C++
//ProblemF.cpp #include <iostream> static std::istream & ip = std::cin; static std::ostream & op = std::cout; #if OJ_MYPC #include <ojio.h> #endif #ifndef OPENOJIO #define OPENOJIO #endif #if 1 || DEFINE /***************************************************************/ typedef unsigned long long u64; typedef long long s64; typedef unsigned uint; #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN3(x, y, z) MIN(x, MIN(y, z)) #define MAX3(x, y, z) MAX(x, MAX(y, z)) #define FillZero(arr) memset(arr, 0, sizeof(arr)); /***************************************************************/ #endif //1 || DEFINE #include <string> #include <vector> #include <map> #include <set> #include <bitset> #include <queue> #include <stack> #include <utility> #include <algorithm> #include <iomanip> #include <cstring> #include <cmath> #include <cstdio> #include <functional> #include <assert.h> //001 //op << setfill('0') << setw(3) << setiosflags(ios::right) << 1; //op << fixed << setprecision(20); using namespace std; //ProblemF.cpp #define MAXN 200010 #define MOD 924844033LL #define N (1 << 19) #define W 10179 template<int _MOD> class ModInt { public: static const int Mod = _MOD; private: unsigned x; public: ModInt() : x(0) {} ModInt(int sig) { int sigt = sig % Mod; if (sigt < 0) sigt += Mod; x = sigt; } ModInt(long long sig) { int sigt = sig % Mod; if (sigt < 0) sigt += Mod; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(const ModInt& b) { if ((x += b.x) >= Mod) x -= Mod; return *this; } ModInt &operator-=(const ModInt& b) { if ((x += Mod - b.x) >= Mod) x -= Mod; return *this; } ModInt &operator*=(const ModInt& b) { x = (unsigned long long)x * b.x % Mod; return *this; } ModInt &operator/=(const ModInt& b) { return *this *= b.inverse(); } friend ModInt operator+ (const ModInt& a, const ModInt& b) { return ModInt(a) += b; } friend ModInt operator- (const ModInt& a, const ModInt& b) { return ModInt(a) -= b; } friend ModInt operator* (const ModInt& a, const ModInt& b) { return ModInt(a) *= b; } friend ModInt operator/ (const ModInt& a, const ModInt& b) { return ModInt(a) /= b; } friend bool operator== (const ModInt& a, const ModInt& b) { return a.get() == b.get(); } friend bool operator!= (const ModInt& a, const ModInt& b) { return a.get() != b.get(); } friend std::ostream& operator<<(std::ostream& ostr, const ModInt & a) { return ostr << a.get(); } friend std::istream& operator >> (std::istream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } ModInt pow(unsigned long long p) const { ModInt a = *this; ModInt rst = 1; while (p) { if (p & 1) rst *= a; p >>= 1; a *= a; } return rst; } ModInt inverse() const { signed a = x, b = Mod, u = 1, v = 0; while (b) { signed t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } }; template<typename Type> class FFT { public: const int n; const Type w; public: FFT(int n, Type w) : n(n), w(w) { assert(n > 0); Type wk = (Type)1; for (int i = 1; i < n; ++i) { wk *= w; assert(wk != (Type)1); } assert(wk * w == (Type)1); for (--n; n; n >>= 1) assert(n & 1); } void calc(std::vector<Type>& rst, const std::vector<Type>& p, int ope = 1) { assert(p.size() <= n); rst = p; calc(rst, inv); } void calc(vector<Type>& p, int ope = 1) { assert((int)p.size() <= n); p.resize(n, 0); Type ww = ope > 0 ? w : 1 / w; for (int m = n, mi = 0; m >= 2; m >>= 1, mi++) { int mh = m >> 1; Type wc = (Type)1; for (int i = 0; i < mh; ++i) { for (int j = i; j < n; j += m) { int k = j + mh; Type tmp = p[j] - p[k]; p[j] += p[k]; p[k] = wc * tmp; } wc *= ww; } ww *= ww; } int i = 0; for (int j = 1; j < n - 1; ++j) { for (int k = n >> 1; k >(i ^= k); k >>= 1); if (j < i) std::swap(p[i], p[j]); } } }; int main(int argc, char* argv[]) { OPENOJIO; typedef ModInt<MOD> mint; static mint fac[MAXN + 1]; fac[0] = fac[1] = 1; for (int i = 2; i <= MAXN; ++i) fac[i] = fac[i - 1] * i; static mint fac_inv[MAXN + 1]; for (int i = 0; i <= MAXN; ++i) { fac_inv[i] = 1 / fac[i]; assert(fac_inv[i] * fac[i] == 1); } int n; vector<vector<int> > nears; ip >> n; nears.resize(n); for (int i = 0; i < n - 1; ++i) { int a, b; ip >> a >> b; --a; --b; nears[a].push_back(b); nears[b].push_back(a); } vector<int> count_sons; count_sons.resize(n, 0); function<int (int, int)> get_count_sons = [&] (int cur, int father) -> int { count_sons[cur] = 1; for (auto son : nears[cur]) { if (son == father) continue; count_sons[cur] += get_count_sons(son, cur); } return count_sons[cur]; }; get_count_sons(0, -1); vector<int> b; b.resize(n, 0); for (int i = 1; i < n; ++i) { b[count_sons[i]]++; b[n - count_sons[i]]++; } vector<mint> c(N, 0); vector<mint> d(N, 0); for (int i = 0; i < n; ++i) c[i] = b[i] * fac[i]; d[0] = 1; for (int i = 1; i < n; ++i) d[N - i] = fac_inv[i]; FFT<mint> fft(N, W); fft.calc(c); fft.calc(d); for (int i = 0; i < c.size(); ++i) c[i] *= d[i]; fft.calc(c, -1); mint N_inv = (mint)1 / N; assert(N * N_inv == 1); for (int i = 0; i < c.size(); ++i) c[i] *= N_inv; vector<mint> &rst = d; for (int i = 1; i <= n; ++i) { rst[i] = n * fac[n] * fac_inv[i] * fac_inv[n - i] - fac_inv[i] * c[i]; } for (int i = 1; i <= n; ++i) { op << rst[i] << endl; } return 0; } /***************************************************************/
a.cc: In member function 'void FFT<Type>::calc(std::vector<_Tp>&, const std::vector<_Tp>&, int)': a.cc:142:27: error: 'inv' was not declared in this scope; did you mean 'int'? 142 | calc(rst, inv); | ^~~ | int
s579279944
p03991
C++
//ProblemF.cpp #include <iostream> static std::istream & ip = std::cin; static std::ostream & op = std::cout; #if OJ_MYPC #include <ojio.h> #endif #ifndef OPENOJIO #define OPENOJIO #endif #if 1 || DEFINE /***************************************************************/ typedef unsigned long long u64; typedef long long s64; typedef unsigned uint; #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN3(x, y, z) MIN(x, MIN(y, z)) #define MAX3(x, y, z) MAX(x, MAX(y, z)) #define FillZero(arr) memset(arr, 0, sizeof(arr)); /***************************************************************/ #endif //1 || DEFINE #include <string> #include <vector> #include <map> #include <set> #include <bitset> #include <queue> #include <stack> #include <utility> #include <algorithm> #include <iomanip> #include <cstring> #include <cmath> #include <cstdio> #include <functional> #include <assert.h> //001 //op << setfill('0') << setw(3) << setiosflags(ios::right) << 1; //op << fixed << setprecision(20); using namespace std; //ProblemF.cpp #define MAXN 200010 #define MOD 924844033LL #define N (1 << 19) #define W 10179 template<int _MOD> class ModInt { public: static const int Mod = _MOD; private: unsigned x; public: ModInt() : x(0) {} ModInt(int sig) { int sigt = sig % Mod; if (sigt < 0) sigt += Mod; x = sigt; } ModInt(long long sig) { int sigt = sig % Mod; if (sigt < 0) sigt += Mod; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(const ModInt& b) { if ((x += b.x) >= Mod) x -= Mod; return *this; } ModInt &operator-=(const ModInt& b) { if ((x += Mod - b.x) >= Mod) x -= Mod; return *this; } ModInt &operator*=(const ModInt& b) { x = (unsigned long long)x * b.x % Mod; return *this; } ModInt &operator/=(const ModInt& b) { return *this *= b.inverse(); } friend ModInt operator+ (const ModInt& a, const ModInt& b) { return ModInt(a) += b; } friend ModInt operator- (const ModInt& a, const ModInt& b) { return ModInt(a) -= b; } friend ModInt operator* (const ModInt& a, const ModInt& b) { return ModInt(a) *= b; } friend ModInt operator/ (const ModInt& a, const ModInt& b) { return ModInt(a) /= b; } friend bool operator== (const ModInt& a, const ModInt& b) { return a.get() == b.get(); } friend bool operator!= (const ModInt& a, const ModInt& b) { return a.get() != b.get(); } friend std::ostream& operator<<(std::ostream& ostr, const ModInt & a) { return ostr << a.get(); } friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } ModInt pow(unsigned long long p) const { ModInt a = *this; ModInt rst = 1; while (p) { if (p & 1) rst *= a; p >>= 1; a *= a; } return rst; } ModInt inverse() const { signed a = x, b = Mod, u = 1, v = 0; while (b) { signed t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } }; template<typename Type> class FFT { public: const int n; const Type w; public: FFT(int n, Type w) : n(n), w(w) { assert(n > 0); Type wk = (Type)1; for (int i = 1; i < n; ++i) { wk *= w; assert(wk != (Type)1); } assert(wk * w == (Type)1); for (--n; n; n >>= 1) assert(n & 1); } void calc(std::vector<Type>& rst, const std::vector<Type>& p, int ope = 1) { assert(p.size() <= n); rst = p; calc(rst, inv); } void calc(vector<Type>& p, int ope = 1) { assert((int)p.size() <= n); p.resize(n, 0); Type ww = ope > 0 ? w : 1 / w; for (int m = n, mi = 0; m >= 2; m >>= 1, mi++) { int mh = m >> 1; Type wc = (Type)1; for (int i = 0; i < mh; ++i) { for (int j = i; j < n; j += m) { int k = j + mh; Type tmp = p[j] - p[k]; p[j] += p[k]; p[k] = wc * tmp; } wc *= ww; } ww *= ww; } int i = 0; for (int j = 1; j < n - 1; ++j) { for (int k = n >> 1; k >(i ^= k); k >>= 1); if (j < i) std::swap(p[i], p[j]); } } }; int main(int argc, char* argv[]) { OPENOJIO; typedef ModInt<MOD> mint; static mint fac[MAXN + 1]; fac[0] = fac[1] = 1; for (int i = 2; i <= MAXN; ++i) fac[i] = fac[i - 1] * i; static mint fac_inv[MAXN + 1]; for (int i = 0; i <= MAXN; ++i) { fac_inv[i] = 1 / fac[i]; assert(fac_inv[i] * fac[i] == 1); } int n; vector<vector<int> > nears; ip >> n; nears.resize(n); for (int i = 0; i < n - 1; ++i) { int a, b; ip >> a >> b; --a; --b; nears[a].push_back(b); nears[b].push_back(a); } vector<int> count_sons; count_sons.resize(n, 0); function<int (int, int)> get_count_sons = [&] (int cur, int father) -> int { count_sons[cur] = 1; for (auto son : nears[cur]) { if (son == father) continue; count_sons[cur] += get_count_sons(son, cur); } return count_sons[cur]; }; get_count_sons(0, -1); vector<int> b; b.resize(n, 0); for (int i = 1; i < n; ++i) { b[count_sons[i]]++; b[n - count_sons[i]]++; } vector<mint> c(N, 0); vector<mint> d(N, 0); for (int i = 0; i < n; ++i) c[i] = b[i] * fac[i]; d[0] = 1; for (int i = 1; i < n; ++i) d[N - i] = fac_inv[i]; FFT<mint> fft(N, W); fft.calc(c); fft.calc(d); for (int i = 0; i < c.size(); ++i) c[i] *= d[i]; fft.calc(c, -1); mint N_inv = (mint)1 / N; assert(N * N_inv == 1); for (int i = 0; i < c.size(); ++i) c[i] *= N_inv; vector<mint> &rst = d; for (int i = 1; i <= n; ++i) { rst[i] = n * fac[n] * fac_inv[i] * fac_inv[n - i] - fac_inv[i] * c[i]; } for (int i = 1; i <= n; ++i) { op << rst[i] << endl; } return 0; } /***************************************************************/
a.cc: In function 'std::istream& operator>>(std::ostream&, const ModInt<_MOD>&)': a.cc:95:105: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'long long int') 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ~~~~ ^~ ~ | | | | | long long int | std::ostream {aka std::basic_ostream<char>} a.cc:95:105: note: candidate: 'operator>>(int, long long int)' (built-in) 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ~~~~~^~~~ a.cc:95:105: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int' In file included from /usr/include/c++/14/string:55, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 835 | operator>>(basic_istream<_CharT, _Traits>& __in, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)' 131 | operator>>(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed: a.cc:95:100: note: cannot convert 'istr' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^~~~ In file included from /usr/include/c++/14/istream:1109, from /usr/include/c++/14/iostream:42: /usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)' 978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) | ^~~~~~~~ /usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)' 849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) | ^~~~~~~~ /usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)' 854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c) | ^~~~~~~~ /usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)' 896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)' 939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)' 945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s) | ^~~~~~~~ /usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)' 1099 | operator>>(_Istream&& __is, _Tp&& __x) | ^~~~~~~~ /usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed: /usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = long long int&]': a.cc:95:101: required from here 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ /usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 1099 | operator>>(_Istream&& __is, _Tp&& __x) | ^~~~~~~~ In file included from a.cc:40: /usr/include/c++/14/bitset:1597:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, bitset<_Nb>&)' 1597 | operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) | ^~~~~~~~ /usr/include/c++/14/bitset:1597:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 95 | friend std::istream& operator >> (std::ostream& istr, const ModInt & a) { long long t; if (istr >> t) a = t; return istr; } | ^ In file included from a.cc:45: /usr/include/c++/14/iomanip:76:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Resetiosflags)' 76 | operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f) | ^~~~~~~~ /usr/include/c++/14/iomanip:76:5: note: template argument deduction/substitution failed: a.cc:95:108: note: 'std::ostream' {aka
s072199212
p03991
C++
#include <math.h> #include <stdio.h> #include <string.h> #include <vector> #include <string> #include <queue> #include <map> #include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <set> using namespace std; const int mmod = 924844033; vector<vector<int> > G; vector<int> sz; vector<int> parent; const int max_n = 499999; int fac[max_n], inv_fac[max_n]; int inv_mod(int a, int b) { if (a == 1) return b; int div = mmod / a + 1; return inv_mod((a * (long long)div) % mmod, (b * (long long)div) % mmod); } void go(int now, int prv) { sz[now] = 1; parent[now] = prv; for (int i=0; i<G[now].size(); i++) { if (prv == G[now][i]) continue; go(G[now][i], now); sz[now] += sz[G[now][i]]; } // printf("sz[%d] = %d %d\n", now, sz[now], parent[now]); } long long combi(int a, int b) { if (b < 0 || b > a) return 0; long long res = fac[a]; res = (res * inv_fac[b]) % mmod; res = (res * inv_fac[a-b]) % mmod; return res; } long long partial_combi(int a, int b) { if (b < 0 || b > a) return 0; long long res = fac[a]; // res = (res * inv_fac[b]) % mmod; res = (res * inv_fac[a-b]) % mmod; return res; } int main() { int N; cin >> N; G.resize(N); sz.resize(N); parent.resize(N); for (int i=0; i<N-1; i++) { int a, b; cin >> a >> b; a --; b --; G[a].push_back(b); G[b].push_back(a); } go(0, -1); map<int, int> M; for (int i=0; i<N; i++) { int remain = N-1; for (int j=0; j<G[i].size(); j++) { int ssz = sz[G[i][j]]; if (G[i][j] == parent[i]) continue; remain -= ssz; M[ssz] ++; } if (remain) M[remain] ++; } vector<int> what ,occ; for (auto a : M) { // printf("%d %d\n", a.first, a.second); what.push_back(a.first); occ.push_back(a.second); } fac[0] = inv_fac[0] = 1; for (int i=1; i<max_n; i++) { fac[i] = (fac[i-1] * 1LL * i) % mmod; inv_fac[i] = inv_mod(fac[i], 1); } for (int K=1; K<=N; K++) { int res = 0; for (int idx = 0; idx < what.size(); idx ++) { int ww = what[idx]; int oo = occ[idx]; res = (res - 1LL * partial_combi(ww, K) * oo) % mmod; } res = (res * inv_fac[b]) % mmod; res = (res + 1LL * combi(N, K) * N) % mmod; res = (res + mmod) % mmod; printf("%lld\n", res); } }
a.cc: In function 'int main()': a.cc:106:26: error: 'b' was not declared in this scope 106 | res = (res * inv_fac[b]) % mmod; | ^
s127985486
p03991
C++
#include <math.h> #include <stdio.h> #include <string.h> #include <vector> #include <string> #include <queue> #include <map> #include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <set> using namespace std; const int mmod = 924844033; vector<vector<int> > G; vector<int> sz; vector<int> parent; const int max_n = 499999; int fac[max_n], inv_fac[max_n]; int inv_mod(int a, int b) { if (a == 1) return b; int div = mmod / a + 1; return inv_mod((a * (long long)div) % mmod, (b * (long long)div) % mmod); } void go(int now, int prv) { sz[now] = 1; parent[now] = prv; for (int i=0; i<G[now].size(); i++) { if (prv == G[now][i]) continue; go(G[now][i], now); sz[now] += sz[G[now][i]]; } // printf("sz[%d] = %d %d\n", now, sz[now], parent[now]); } long long combi(int a, int b) { if (b < 0 || b > a) return 0; long long res = fac[a]; res = (res * inv_fac[b]) % mmod; res = (res * inv_fac[a-b]) % mmod; return res; } long long partial_combi(int a, int b) { if (b < 0 || b > a) return 0; long long res = fac[a]; // res = (res * inv_fac[b]) % mmod; res = (res * inv_fac[a-b]) % mmod; return res; } int main() { int N; cin >> N; G.resize(N); sz.resize(N); parent.resize(N); for (int i=0; i<N-1; i++) { int a, b; cin >> a >> b; a --; b --; G[a].push_back(b); G[b].push_back(a); } go(0, -1); map<int, int> M; for (int i=0; i<N; i++) { int remain = N-1; for (int j=0; j<G[i].size(); j++) { int ssz = sz[G[i][j]]; if (G[i][j] == parent[i]) continue; remain -= ssz; M[ssz] ++; } if (remain) M[remain] ++; } vector<int> what ,occ; for (auto a : M) { // printf("%d %d\n", a.first, a.second); what.push_back(a.first); occ.push_back(a.second); } fac[0] = inv_fac[0] = 1; for (int i=1; i<max_n; i++) { fac[i] = (fac[i-1] * 1LL * i) % mmod; inv_fac[i] = inv_mod(fac[i], 1); } for (int K=1; K<=N; K++) { for (int idx = 0; idx < what.size(); idx ++) { int ww = what[idx]; int oo = occ[idx]; res = (res - 1LL * partial_combi(ww, K) * oo) % mmod; } res = (res * inv_fac[b]) % mmod; res = (res + 1LL * combi(N, K) * N) % mmod; res = (res + mmod) % mmod; printf("%lld\n", res); } }
a.cc: In function 'int main()': a.cc:103:7: error: 'res' was not declared in this scope 103 | res = (res - 1LL * partial_combi(ww, K) * oo) % mmod; | ^~~ a.cc:105:5: error: 'res' was not declared in this scope 105 | res = (res * inv_fac[b]) % mmod; | ^~~ a.cc:105:26: error: 'b' was not declared in this scope 105 | res = (res * inv_fac[b]) % mmod; | ^
s379425389
p03992
C++
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; printf("%s %s",s.substr(0,4),s.substr(4)) }
a.cc: In function 'int main()': a.cc:7:46: error: expected ';' before '}' token 7 | printf("%s %s",s.substr(0,4),s.substr(4)) | ^ | ; 8 | } | ~
s753772365
p03992
C++
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define pb push_back using ll = long long; using vin=vector<int>; using vll=vector<ll>; using vst=vector<string>; using P = pair<ll,ll>; const int inf=1e9+7; const ll INF=9e18; template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;} template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;} template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; int main(){cout<<fixed<<setprecision(20); string s; cin>>s; rep(i,0,4)cout<<s[i]; cout<<" "; rep(0,4,12)cout<<s[i]; cout<<endl; }
a.cc: In function 'int main()': a.cc:28:16: error: expected unqualified-id before numeric constant 28 | rep(0,4,12)cout<<s[i]; | ^ a.cc:4:35: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^ a.cc:28:16: error: expected ';' before numeric constant 28 | rep(0,4,12)cout<<s[i]; | ^ a.cc:4:35: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^ a.cc:28:16: error: lvalue required as left operand of assignment 28 | rep(0,4,12)cout<<s[i]; | ^ a.cc:4:35: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^ a.cc:4:53: error: expected ')' before ';' token 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ~ ^ a.cc:28:12: note: in expansion of macro 'rep' 28 | rep(0,4,12)cout<<s[i]; | ^~~ a.cc:28:16: error: lvalue required as increment operand 28 | rep(0,4,12)cout<<s[i]; | ^ a.cc:4:57: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^
s318555844
p03992
C++
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define pb push_back using ll = long long; using vin=vector<int>; using vll=vector<ll>; using vst=vector<string>; using P = pair<ll,ll>; const int inf=1e9+7; const ll INF=9e18; template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;} template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;} template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; int main(){cout<<fixed<<setprecision(20); string s; cin>>s; rep(i,0,4)cout<<s[i]; cout<<" "; rep(0,4,12)cout<<s[i]<<endl; }
a.cc: In function 'int main()': a.cc:28:16: error: expected unqualified-id before numeric constant 28 | rep(0,4,12)cout<<s[i]<<endl; | ^ a.cc:4:35: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^ a.cc:28:16: error: expected ';' before numeric constant 28 | rep(0,4,12)cout<<s[i]<<endl; | ^ a.cc:4:35: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^ a.cc:28:16: error: lvalue required as left operand of assignment 28 | rep(0,4,12)cout<<s[i]<<endl; | ^ a.cc:4:35: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^ a.cc:4:53: error: expected ')' before ';' token 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ~ ^ a.cc:28:12: note: in expansion of macro 'rep' 28 | rep(0,4,12)cout<<s[i]<<endl; | ^~~ a.cc:28:16: error: lvalue required as increment operand 28 | rep(0,4,12)cout<<s[i]<<endl; | ^ a.cc:4:57: note: in definition of macro 'rep' 4 | #define rep(i, from, to) for (int i = from; i < (to); ++i) | ^
s238392266
p03992
C++
#include <bits/stdc++.h> using namespace std; int main(){ string S; cin>>S; for(int i=0;i<12;i++){ cout<<S[i]; if(i==3){ cout<<" "; break; } } for(int i=4;i<=12;i++){ cout<<S[i];    } cout<<endl; }
a.cc:15:1: error: extended character   is not valid in an identifier 15 |    } | ^ a.cc:15:1: error: extended character   is not valid in an identifier a.cc:15:1: error: extended character   is not valid in an identifier a.cc: In function 'int main()': a.cc:15:1: error: '\U00003000\U00003000\U00003000' was not declared in this scope 15 |    } | ^~~~~~
s426040377
p03992
C++
#include <bits/stdc++.h> #include <vector> #include <algorithm> #include <iostream> using namespace std; int main() { string s; cin >> s; cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << ' ' << s.at(4) << s,at(5) << s.at(6) << s.at(7) << s.at(8) << s.at(9) << s.at(10) << s.at(11) << endl; }
a.cc: In function 'int main()': a.cc:10:75: error: 'at' was not declared in this scope 10 | cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << ' ' << s.at(4) << s,at(5) << s.at(6) << s.at(7) << s.at(8) << s.at(9) << s.at(10) << s.at(11) << endl; | ^~
s659050904
p03992
C++
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; for(int i=0;i<=3;i++){ cout<<s[i]; } cout<<" "; for(int i=4;i<=s.size()){ cout<<s[i]; } cout<<endl; }
a.cc: In function 'int main()': a.cc:11:26: error: expected ';' before ')' token 11 | for(int i=4;i<=s.size()){ | ^ | ;
s969122687
p03992
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); char[] ch=sc.next().toCharArray(); StringBuffer sb=new StringBuffer(); for(int i=0;i<12;i++){ if(i=3){ sb.append(ch[i]+" "); }else{ sb.append(ch[i]); } } System.out.println(sb); } }
Main.java:8: error: incompatible types: int cannot be converted to boolean if(i=3){ ^ 1 error