submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s032876341
p04050
C++
#include<bits\stdc++.h> using namespace std; typedef long long ll; ll qread() { ll ans=0;char c=getchar(); while(c<'0' or c>'9') c=getchar(); while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar(); return ans; } void write(ll num) { if(num>9) write(num%10); putchar('0'+num%10); } void writeln(ll num) {write(num);puts("");} #define pr pair<int,int> #define FR first #define SE second #define MP make_pair #define PB push_back const int INF=0x3f3f3f3f; void chmax(int &x,int y) {x=x>y?x:y;} const int MAX_N=110; int a[MAX_N]; int main() { int n=qread(),m=qread(); int cnt=0;for(int i=1;i<=m;i++) cnt+=(a[i]=qread())&1; if(m==1) {printf("%d\n2\n%d 1",a[1],a[1]-1);return 0;} if(cnt>2) {puts("Impossible");return 0;} for(int i=1;i<=m;i++) if((a[i]&1)==1) { for(int j=i-1;j>=1;j--) swap(a[j],a[j+1]); break; } for(int i=2;i<=m;i++) if((a[i]&1)==1) { for(int j=i+1;j<=m;j++) swap(a[j-1],a[j]); break; } for(int i=1;i<=m;i++) printf("%d ",a[i]);puts(""); if(a[1]==1) { writeln(m-1); for(int i=2;i<=m;i++) printf("%d ",a[i]+(i==m)); } else { writeln(m);printf("%d ",a[1]-1); for(int i=2;i<=m;i++) printf("%d ",a[i]+(i==m)); } }
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s592302713
p04050
C++
#include <bits/stdc++.h> using namespace std; int cl = 0, n, m; int a[102], b[102]; set<int> ke; signed main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d", &a[i]); if (a[i] % 2) cl++; if (a[i] % 2) ke.insert(a[i]); } if (m == 1) { cout << a[1] << "\n2\n"; cout << a[1] - 1 << ' ' << 1; return 0; } if (m == 2) { cout << a[1] << ' ' << a[2] << "\n2\n"; cout << a[1] - 1 << ' ' << a[2] + 1; return 0; } if (cl > 2) { cout << "Impossible"; return 0; } else { int it = 1; if (ke.size()) { cout << *ke.begin() << ' '; b[it] = *ke.begin(); it++; } for (int i = 1; i <= m; i++) { if (ke.find(a[i]) == ke.end()) { cout << a[i] << ' '; b[it] = a[i]; it++; } } if (ke.size()) { ke.erase(ke.begin()); if (!ke.size()) break; cout << *ke.begin(); b[it] = *ke.begin(); } cout << '\n'; cout << m << '\n'; b[1] --; b[m] ++; for (int i = 1; i <= m; i++) { cout << b[i] << ' '; } } }
a.cc: In function 'int main()': a.cc:45:29: error: break statement not within loop or switch 45 | if (!ke.size()) break; | ^~~~~
s010162125
p04050
C++
#include <vector> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(M); vector<int> odds; for (int i = 0; i < M; ++i) { cin >> A[i]; if (A[i] & 1) odds.push_back(A[i]); } if (odds.size() >= 3) { cout << "Impossible" << endl; } else if (N == 2) { cout << 2 << endl << 1 << endl << 2 << endl; } else if (odds.size() == 0) { int ptr = find(A.begin(), A.end(), N / 2 + 1) - A.begin(); if (ptr != M) { swap(A[0], A[ptr]); } for (int i = 0; i < M; ++i) { if (i) cout << ' '; cout << A[i]; } cout << endl; cout << 2 << endl << N - 1 << ' ' << 1 << endl; } else if (odds.size() == 1) { cout << odds[0]; for (int i : A) { if (!(i & 1)) cout << ' ' << i; } cout << endl; cout << (N + 1) / 2 << endl; for (int i = 0; i < N / 2; ++i) { cout << 2 << ' '; } cout << 1 << endl; } else { cout << odds[0]; for (int i : A) { if (!(i & 1)) cout << ' ' << i; } cout << odds[1] << endl; cout << N / 2 << endl; for (int i = 0; i < N / 2; ++i) { if (i) cout << ' '; cout << 2; } cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:31: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)' 20 | int ptr = find(A.begin(), A.end(), N / 2 + 1) - A.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:20:31: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >' 20 | int ptr = find(A.begin(), A.end(), N / 2 + 1) - A.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s955162565
p04050
C++
#include<cstdio> #include<algorithm> #include<iostream> #include<queue> #include<set> #define rep(i,s,t) for(register int i=s;i<=t;++i) #define _rep(i,s,t) for(register int i=s;i>=t;--i) #define Rep(i,s,t) for(register int i=s;i<t;++i) #define go(x) for(register int e=las[x];e;e=nxt[e]) #define re register #define fi first #define se second #define mp make_pair #define pb push_back #define pii pair<int,int> #define gi(x) read(x) #define gii(x,y) read(x),read(y) #define giii(x,y,z) read(x),read(y),read(z) #define ms(f,x) memset(f,x,sizeof f) #define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout) namespace IO{ #define gc getchar() #define pc(x) putchar(x) template<typename T>inline void read(T &x){ x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;} while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return; } template<typename T>inline void write(T x=0){ T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48); while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]); putchar('\n'); return; } } using IO::read; using IO::write; using namespace std; #define gi(x) read(x) typedef long long ll; const int N=1e5+11; int n,m; int a[N],b[N],top; int main(){ gii(n,m); int odd1=-1,odd2=-1; rep(i,1,m){ a[i]=read(); if(a[i]&1){ if(odd1==-1)odd1=i; else if(odd2==-1)odd2=i; else{ puts("Impossible"); return 0; } } } if(m==1){ if(a[1]==1)printf("1\n1\n1\n"); else printf("%d\n2\n1 %d\n",a[1],a[1]-1); return 0; } if(odd1!=-1)swap(a[1],a[odd1]); if(odd2!=-1)swap(a[m],a[odd2]); rep(i,1,m)printf("%d%c",a[i]," \n"[i==m]); if(a[m]==1){ printf("%d\n",m-1); printf("%d ",a[1]+1); rep(i,2,m-1) printf("%d ",a[i]); puts(""); return 0; } b[1]=a[1]+1; rep(i,2,m-1) b[i]=a[i]; b[m]=a[m]-1; printf("%d\n",m); rep(i,1,m) printf("%d%c",b[i]," \n"[i==m]); return 0; }
a.cc: In function 'int main()': a.cc:46:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 46 | rep(i,1,m){ | ^ a.cc:6:37: note: in definition of macro 'rep' 6 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:47:18: error: no matching function for call to 'read()' 47 | a[i]=read(); | ~~~~^~ a.cc:24:37: note: candidate: 'template<class T> void IO::read(T&)' 24 | template<typename T>inline void read(T &x){ | ^~~~ a.cc:24:37: note: candidate expects 1 argument, 0 provided a.cc:64:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 64 | rep(i,1,m)printf("%d%c",a[i]," \n"[i==m]); | ^ a.cc:6:37: note: in definition of macro 'rep' 6 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:68:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 68 | rep(i,2,m-1) | ^ a.cc:6:37: note: in definition of macro 'rep' 6 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:74:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 74 | rep(i,2,m-1) | ^ a.cc:6:37: note: in definition of macro 'rep' 6 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^ a.cc:78:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 78 | rep(i,1,m) | ^ a.cc:6:37: note: in definition of macro 'rep' 6 | #define rep(i,s,t) for(register int i=s;i<=t;++i) | ^
s234548704
p04050
C++
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<iomanip> #include<math.h> #include<bitset> #include<assert> using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;} #define ALL(v) v.begin(),v.end() #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end()); #define pb push_back int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, m; cin >> n >> m; vector<ll> a(m); REP(i,m) cin >> a[i]; ll cnt = 0; REP(i,m) if(a[i] % 2) cnt++; if(n % 2) { if(cnt > 1) { cout << "Impossible" << endl; return 0; } assert(false); ll buf = -1; vector<ll> ans1; vector<ll> ans2; REP(i,m) { if(a[i] % 2) buf = a[i]; else ans1.pb(a[i]); } ans1.pb(buf); REP(i,m) { if(i == 0) { ans2.pb(a[i] - 1); } else if(i == m - 1) { ans2.pb(a[i] + 1); } else ans2.pb(ans1[i]); } DUMP(ans1); cout << (ll)ans2.size() << endl; DUMP(ans2); return 0; } else { if(cnt > 2) { cout << "Impossible" << endl; return 0; } assert(false); if(cnt == 0) { vector<ll> ans1(m); REP(i,m) ans1[i] = a[i]; vector<ll> ans2; ans2.pb(1); REP(i,m) { if(i != m - 1) ans2.pb(ans1[i]); else ans2.pb(ans1[i] - 1); } DUMP(ans1); cout << (ll)ans2.size() << endl; DUMP(ans2); return 0; } if(cnt == 2) { vector<ll> ans1; P buf = P(-1, -1); REP(i,m) { if(a[i] % 2 == 0) ans1.pb(a[i]); else { if(buf.first == -1) buf.first = a[i]; else buf.second = a[i]; } } ans1.insert(ans1.begin(), buf.first); ans1.pb(buf.second); vector<ll> ans2; REP(i,m) { if(i == 0) { ans2.pb(a[i] + 1); } else if(i == m - 1) { ans2.pb(a[i]); } else { if(a[i] != 1) ans2.pb(a[i] - 1); } } DUMP(ans1); cout << (ll)ans2.size() << endl; DUMP(ans2); return 0; } } return 0; }
a.cc:9:9: fatal error: assert: No such file or directory 9 | #include<assert> | ^~~~~~~~ compilation terminated.
s089832190
p04050
C++
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<iomanip> #include<math.h> #include<bitset> using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;} #define ALL(v) v.begin(),v.end() #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end()); #define pb push_back int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, m; cin >> n >> m; vector<ll> a(m); REP(i,m) cin >> a[i]; ll cnt = 0; REP(i,m) if(a[i] % 2) cnt++; if(n % 2) { if(cnt > 1) { cout << "Impossible" << endl; return 0; } assert(false); ll buf = -1; vector<ll> ans1; vector<ll> ans2; REP(i,m) { if(a[i] % 2) buf = a[i]; else ans1.pb(a[i]); } ans1.pb(buf); REP(i,m) { if(i == 0) { ans2.pb(a[i] - 1); } else if(i == m - 1) { ans2.pb(a[i] + 1); } else ans2.pb(ans1[i]); } DUMP(ans1); cout << (ll)ans2.size() << endl; DUMP(ans2); return 0; } else { if(cnt > 2) { cout << "Impossible" << endl; return 0; } assert(false); if(cnt == 0) { vector<ll> ans1(m); REP(i,m) ans1[i] = a[i]; vector<ll> ans2; ans2.pb(1); REP(i,m) { if(i != m - 1) ans2.pb(ans1[i]); else ans2.pb(ans1[i] - 1); } DUMP(ans1); cout << (ll)ans2.size() << endl; DUMP(ans2); return 0; } if(cnt == 2) { vector<ll> ans1; P buf = P(-1, -1); REP(i,m) { if(a[i] % 2 == 0) ans1.pb(a[i]); else { if(buf.first == -1) buf.first = a[i]; else buf.second = a[i]; } } ans1.insert(ans1.begin(), buf.first); ans1.pb(buf.second); vector<ll> ans2; REP(i,m) { if(i == 0) { ans2.pb(a[i] + 1); } else if(i == m - 1) { ans2.pb(a[i]); } else { if(a[i] != 1) ans2.pb(a[i] - 1); } } DUMP(ans1); cout << (ll)ans2.size() << endl; DUMP(ans2); return 0; } } return 0; }
a.cc: In function 'int main()': a.cc:37:17: error: 'assert' was not declared in this scope 37 | assert(false); | ^~~~~~ a.cc:9:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 8 | #include<bitset> +++ |+#include <cassert> 9 | using namespace std; a.cc:63:17: error: 'assert' was not declared in this scope 63 | assert(false); | ^~~~~~ a.cc:63:17: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
s633890929
p04050
C++
#include <bits/stdc++.h> #define For(i, j, k) for (int i = j; i <= k; ++ i) #define Forr(i, j, k) for (int i = j; i >= k; -- i) using namespace std; inline int read() { int x = 0, p = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') p = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * p; } inline void File() { freopen("D.in", "r", stdin); freopen("D.out", "w", stdout); } const int N = 1e2 + 10; int a[N], sta[N], tp, n, m, lst, sum, cnt, ans[N]; int main() { n = read(), m = read(); For(i, 1, m) { a[i] = read(); if (a[i] & 1) sta[++ tp] = i; } if (tp > 2) return puts("Impossible"), 0; if (tp > 0) swap(a[1], a[sta[1]]); if (tp > 1) swap(a[m], a[sta[2]]); // For(i, 1, m) cout << a[i] << ' '; cout << endl; if (m == 1) return printf("%d\n2\n%d %d", a[1], a[1] - 1, 1), 0; For(i, 1, m) printf("%d ", a[i]); puts(""); ans[++ cnt] = lst = a[1] - 1; sum = 1; For(i, 1, m) sum += a[i], ans[++ cnt] = sum - lst, lst = sum; ans[cnt] -= 1; iNt tt = 0; For(i, 1, cnt) if (ans[i] == 0) ++ tt; printf("%d\n", cnt - tt); For(i, 1, cnt) if (ans[i]) printf("%d ", ans[i]); puts(""); return 0; }
a.cc: In function 'int main()': a.cc:46:9: error: 'iNt' was not declared in this scope; did you mean 'int'? 46 | iNt tt = 0; For(i, 1, cnt) if (ans[i] == 0) ++ tt; | ^~~ | int a.cc:46:56: error: 'tt' was not declared in this scope; did you mean 'tp'? 46 | iNt tt = 0; For(i, 1, cnt) if (ans[i] == 0) ++ tt; | ^~ | tp a.cc:48:30: error: 'tt' was not declared in this scope; did you mean 'tp'? 48 | printf("%d\n", cnt - tt); | ^~ | tp
s379763627
p04050
C++
#include<stdio.h> #include<cstring> #include<cstdlib> #include<algorithm> #include<vector> #include<map> #include<set> #include<cmath> #include<iostream> #include<queue> #include<string> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef long double ld; typedef unsigned long long ull; typedef pair<long long,long long> pll; #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i,j,k) for(register int i=(int)(j);i<=(int)(k);i++) #define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--) ll read(){ ll x=0,f=1;char c=getchar(); while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();} return x*f; } const int maxn=200; int n,m; int a[maxn]; int main(){ #ifdef LZT freopen("in","r",stdin); #endif int num=0; n=read();m=read(); rep(i,1,m) a[i]=read(),if(a[i]&1) num++; if(num>2){ puts("Impossible"); return 0; } rep(i,1,m) cout<<a[i]<<' '; cout<<endl; a[1]--;a[m]++; if(m>=2){ cout<<m<<endl; rep(i,1,m) cout<<a[i]<<' '; cout<<endl; } else{ if(n<=2){ cout<<1<<endl; cout<<n<<endl; } else{ cout<<2<<endl; cout<<n-1<<' '<<1<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:42:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 42 | rep(i,1,m) a[i]=read(),if(a[i]&1) num++; | ^ a.cc:22:38: note: in definition of macro 'rep' 22 | #define rep(i,j,k) for(register int i=(int)(j);i<=(int)(k);i++) | ^ a.cc:42:32: error: expected primary-expression before 'if' 42 | rep(i,1,m) a[i]=read(),if(a[i]&1) num++; | ^~ a.cc:47:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 47 | rep(i,1,m) cout<<a[i]<<' '; | ^ a.cc:22:38: note: in definition of macro 'rep' 22 | #define rep(i,j,k) for(register int i=(int)(j);i<=(int)(k);i++) | ^ a.cc:52:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 52 | rep(i,1,m) cout<<a[i]<<' '; | ^ a.cc:22:38: note: in definition of macro 'rep' 22 | #define rep(i,j,k) for(register int i=(int)(j);i<=(int)(k);i++) | ^
s701140744
p04050
C++
if (n == 1) { cout << "1\n1\n1\n"; return 0; }
a.cc:1:9: error: expected unqualified-id before 'if' 1 | if (n == 1) { | ^~
s036992569
p04050
C++
#include <bits/stdc++.h> using namespace std; const int MOD=1e9+7; const double PI=3.14159265359; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; vector<int> v(m); int oct=0; for(int&i:v)cin>>i, oct+=i%2; if(oct>2){ cout<<"Impossible"; return 0; } if(n==1){ cout<<"1 /n 1 /n 1; return 0; } if(m==1){ cout<<n<<endl; cout<<2<<endl<<n-1<<" "<<1; return 0; } sort(v.begin(), v.end(), [](int i, int j) {return i%2 < j%2;}); for(int i:v){ cout<<i<<" "; } if(m==3 && oct==2){ swap(v[0], v[1]); } cout<<endl; cout<<m<<endl; cout<<v[0]-1<<" "; for(int i=1; i<m-1; i++){ cout<<v[i]<<" "; } cout<<v[m-1]+1; return 0; }
a.cc:24:15: warning: missing terminating " character 24 | cout<<"1 /n 1 /n 1; | ^ a.cc:24:15: error: missing terminating " character 24 | cout<<"1 /n 1 /n 1; | ^~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:25:9: error: expected primary-expression before 'return' 25 | return 0; | ^~~~~~
s267040798
p04050
C++
#include <bits/stdc++.h> using namespace std; const int MOD=1e9+7; const double PI=3.14159265359; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; vector<int> v(m); int oct=0; for(int&i:v)cin>>i, oct+=i%2; if(oct>2){ cout<<"Impossible"; return 0; } if(n==1){ cout<<"1 /n 1 /n 1 /n 1 /n" return 0; } if(m==1){ cout<<n<<endl; cout<<2<<endl<<n-1<<" "<<1; return 0; } sort(v.begin(), v.end(), [](int i, int j) {return i%2 < j%2;}); for(int i:v){ cout<<i<<" "; } if(m==3 && oct==2){ swap(v[0], v[1]); } cout<<endl; cout<<m<<endl; cout<<v[0]-1<<" "; for(int i=1; i<m-1; i++){ cout<<v[i]<<" "; } cout<<v[m-1]+1; return 0; }
a.cc: In function 'int main()': a.cc:24:36: error: expected ';' before 'return' 24 | cout<<"1 /n 1 /n 1 /n 1 /n" | ^ | ; 25 | return 0; | ~~~~~~
s287826304
p04050
C++
#include <bits/stdc++.h> using namespace std; const int N = 110, M = 100010; vector<int>v, u; int num, n, k, x; int main() { scanf("%d%d", &n, &k); if (n == 1) return puts("1\n1\n1"), 0; if (k == 1) { scanf("%d", &x); printf("%d\n%d\n%d %d", x, 2, x - 1, 1); return 0; } for (int i = 1; i <= k; i++) { scanf("%d", &x); v.push_back(x); num += x & 1; } if (num > 2) puts("Impossible"); sort(v.begin(),v.end(),greater<int>()); else { for (int i : v) printf("%d ", i); printf("\n%d\n", v[0] == 1 ? k - 1 : k); if (v[0] != 1) printf("%d ", v[0] - 1); for (int i = 1; i < k; i++) printf("%d ", v[i] + (i == k - 1)); } }
a.cc: In function 'int main()': a.cc:26:9: error: 'else' without a previous 'if' 26 | else | ^~~~
s456001348
p04050
C++
#include <bits/stdc++.h> using namespace std; const int N = 110, M = 100010; vector<int>v, u; int num, n, k, x; int main() { scanf("%d%d", &n, &k); if (n == 1) return puts("1\n1\n1"), 0; if (k == 1) { scanf("%d", &x); printf("%d\n%d\n%d %d", x, 2, x - 1, 1); return 0; } for (int i = 1; i <= k; i++) { scanf("%d", &x); v.push_back(x); num += x & 1; } if (num > 2) puts("Impossible"); sort(v.begin(),v.end(),greater<int>); else { for (int i : v) printf("%d ", i); printf("\n%d\n", v[0] == 1 ? k - 1 : k); if (v[0] != 1) printf("%d ", v[0] - 1); for (int i = 1; i < k; i++) printf("%d ", v[i] + (i == k - 1)); } }
a.cc: In function 'int main()': a.cc:25:44: error: expected primary-expression before ')' token 25 | sort(v.begin(),v.end(),greater<int>); | ^ a.cc:26:9: error: 'else' without a previous 'if' 26 | else | ^~~~
s588495142
p04050
C++
#include <bits/stdc++.h> using namespace std; const int N = 110, M = 100010; vector<int>v, u; int num, n, k, x; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) { scanf("%d", &x); v.push_back(x); num += x & 1; n += x; if (x & 1) u.push_back(x); } sort(v.begin(), v.end(), greater<int>); if (num > 2) puts("Impossible"); else if (num <= 1) { for (int i : v) printf("%d ", i); puts("\n1"); printf("%d", n); } else { printf("%d ", u[0]); for (int i : v) if (!(i & 1)) printf("%d ", i); printf("%d\n", u[1]); printf("%d\n", v.size()); printf("%d ", u[0] - 1); for (int i : v) if (!(i & 1)) printf("%d ", i); printf("%d\n", u[1] + 1); } }
a.cc: In function 'int main()': a.cc:18:46: error: expected primary-expression before ')' token 18 | sort(v.begin(), v.end(), greater<int>); | ^
s830933164
p04050
C++
#include <bits/stdc++.h> using namespace std; int m, n; const int N = 200; int ai[N], c; int main() { cin >> m >> n; if (n == 1) { int a; cin >> a; if (a == 1) cout << 1 << endl << 1 << endl << 1 << endl; else cout << a << endl << 2 << endl << a - 1 << " " << 1 << endl; return 0; } for (int i = 1; i <= n; ++ i) cin >> ai[i], c += (ai[i] % 2 == 0); if (c > 2) { cout << "Impossible\n"; return 0; } int A = 1, B = 2; for (int i = 3; i <= n; ++ i) if (ai[i] & 1) { A = i; for (int j = i + 1; j <= n; ++ j) if (ai[j] & 1) { B = j; goto GG; } goto GG; } GG: cout << ai[A] << " "; for (int i = 1; i <= n; ++ i) if (i != A && i != B) cout << ai[i] << " "; cout << ai[B] << endl; if (ai[A] == 1) cout << n - 1 << endl; else cout << n << endl << cout << ai[A] - 1 << " "; for (int i = 1; i <= n; ++ i) if (i != A && i != B) cout << ai[i] << " "; cout << ai[B] + 1 << endl; }
a.cc: In function 'int main()': a.cc:42:29: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'std::ostream' {aka 'std::basic_ostream<char>'}) 42 | else cout << n << endl << cout << ai[A] - 1 << " "; | ~~~~~~~~~~~~~~~~~ ^~ ~~~~ | | | | | basic_ostream<[...]> | basic_ostream<[...]> a.cc:42:29: note: candidate: 'operator<<(int, int)' (built-in) 42 | else cout << n << endl << cout << ai[A] - 1 << " "; | ~~~~~~~~~~~~~~~~~~^~~~~~~ a.cc:42:29: note: no known conversion for argument 2 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int' In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char
s250103300
p04050
C++
#include <vector> using namespace std; int N, M; vector<int> even; vector<int> odd; vector<int> a; vector<int> b; int main() { cin >> N >> M; for (int i = 0; i < M; ++i) { int t; cin >> t; if (t & 1) { odd.push_back(t); } else { even.push_back(t); } } if (odd.size() > 2) { cout << "Impossible" << endl; return 0; } if (odd.size() == 0) { a.push_back(even[0]); b.push_back(even[0] - 1); } else { a.push_back(odd[0]); if (odd[0] != 1) { b.push_back(odd[0] - 1); } } for (int i=(odd.empty() ? 1 : 0); i < even.size(); ++i) { a.push_back(even[i]); b.push_back(even[i]); } if (odd.size() < 2) { b.push_back(1); } else { a.push_back(odd[1]); b.push_back(2); if (odd[1] != 1) { b.push_back(odd[1] - 1); } } for (int i = 0; i < a.size(); ++i) { if (i) cout << " "; cout << a[i]; } cout << endl; cout << b.size() << endl; for (int i = 0; i < b.size(); ++i) { if (i) cout << " "; cout << b[i]; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:3: error: 'cin' was not declared in this scope 11 | cin >> N >> M; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <vector> +++ |+#include <iostream> 2 | using namespace std; a.cc:23:5: error: 'cout' was not declared in this scope 23 | cout << "Impossible" << endl; | ^~~~ a.cc:23:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:23:29: error: 'endl' was not declared in this scope 23 | cout << "Impossible" << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <vector> +++ |+#include <ostream> 2 | using namespace std; a.cc:53:12: error: 'cout' was not declared in this scope 53 | if (i) cout << " "; | ^~~~ a.cc:53:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:54:5: error: 'cout' was not declared in this scope 54 | cout << a[i]; | ^~~~ a.cc:54:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:56:3: error: 'cout' was not declared in this scope 56 | cout << endl; | ^~~~ a.cc:56:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:56:11: error: 'endl' was not declared in this scope 56 | cout << endl; | ^~~~ a.cc:56:11: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s101076008
p04050
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cstdio> #include <queue> #include "math.h" #include <complex> #include <iomanip> #include <map> #define ifor(i,a,b) for (int i=(a);i<(b);i++) #define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--) #define rep(i,n) for (int i=0;i<(n);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) using namespace std; typedef long double ld; typedef long long int lli; typedef complex <double> P; const double eps = 1e-11; int vex[4]={1,0,-1,0}; int vey[4]={0,1,0,-1}; typedef vector<double> Vec; typedef vector<int> vec; typedef vector<Vec> MAT; typedef vector<vec> mat; lli MOD=1000000007; //Ax=bをとくAは正方行列 //rankA<=min(m,n)ならば配列0のvecが帰る int main(){ int N,M,A[1004]; cin >> N >> M; int cnt =0; vector<int> odd; rep(i,M){ cin >> A[i]; if(A[i]&1){ cnt++; odd.push_back(i); } } vector<int>a,b; if(M==1){ a.push_back(1); a.push_back(A[0]-1); b.push_back(A[0]); } else if(M==2){ a.push_back(A[0]-1); a.push_back(A[1]+1); b.push_back(A[0]); b.push_back(A[1]); }else { if(cnt>2){ cout<<"Impossible"<<endl; return 0; } else { if(cnt!=0){ a.push_back(A[odd[0]]-1); b.push_back(A[odd[0]]); rep(i,M){ if(i!=odd[0]&&i!=odd[1]){ b.push_back(A[i]); a.push_back(A[i]); } } a.push_back(A[odd[1]]+1); b.push_back(A[odd[1]]); } } else{ rep(i,M){ a.push_back(A[i]); b.push_back(A[i]); } a[0]++; a[M-1]--; } } vector<int>c; rep(i,a.size()){ if(a[i]!=0)c.push_back(a[i]); } rep(i,b.size())cout<<b[i]<<' '; cout<<endl; cout<<c.size()<<endl; rep(i,c.size())cout<<c[i]<<' '; cout<<endl; }
a.cc: In function 'int main()': a.cc:71:5: error: 'else' without a previous 'if' 71 | else{ | ^~~~
s915101497
p04050
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cstdio> #include <queue> #include "math.h" #include <complex> #include <iomanip> #include <map> #define ifor(i,a,b) for (int i=(a);i<(b);i++) #define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--) #define rep(i,n) for (int i=0;i<(n);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) using namespace std; typedef long double ld; typedef long long int lli; typedef complex <double> P; const double eps = 1e-11; int vex[4]={1,0,-1,0}; int vey[4]={0,1,0,-1}; typedef vector<double> Vec; typedef vector<int> vec; typedef vector<Vec> MAT; typedef vector<vec> mat; lli MOD=1000000007; //Ax=bをとくAは正方行列 //rankA<=min(m,n)ならば配列0のvecが帰る int main(){ int N,M,A[1004]; cin >> N >> M; int cnt =0; vector<int> odd; rep(i,M){ cin >> A[i]; if(A[i]&1){ cnt++; odd.push_back(i); } } vector<int>a,b; if(M==1){ a.push_back(1); a.push_back(A[0]-1); b.push_back(A[0]); } else if(M==2){ a.push_back(A[0]-1); a.push_back(A[1]+1); b.push_back(A[0]); b.push_back(A[1]); }else { if(cnt>2){ cout<<"Impossible"<<endl; return 0; } else { if(cnt==1){ a.push_back(A[odd[0]]-1); b.push_back(A[odd[0]]); rep(i,M){ if(i!=odd[0]&&i!=odd[1]){ b.push_back(A[i]); a.push_back(A[i]); } } a.push_back(A[odd[1]]+1); b.push_back(A[odd[1]]); } } else{ rep(i,M){ a.push_back(A[i]); b.push_back(A[i]); } a[0]++; a[M-1]--; } } vector<int>c; rep(i,a.size()){ if(a[i]!=0)c.push_back(a[i]); } rep(i,b.size())cout<<b[i]<<' '; cout<<endl; cout<<c.size()<<endl; rep(i,c.size())cout<<c[i]<<' '; cout<<endl; }
a.cc: In function 'int main()': a.cc:71:5: error: 'else' without a previous 'if' 71 | else{ | ^~~~
s198804733
p04050
C++
#include <bits/stdc++.h> using namespace std; #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } int N, M, L, sum; int A[210]; int B[210]; int main() { while (cin >> N >> M) { sum = 0; int odd = 0; for (int i = 0; i < M; ++i) { cin >> A[i]; if (A[i] & 1) { swap(A[odd++], A[i]); } } if (odd == 2) swap(A[1], A[M-1]); if (odd > 2) puts("Impossible"); else { for (int i = 0; i < M; ++i) cout << A[i] << " "; cout << endl; vector<int> B; if (odd == 0 || M == 1) { B.push_back(1); for (int i = 0; i < M; ++i) B.push_back(A[i]); B.back()--; else { for (int i = 0; i < M; ++i) B.push_back(A[i]); B[0]--; B.back()++; } for (int i = 0; i < B.size(); ++i) if (B[i] <= 0) B.erase(B.begin() + i--); cout << B.size() << endl; for (int i = 0; i < B.size(); ++i) cout << B[i] << " "; cout << endl; } } }
a.cc: In function 'int main()': a.cc:39:13: error: expected '}' before 'else' 39 | else { | ^~~~ a.cc:35:37: note: to match this '{' 35 | if (odd == 0 || M == 1) { | ^
s456029820
p04050
Java
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.NoSuchElementException; public class Main { private static class Task { void solve(FastScanner in, PrintWriter out) throws Exception { int N = in.nextInt(); int M = in.nextInt(); int[] A = in.nextIntArray(M); if (M == 1) { if (A[0] == 1) { out.println("Impossible"); throw new Exception(); return; } out.println(A[0]); out.println(2); out.println(1 + " " + (A[0] - 1)); return; } ArrayList<Integer> odd = new ArrayList<>(); ArrayList<Integer> even = new ArrayList<>(); for (int a : A) if (a % 2 == 0) even.add(a); else odd.add(a); if (odd.size() > 2) { out.println("Impossible"); return; } Collections.sort(odd); if (!odd.isEmpty()) { even.add(odd.get(0)); if (odd.size() == 2) even.add(0, odd.get(1)); } for (int e : even) out.print(e + " "); out.println(); if (even.get(0) == 1) { out.println(even.size() - 1); for (int i = 1; i < even.size() - 1; i++) out.print(even.get(i) + " "); out.print(even.get(M - 1) + 1); out.println(); } else { out.println(even.size()); out.print(even.get(0) - 1); out.print(" "); for (int i = 1; i < even.size() - 1; i++) out.print(even.get(i) + " "); out.print(even.get(M - 1) + 1); out.println(); } } } // Template public static void main(String[] args) throws Exception { OutputStream outputStream = System.out; FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(in, out); out.close(); } private static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int bufferLength = 0; private boolean hasNextByte() { if (ptr < bufferLength) { return true; } else { ptr = 0; try { bufferLength = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (bufferLength <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) { array[i] = nextDouble(); } return array; } double[][] nextDoubleMap(int n, int m) { double[][] map = new double[n][]; for (int i = 0; i < n; i++) { map[i] = nextDoubleArray(m); } return map; } public int nextInt() { return (int) nextLong(); } public int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) { array[i] = nextInt(); } return array; } } }
Main.java:19: error: unreachable statement return; ^ 1 error
s574316289
p04051
C++
#include <bits/stdc++.h> using namespace std; #define M 4005 #define delta 2001 #define MOD 1000000007 #define ll long long #define int long long int n; int a[M], b[M]; ll ans; ll f[M][M], mns[M][M]; inline ll quick_pow(ll x, ll k) { ll res = 1; while (k) { if (k & 1) (res *= x) %= MOD; (x *= x) %= MOD; k >>= 1; } return res; } inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); } return x * f; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i] = read(), b[i] = read(); f[-a[i] + delta][-b[i] + delta]++; } for (int i = 1; i <= 4004; i++) for (int j= 1; j <= 4004; j++) (f[i][j] += (f[i-1][j] + f[i][j-1]) % MOD) %= MOD; mns[1][1] = 1; for (int i = 1; i <= 4004; i++) for (int j = 1; j <= 4004; j++) (mns[i][j] += (mns[i-1][j] + mns[i][j-1]) % MOD) %= MOD; for (int i = 1; i <= n; i++) { (ans += f[a[i]+delta][b[i]+delta]) %= MOD; // cout << a[i] * 2 << ", " << b[i] * 2 << " " << mns[a[i]*2][b[i]*2] << endl; ((ans -= mns[a[i]*2+1][b[i]*2+1]) += MOD) %= MOD; } cout << ans * quick_pow(2, MOD-2) % MOD; return 0; }
cc1plus: error: '::main' must return 'int'
s197952389
p04051
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 = 200005; const int mod=1e9+7; const int size=2001; int fac[size*5],ifac[size*5]; int a[MAXN],b[MAXN],dp[size*5][size*5]; int n,ans; 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; } int main(int argc, char const *argv[]) { n=read(); init(size<<2); auto cbt=[](int n,int m) {return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}; for(int i=1; i<=n; ++i) { a[i]=read(),b[i]=read(); ++dp[size-a[i]][size-b[i]]; } for(int i=1; i<=size<<1; ++i) for(int j=1; j<=size<<1; ++j) dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod; for(int i=1; i<=n; ++i) { ans=(ans+dp[size+a[i]][size+b[i]])%mod; ans=(ans-cbt(a[i]+a[i]+b[i]+b[i],a[i]+a[i])+mod)%mod; } printf("%lld\n",1ll*ans*qpow(2,mod-2)%mod); return 0; }
a.cc:15:9: error: reference to 'size' is ambiguous 15 | int fac[size*5],ifac[size*5]; | ^~~~ 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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:15:22: error: reference to 'size' is ambiguous 15 | int fac[size*5],ifac[size*5]; | ^~~~ /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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:16:24: error: reference to 'size' is ambiguous 16 | int a[MAXN],b[MAXN],dp[size*5][size*5]; | ^~~~ /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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:16:32: error: reference to 'size' is ambiguous 16 | int a[MAXN],b[MAXN],dp[size*5][size*5]; | ^~~~ /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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc: In function 'void init(int)': a.cc:29:19: error: 'fac' was not declared in this scope 29 | for(int i=fac[0]=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod; | ^~~ a.cc:30:9: error: 'ifac' was not declared in this scope 30 | ifac[n]=qpow(fac[n],mod-2); | ^~~~ a.cc:30:22: error: 'fac' was not declared in this scope 30 | ifac[n]=qpow(fac[n],mod-2); | ^~~ a.cc: In function 'int main(int, const char**)': a.cc:36:24: error: reference to 'size' is ambiguous 36 | n=read(); init(size<<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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc: In lambda function: a.cc:38:21: error: 'fac' was not declared in this scope 38 | {return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}; | ^~~ a.cc:38:28: error: 'ifac' was not declared in this scope 38 | {return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}; | ^~~~ a.cc: In function 'int main(int, const char**)': a.cc:42:19: error: 'dp' was not declared in this scope; did you mean 'dup'? 42 | ++dp[size-a[i]][size-b[i]]; | ^~ | dup a.cc:42:22: error: reference to 'size' is ambiguous 42 | ++dp[size-a[i]][size-b[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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:42:33: error: reference to 'size' is ambiguous 42 | ++dp[size-a[i]][size-b[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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:44:25: error: reference to 'size' is ambiguous 44 | for(int i=1; i<=size<<1; ++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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:45:33: error: reference to 'size' is ambiguous 45 | for(int j=1; j<=size<<1; ++j) | ^~~~ /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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:46:25: error: 'dp' was not declared in this scope; did you mean 'dup'? 46 | dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod; | ^~ | dup a.cc:49:26: error: 'dp' was not declared in this scope; did you mean 'dup'? 49 | ans=(ans+dp[size+a[i]][size+b[i]])%mod; | ^~ | dup a.cc:49:29: error: reference to 'size' is ambiguous 49 | ans=(ans+dp[size+a[i]][size+b[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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~ a.cc:49:40: error: reference to 'size' is ambiguous 49 | ans=(ans+dp[size+a[i]][size+b[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:14:11: note: 'const int size' 14 | const int size=2001; | ^~~~
s547547425
p04051
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 = 200005; const int mod=1e9+7,size=2001; int fac[size*5],ifac[size*5]; int a[MAXN],b[MAXN],dp[size*5][size*5]; int n,ans; 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; } int main(int argc, char const *argv[]) { n=read(); init(size<<2); auto cbt=[](int n,int m) {return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}; for(int i=1; i<=n; ++i) { a[i]=read(),b[i]=read(); ++dp[size-a[i]][size-b[i]]; } for(int i=1; i<=size<<1; ++i) for(int j=1; j<=size<<1; ++j) dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod; for(int i=1; i<=n; ++i) { ans=(ans+dp[size+a[i]][size+b[i]])%mod; ans=(ans-cbt(a[i]+a[i]+b[i]+b[i],a[i]+a[i])+mod)%mod; } printf("%lld\n",1ll*ans*qpow(2,mod-2)%mod); return 0; }
a.cc:14:9: error: reference to 'size' is ambiguous 14 | int fac[size*5],ifac[size*5]; | ^~~~ 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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:14:22: error: reference to 'size' is ambiguous 14 | int fac[size*5],ifac[size*5]; | ^~~~ /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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:15:24: error: reference to 'size' is ambiguous 15 | int a[MAXN],b[MAXN],dp[size*5][size*5]; | ^~~~ /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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:15:32: error: reference to 'size' is ambiguous 15 | int a[MAXN],b[MAXN],dp[size*5][size*5]; | ^~~~ /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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc: In function 'void init(int)': a.cc:28:19: error: 'fac' was not declared in this scope 28 | for(int i=fac[0]=1; i<=n; ++i) fac[i]=1ll*fac[i-1]*i%mod; | ^~~ a.cc:29:9: error: 'ifac' was not declared in this scope 29 | ifac[n]=qpow(fac[n],mod-2); | ^~~~ a.cc:29:22: error: 'fac' was not declared in this scope 29 | ifac[n]=qpow(fac[n],mod-2); | ^~~ a.cc: In function 'int main(int, const char**)': a.cc:35:24: error: reference to 'size' is ambiguous 35 | n=read(); init(size<<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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc: In lambda function: a.cc:37:21: error: 'fac' was not declared in this scope 37 | {return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}; | ^~~ a.cc:37:28: error: 'ifac' was not declared in this scope 37 | {return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}; | ^~~~ a.cc: In function 'int main(int, const char**)': a.cc:41:19: error: 'dp' was not declared in this scope; did you mean 'dup'? 41 | ++dp[size-a[i]][size-b[i]]; | ^~ | dup a.cc:41:22: error: reference to 'size' is ambiguous 41 | ++dp[size-a[i]][size-b[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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:41:33: error: reference to 'size' is ambiguous 41 | ++dp[size-a[i]][size-b[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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:43:25: error: reference to 'size' is ambiguous 43 | for(int i=1; i<=size<<1; ++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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:44:33: error: reference to 'size' is ambiguous 44 | for(int j=1; j<=size<<1; ++j) | ^~~~ /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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:45:25: error: 'dp' was not declared in this scope; did you mean 'dup'? 45 | dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod; | ^~ | dup a.cc:48:26: error: 'dp' was not declared in this scope; did you mean 'dup'? 48 | ans=(ans+dp[size+a[i]][size+b[i]])%mod; | ^~ | dup a.cc:48:29: error: reference to 'size' is ambiguous 48 | ans=(ans+dp[size+a[i]][size+b[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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~ a.cc:48:40: error: reference to 'size' is ambiguous 48 | ans=(ans+dp[size+a[i]][size+b[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:13:21: note: 'const int size' 13 | const int mod=1e9+7,size=2001; | ^~~~
s821853926
p04051
C++
#include<bits/stdc++.h> #define int long long using namespace std; const int N=5e3; const int M=2e3+88; const int mod=1e9+7; int n,a[M*100],b[M*100],f[N+99][N+99],fac[M*10+99],da; int ksm(int x,int y){ int base=1; while(y){ if(y&1)base=(1ll*base*x)%mod; x=(1ll*x*x)%mod; y>>=1; }return base; } int C(int n,int m){ return (1ll*fac[n]*ksm((1ll*fac[m]*fac[n-m]%mod),mod-2))%mod; } signed main(){ ios::sync_with_stdio(false); cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]; }fac[0]=1; for(int i=1;i<=N;i++){ fac[i]=1ll*fac[i-1]*i%mod; } for(int i=1;i<=n;i++){ f[M-a[i]][M-b[i]]++; } for(int i=1;i<=N;i++){ for(int k=1;k<=N;k++){ f[i][k]=(f[i][k]+f[i-1][k]+f[i][k-1])%mod; } } for(int i=1;i<=n;i++){ da=(da+f[a[i]+M][b[i]+M])%mod; da=((da-C(2*(a[i]+b[i]),a[i]*2)mod)%mod+mod)%mod; } da=(1ll*da*ksm(2,mod-2))%mod; cout<<da; }
a.cc: In function 'int main()': a.cc:38:48: error: expected ')' before 'mod' 38 | da=((da-C(2*(a[i]+b[i]),a[i]*2)mod)%mod+mod)%mod; | ~ ^~~ | ) a.cc:38:65: error: expected ')' before ';' token 38 | da=((da-C(2*(a[i]+b[i]),a[i]*2)mod)%mod+mod)%mod; | ~ ^ | )
s792393510
p04051
C++
/* Though leaves are many , the root is one. Through all the lying days of my youth I swayed my leaves and flowers in the sun. Now I may wither into the truth. - William Butler Yeats */ #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #pragma GCC target("avx,tune=native") #include<bits/stdc++.h> //#pragma comment("-Wl,--stack=1024000000") //#include<ext/pb_ds/assoc_container.hpp> using namespace std; namespace fastio{ char in[100000]; int itr=0,llen=0; char get(){ if(itr==llen)llen=fread(in,1,100000,stdin),itr=0; if(llen==0)return EOF; return in[itr++]; } char out[100000]; int itr2=0; void put(char c){ out[itr2++]=c; if(itr2==100000){ fwrite(out,1,100000,stdout); itr2=0; } } int clear(){ fwrite(out,1,itr2,stdout); itr2=0; return 0; } int getint(){ int ret=0;char ch=get(); if(ch=='-')return -getint(); while (ch<'0'||ch>'9'){ ch=get();if(ch=='-')return -getint(); } while ('0'<=ch&&ch<='9'){ ret=ret*10-48+ch; ch=get(); } return ret; } string getstr(){ string ret=""; char ch=get(); while(ch==' '||ch=='\n')ch=get(); while(ch!=' '&&ch!='\n')ret.push_back(ch),ch=get(); return ret; } void putstr(string s){ for(int i=0;i<s.size();i++)put(s[i]); } void putint(int x){ if(x<0){ put('-'); putint(-x); return; } if(x==0){ put('0');put(' '); return; } char c[40];int pos=0; while(x){ c[pos++]='0'+x%10; x/=10; } for(int i=pos-1;i>=0;i--)put(c[i]); put(' '); } void putln(int x){ if(x<0){ put('-'); putln(-x); return; } if(x==0){ put('0');put('\n'); return; } char c[40];int pos=0; while(x){ c[pos++]='0'+x%10; x/=10; } for(int i=pos-1;i>=0;i--)put(c[i]); put('\n'); } } using namespace fastio; //using namespace __gnu_pbds; const int inf=0x3f3f3f3f; const double eps=1e-6; const int mod=1000000007; typedef long long ll; #ifndef LOCAL #define cerr if(0)cout #define eprintf(...) 0 #else #define eprintf(...) fprintf(stderr, __VA_ARGS__) #endif inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;} int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;} inline int Rand(){return rand()*32768+rand();} int n,a[200005],b[200005],s[200005],d[200005]; int C[4005][4005],sum[6666]; int main(){ n=getint(); for(int i=1;i<=n;i++){ a[i]=getint();b[i]=getint();s[i]=a[i]+b[i]; } C[0][0]=1; for(int i=1;i<=4000;i++){ C[i][0]=C[i][i]=1; for(int j=1;j<i;j++){ C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod; } } int ans=0; for(int delta=-2000;delta<=2000;delta++){ const int pos=delta+2222; for(int j=1;j<=n;j++){ if(delta+a[j]>=0&&delta<=b[j]){ cerr<<delta<<" "<<j<<" "<<C[a[j]+b[j]][a[j]+delta]<<endl; sum[pos]+=C[a[j]+b[j]][a[j]+delta]; if(sum[pos]>=mod)sum[pos]-=mod; } } } for(int i=-2000;i<=0;i++){ ans+=(ll)(1ll+(i!=0?1ll:0ll))*sum[i+2222]*sum[-i+2222]%mod; ans%=mod; } for(int i=1;i<=n;i++){ ans-=C[a[i]+a[i]+b[i]+b[i]][a[i]+a[i]]; if(ans<0)ans+=mod; } ans=((ll)ans*(mod+1)/2)%mod; cout<<ans<<endl; return 0; }
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:11: /usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()': /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 = char]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:186:14: note: called from here 186 | struct _Alloc_hider : allocator_type // TODO check __is_final | ^~~~~~~~~~~~
s272305335
p04051
C++
/* Though leaves are many , the root is one. Through all the lying days of my youth I swayed my leaves and flowers in the sun. Now I may wither into the truth. - William Butler Yeats */ #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #pragma GCC target("avx,tune=native") #include<bits/stdc++.h> #pragma comment("-Wl,--stack=1024000000") //#include<ext/pb_ds/assoc_container.hpp> using namespace std; namespace fastio{ char in[100000]; int itr=0,llen=0; char get(){ if(itr==llen)llen=fread(in,1,100000,stdin),itr=0; if(llen==0)return EOF; return in[itr++]; } char out[100000]; int itr2=0; void put(char c){ out[itr2++]=c; if(itr2==100000){ fwrite(out,1,100000,stdout); itr2=0; } } int clear(){ fwrite(out,1,itr2,stdout); itr2=0; return 0; } int getint(){ int ret=0;char ch=get(); if(ch=='-')return -getint(); while (ch<'0'||ch>'9'){ ch=get();if(ch=='-')return -getint(); } while ('0'<=ch&&ch<='9'){ ret=ret*10-48+ch; ch=get(); } return ret; } string getstr(){ string ret=""; char ch=get(); while(ch==' '||ch=='\n')ch=get(); while(ch!=' '&&ch!='\n')ret.push_back(ch),ch=get(); return ret; } void putstr(string s){ for(int i=0;i<s.size();i++)put(s[i]); } void putint(int x){ if(x<0){ put('-'); putint(-x); return; } if(x==0){ put('0');put(' '); return; } char c[40];int pos=0; while(x){ c[pos++]='0'+x%10; x/=10; } for(int i=pos-1;i>=0;i--)put(c[i]); put(' '); } void putln(int x){ if(x<0){ put('-'); putln(-x); return; } if(x==0){ put('0');put('\n'); return; } char c[40];int pos=0; while(x){ c[pos++]='0'+x%10; x/=10; } for(int i=pos-1;i>=0;i--)put(c[i]); put('\n'); } } using namespace fastio; //using namespace __gnu_pbds; const int inf=0x3f3f3f3f; const double eps=1e-6; const int mod=1000000007; typedef long long ll; #ifndef LOCAL #define cerr if(0)cout #define eprintf(...) 0 #else #define eprintf(...) fprintf(stderr, __VA_ARGS__) #endif inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;} int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;} inline int Rand(){return rand()*32768+rand();} int n,a[200005],b[200005],s[200005],d[200005]; int C[4005][4005],sum[6666]; int main(){ n=getint(); for(int i=1;i<=n;i++){ a[i]=getint();b[i]=getint();s[i]=a[i]+b[i]; } C[0][0]=1; for(int i=1;i<=4000;i++){ C[i][0]=C[i][i]=1; for(int j=1;j<i;j++){ C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod; } } int ans=0; for(int delta=-2000;delta<=2000;delta++){ const int pos=delta+2222; for(int j=1;j<=n;j++){ if(delta+a[j]>=0&&delta<=b[j]){ cerr<<delta<<" "<<j<<" "<<C[a[j]+b[j]][a[j]+delta]<<endl; sum[pos]+=C[a[j]+b[j]][a[j]+delta]; if(sum[pos]>=mod)sum[pos]-=mod; } } } for(int i=-2000;i<=0;i++){ ans+=(ll)(1ll+(i!=0?1ll:0ll))*sum[i+2222]*sum[-i+2222]%mod; ans%=mod; } for(int i=1;i<=n;i++){ ans-=C[a[i]+a[i]+b[i]+b[i]][a[i]+a[i]]; if(ans<0)ans+=mod; } ans=((ll)ans*(mod+1)/2)%mod; cout<<ans<<endl; return 0; }
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:11: /usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()': /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 = char]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:186:14: note: called from here 186 | struct _Alloc_hider : allocator_type // TODO check __is_final | ^~~~~~~~~~~~
s602956232
p04051
C++
#include<cstdio> #include<cctype> #define rr register using namespace std; const int M=4001,N=200011,mod=1000000007; int dp[M][M],fac[M<<1],inv[M<<1],a[N],b[N],ans; inline signed iut(){ rr int ans=0; rr char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) ans=ans*10+c-48,c=getchar(); return ans; } inline signed mo(int x,int y){return x+y>=mod?x+y-mod:x+y;} inline signed c(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;} signed main(){ n=iut(),fac[0]=fac[1]=inv[0]=inv[1]=1; rr int t=M>>1,T=t<<2; for (rr int i=2;i<=T;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod; for (rr int i=2;i<=T;++i) fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*inv[i-1]*inv[i]%mod; for (rr int i=1;i<=n;++i){ a[i]=iut(),b[i]=iut(); ++dp[t-a[i]][t-b[i]]; } for (rr int i=1;i<M;++i) for (rr int j=1;j<M;++j){ rr int w=mo(dp[i-1][j],dp[i][j-1]); dp[i][j]=mo(dp[i][j],w); } for (rr int i=1;i<=n;++i){ ans=mo(ans,dp[t+a[i]][t+b[i]]); ans=mo(ans,mod-c(a[i]*2+b[i]*2,a[i]+b[i])); } return !printf("%d\n",ans); }
a.cc: In function 'int iut()': a.cc:8:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 8 | rr int ans=0; rr char c=getchar(); | ^~~ a.cc:8:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 8 | rr int ans=0; rr char c=getchar(); | ^ a.cc: In function 'int main()': a.cc:16:5: error: 'n' was not declared in this scope 16 | n=iut(),fac[0]=fac[1]=inv[0]=inv[1]=1; | ^ a.cc:17:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | rr int t=M>>1,T=t<<2; | ^ a.cc:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | rr int t=M>>1,T=t<<2; | ^ a.cc:18:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 18 | for (rr int i=2;i<=T;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod; | ^ a.cc:19:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 19 | for (rr int i=2;i<=T;++i) fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*inv[i-1]*inv[i]%mod; | ^ a.cc:20:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 20 | for (rr int i=1;i<=n;++i){ | ^ a.cc:24:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 24 | for (rr int i=1;i<M;++i) | ^ a.cc:25:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 25 | for (rr int j=1;j<M;++j){ | ^ a.cc:26:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 26 | rr int w=mo(dp[i-1][j],dp[i][j-1]); | ^ a.cc:29:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 29 | for (rr int i=1;i<=n;++i){ | ^
s740115291
p04051
C++
#include<cstdio> #include<cctype> #define rr register using namespace std; const int M=4001,N=200011,mod=1000000007; int dp[M][M],fac[M<<1],inv[M<<1],a[N],b[N],ans; inline signed iut(){ rr int ans=0; rr char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) ans=ans*10+c-48,c=getchar(); return ans; } inline signed mo(int x,int y){return x+y>=mod?x+y-mod:x+y;} inline signed c(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;} signed main(){ n=iut(),fac[0]=fac[1]=inv[0]=inv[1]=1; rr int t=M>>1,T=t<<2; for (rr int i=2;i<=T;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod; for (rr int i=2;i<=T;++i) fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*inv[i-1]*inv[i]%mod; for (rr int i=1;i<=n;++i){ a[i]=iut(),b[i]=iut(); ++dp[t-a[i]][t-b[i]]; } for (rr int i=1;i<M;++i) for (rr int j=1;j<M;++j){ rr int w=mo(dp[i-1][j],dp[i][j-1]); dp[i][j]=mo(dp[i][j],w); } for (rr int i=1;i<=n;++i){ ans=mo(ans,dp[t+a[i]][t+b[i]]); ans=mo(ans,mod-c(a[i]*2+b[i]*2,a[i]+b[i]); } return !printf("%d\n",ans); }
a.cc: In function 'int iut()': a.cc:8:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 8 | rr int ans=0; rr char c=getchar(); | ^~~ a.cc:8:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 8 | rr int ans=0; rr char c=getchar(); | ^ a.cc: In function 'int main()': a.cc:16:5: error: 'n' was not declared in this scope 16 | n=iut(),fac[0]=fac[1]=inv[0]=inv[1]=1; | ^ a.cc:17:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | rr int t=M>>1,T=t<<2; | ^ a.cc:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | rr int t=M>>1,T=t<<2; | ^ a.cc:18:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 18 | for (rr int i=2;i<=T;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod; | ^ a.cc:19:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 19 | for (rr int i=2;i<=T;++i) fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*inv[i-1]*inv[i]%mod; | ^ a.cc:20:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 20 | for (rr int i=1;i<=n;++i){ | ^ a.cc:24:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 24 | for (rr int i=1;i<M;++i) | ^ a.cc:25:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 25 | for (rr int j=1;j<M;++j){ | ^ a.cc:26:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 26 | rr int w=mo(dp[i-1][j],dp[i][j-1]); | ^ a.cc:29:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 29 | for (rr int i=1;i<=n;++i){ | ^ a.cc:31:50: error: expected ')' before ';' token 31 | ans=mo(ans,mod-c(a[i]*2+b[i]*2,a[i]+b[i]); | ~ ^ | )
s417710663
p04051
C++
//G #include<bits/stdc++.h> using namespace std; #define as 1000000007 long long n; struct { long long a,b; }cas[200000]; long long op(int n) { long long QWQ=1; for(int i=1;i<=n;i++) QWQ*=i; return QWQ%as; } long long Con(long long a,long long b) { return op(a+b)/op(a)/op(b)%as; } int main() { long long ans=0; cin>>n; for(long long i=0;i<n;i++) { cin>>a[i]>>b[i]; } for(long long i=0;i<n;i++) { for(long long j=0;j<i;j++) { long long A=a[i]+a[j],B=b[i]+b[j]; ans+=Con(A,B)%as; } } cout<<ans%as; }
a.cc: In function 'int main()': a.cc:26:22: error: 'a' was not declared in this scope 26 | cin>>a[i]>>b[i]; | ^ a.cc:26:28: error: 'b' was not declared in this scope 26 | cin>>a[i]>>b[i]; | ^ a.cc:32:37: error: 'a' was not declared in this scope 32 | long long A=a[i]+a[j],B=b[i]+b[j]; | ^ a.cc:33:36: error: 'B' was not declared in this scope 33 | ans+=Con(A,B)%as; | ^
s118242533
p04051
C++
//G #include<bits/stdc++.h> using namespacde std; #define as 1000000007 long long n; struct { long long a,b; }cas[200000]; long long op(int n) { long long QWQ=1; for(int i=1;i<=n;i++) QWQ*=i; return QWQ%as; } long long Con(long long a,long long b) { return op(a+b)/op(a)/op(b)%as; } int main() { long long ans=0; cin>>n; for(long long i=0;i<n;i++) { cin>>a[i]>>b[i]; } for(long long i=0;i<n;i++) { for(long long j=0;j<i;j++) { long long A=a[i]+a[j],B=b[i]+b[j]; ans+=Con(A,B)%as; } } cout<<ans%as; }
a.cc:3:7: error: expected nested-name-specifier before 'namespacde' 3 | using namespacde std; | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:23:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 23 | 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:26:22: error: 'a' was not declared in this scope 26 | cin>>a[i]>>b[i]; | ^ a.cc:26:28: error: 'b' was not declared in this scope 26 | cin>>a[i]>>b[i]; | ^ a.cc:32:37: error: 'a' was not declared in this scope 32 | long long A=a[i]+a[j],B=b[i]+b[j]; | ^ a.cc:33:36: error: 'B' was not declared in this scope 33 | ans+=Con(A,B)%as; | ^ a.cc:36:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 36 | cout<<ans%as; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s441190472
p04051
C++
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> const int maxn = int(4e4) + 7, mod = int(1e9) + 7; typedef long long ll; ll fac[maxn], inv[maxn]; ll pow(ll x,ll y){ x%=P; ll ans=1; while(y){ if (y&1) ans=ans*x%P; x=x*x%P; y>>=1; } return ans%P; } void init() { fac[0] = 1; for (int i = 1; i <= maxn - 10; ++i) fac[i] = fac[i - 1] * i % mod; inv[maxn - 10] = pow(fac[maxn - 10], mod - 2); for (int i = maxn - 11; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % mod; } ll C(int x, int y) { return fac[x] * inv[y] % mod * inv[x - y] % mod; } int n, a[2000007], b[2000007], dp[4007][4007]; int main() { // freopen("in.txt", "r", stdin); init(); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", a + i, b + i); dp[2001 - a[i]][2001 - b[i]]++; } for (int i = 1; i <= 4001; i++) for (int j = 1; j <= 4001; j++) { dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod; dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod; } ll ans = 0; for (int i = 1; i <= n; i++) ans = (ans + dp[2001 + a[i]][2001 + b[i]]) % mod; for (int i = 1; i <= n; i++) ans = (ans - C(a[i] + a[i] + b[i] + b[i], a[i] + a[i]) + mod) % mod; printf("%lld\n", ans * pow(2, mod - 2) % mod); return 0; }
a.cc: In function 'll pow(ll, ll)': a.cc:10:8: error: 'P' was not declared in this scope 10 | x%=P; | ^ a.cc: In function 'int main()': a.cc:48:31: error: call of overloaded 'pow(int, int)' is ambiguous 48 | printf("%lld\n", ans * pow(2, mod - 2) % mod); | ~~~^~~~~~~~~~~~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/bits/requires_hosted.h:31, from /usr/include/c++/14/iostream:38, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: candidate: 'double pow(double, double)' 173 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y)); | ^~~~~~~~~~~~~~ a.cc:9:4: note: candidate: 'll pow(ll, ll)' 9 | ll pow(ll x,ll y){ | ^~~
s932731662
p04051
C++
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; namespace io { #define SIZ (1 << 21 | 1) #define gc() (io::iS == io::iT ? (io::iT= (io::iS= io::ibuff) + fread(io::ibuff, 1, SIZ, stdin), (io::iS == io::iT ? EOF : *io::iS++)) : *io::iS++) #define putc(x) (io::oS == io::oT ? (fwrite(io::obuff, 1, io::oS - io::obuff, stdout), io::oS= io::obuff, (*io::oS++= x)) : *io::oS++= x) #define exit \ fwrite(io::obuff, 1, io::oS - io::obuff, stdout); \ return 0; char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS= obuff, *oT= oS + SIZ - 1, fu[110], c; int fr; template <class Type> inline void read(Type &x) { x= 0; Type y= 1; for(c= gc(); (c > '9' || c < '0') && c != '-'; c= gc()) ; c == '-' ? y= -1 : x= (c & 15); for(c= gc(); c >= '0' && c <= '9'; c= gc()) x= x * 10 + (c & 15); x*= y; } inline void reads(char *x) { for(c= gc(); c == ' ' || c == '\n'; c= gc()) ; for(; c != ' ' && c != '\n' && c != EOF; *x= c, c= gc(), ++x) ; } template <class Type> inline void print(Type x, char text= '\n') { if(x < 0) putc('-'), x*= -1; if(x == 0) putc('0'); while(x) fu[++fr]= x % 10 + '0', x/= 10; while(fr) putc(fu[fr--]); putc(text); } inline void prints(char *x, char *y= NULL, char text= '\n') { for(; *x && x != y; ++x) putc(*x); putc(text); } } // namespace io using io::print; using io::prints; using io::read; using io::reads; #define N 200001 #define M 4005 #define P 1000000007 int n, a[N], b[N], f[M][M], ans, jc[M], invjc[M]; inline int ksm(int a, int b) { int s= 1; for(; b; b>>= 1, a= (long long)a * a % P) if(b & 1) s= (long long)s * a % P; return s; } inline int C(int n, int m) { return (long long)jc[n] * invjc[m] % P * invjc[n - m] % P; } signed main() { read(n); for(int i= 1; i <= n; i++) read(a[i]), read(b[i]); for(int i= 1; i <= n; i++) f[2000 - a[i]][2000 - b[i]]++; for(int i= 0; i <= 4000; i++) { for(int j= 0; j <= 4000; j++) { f[i + 1][j]= ((long long)f[i + 1][j] + f[i][j]) % P; f[i][j + 1]= ((long long)f[i][j + 1] + f[i][j]) % P; } } for(int i= 1; i <= n; i++) ans= ((long long)ans + f[2000 + a[i]][2000 + b[i]]) % P; jc[0]= invjc[0]= 1; for(int i= 1; i <= 4000; i++) jc[i]= (long long)jc[i - 1] * i % P, invjc[i]= ksm(jc[i], P - 2); for(int i= 1; i <= n; i++) ans= ((long long)ans - C(2 * (a[i] + b[i]), 2 * b[i])) % P, if(ans < 0) ans+= P; ans= (long long)ans * ksm(2, P - 2) % P; print(ans); exit; }
a.cc: In function 'int main()': a.cc:90:96: error: expected primary-expression before 'if' 90 | for(int i= 1; i <= n; i++) ans= ((long long)ans - C(2 * (a[i] + b[i]), 2 * b[i])) % P, if(ans < 0) ans+= P; | ^~
s603380047
p04051
C++
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <iomanip> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> #include <cstdint> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; #define MP make_pair #define PB push_back #define inf 1000000007 #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define all(x) (x).begin(),(x).end() template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } template<class T> inline bool chmax(T &a, T b){ if(a<b){ a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b){ if(a>b){ a = b; return true; } return false; } template <unsigned int mod> class ModInt { private: unsigned int v; static unsigned int norm(const unsigned int& x){ return x < mod ? x : x - mod; } static ModInt make(const unsigned int& x){ ModInt m; return m.v = x, m; } static ModInt inv(const ModInt& x){ return make(inverse(x.v, mod)); } static unsigned int inverse(int a, int m){ int u[] = {a, 1, 0}, v[] = {m, 0, 1}, t; while(*v){ t = *u / *v; swap(u[0] -= t * v[0], v[0]), swap(u[1] -= t * v[1], v[1]), swap(u[2] -= t * v[2], v[2]); } return (u[1] % m + m) % m; } public: ModInt() : v{0}{} ModInt(const long long val) : v{norm(val % mod + mod)} {} ModInt(const ModInt<mod>& n) : v{n()} {} explicit operator bool() const noexcept { return v != 0; } bool operator!() const noexcept { return !static_cast<bool>(*this); } ModInt& operator=(const ModInt& n){ return v = n(), (*this); } ModInt& operator=(const long long val){ return v = norm(val % mod + mod), (*this); } ModInt operator+() const { return *this; } ModInt operator-() const { return v == 0 ? make(0) : make(mod - v); } ModInt operator+(const ModInt& val) const { return make(norm(v + val())); } ModInt operator-(const ModInt& val) const { return make(norm(v + mod - val())); } ModInt operator*(const ModInt& val) const { return make((long long)v * val() % mod); } ModInt operator/(const ModInt& val) const { return *this * inv(val); } ModInt& operator+=(const ModInt& val){ return *this = *this + val; } ModInt& operator-=(const ModInt& val){ return *this = *this - val; } ModInt& operator*=(const ModInt& val){ return *this = *this * val; } ModInt& operator/=(const ModInt& val){ return *this = *this / val; } ModInt operator+(const long long val) const { return ModInt{v + val}; } ModInt operator-(const long long val) const { return ModInt{v - val}; } ModInt operator*(const long long val) const { return ModInt{(long long)v * (val % mod)}; } ModInt operator/(const long long val) const { return ModInt{(long long)v * inv(val)}; } ModInt& operator+=(const long long val){ return *this = *this + val; } ModInt& operator-=(const long long val){ return *this = *this - val; } ModInt& operator*=(const long long val){ return *this = *this * val; } ModInt& operator/=(const long long val){ return *this = *this / val; } bool operator==(const ModInt& val) const { return v == val.v; } bool operator!=(const ModInt& val) const { return !(*this == val); } bool operator==(const long long val) const { return v == norm(val % mod + mod); } bool operator!=(const long long val) const { return !(*this == val); } unsigned int operator()() const { return v; } friend ModInt operator+(const long long val, const ModInt& n) { return n + val; } friend ModInt operator-(const long long val, const ModInt& n) { return ModInt{val - n()}; } friend ModInt operator*(const long long val, const ModInt& n) { return n * val; } friend ModInt operator/(const long long val, const ModInt& n) { return ModInt{val} / n; } friend bool operator==(const long long val, const ModInt& n) { return n == val; } friend bool operator!=(const long long val, const ModInt& n) { return !(val == n); } friend istream& operator>>(istream& is, ModInt& n){ unsigned int v; return is >> v, n = v, is; } friend ostream& operator<<(ostream& os, const ModInt& n){ return (os << n()); } friend ModInt mod_pow(ModInt x, long long n){ ModInt ans = 1; while(n){ if(n & 1) ans *= x; x *= x, n >>= 1; } return ans; } }; #define MOD 1000000007 using mod = ModInt<MOD>; mod dp[4010][4010]; mod out[4010][4010]; int main(){ make(); cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; mod ans = 0; rep(i,n){ int a,b; cin >> a >> b; ans -= comb(2*a+2*b,2*a); dp[2000-a][2000-b]+=1; out[2000+a][2000+b]+=1; } rep(i,4001){ rep(j,4001){ if(i!=0)dp[i][j] += dp[i-1][j]; if(j!=0)dp[i][j] += dp[i][j-1]; ans += dp[i][j] * out[i][j]; } } cout << ans/2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:129:5: error: 'make' was not declared in this scope 129 | make(); | ^~~~ a.cc:138:16: error: 'comb' was not declared in this scope; did you mean 'wctomb'? 138 | ans -= comb(2*a+2*b,2*a); | ^~~~ | wctomb
s075848833
p04051
C++
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/ /*Header file starts here*/ //#include<bits/stdc++.h> #include<vector> #include<list> #include<map> #include<set> #include<queue> #include<stack> #include<bitset> #include<algorithm> #include<iostream> #include<iomanip> #include<cstdio> #include<cmath> #include<cstdlib> #include<iterator> #include<cctype> #include<climits> #include<string> #include<sstream> #include<cstring> #include<ctime> /*Header file ends here*/ /*Macro starts here*/ #define fasterInOut ios::sync_with_stdio(false); cin.tie(0); #define fin(in) freopen("in.txt", "r", stdin) #define fout(out) freopen("out.txt", "w", stdout) #define pb push_back #define ll long long #define lld I64d//for CF submissions #define rh cout<<"Reached Here\n" #define inf LLONG_MAX #define neginf LLONG_MIN #define forit(it,s) for(__typeof((s).end()) it=(s).begin(); it!= (s).end(); it++) #define string_reverse(s) reverse(s.begin(), s.end())//Vector also can be reversed with this function #define memz(x) memset(x, 0, sizeof(x)); #define memneg(x) memset(x, -1, sizeof(x)); //Geometry & Maths #define gcd(a,b) __gcd(a,b) #define lcm(a, b) (a*b)/gcd(a, b) #define pi acos(-1.0) #define negmod(ans, x, m) ll y= (-1*x)%m; if(y== 0) ans= 0; else ans= m-y;//for negative mod only i.e. when x<0. Undefined when m<0 #define dis(x1, y1, x2, y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) #define t_area(a, b, c, s) sqrt(s*(s-a)*(s-b)*(s-c))// s= (a+b+c)/2.0 #define t_angle(a, b, c) acos((a*a+b*b-c*c)/(2*a*b))// returns angle C in radian. a, b, c are anti-clockwise formatted and side a and b form angle C #define pointPos(x1, y1, x2, y2, x3, y3) ((x2-x1)*(y3-y1))-((x3-x1)*(y2-y1));/*returns NEGATIVE if the Point P3 is on the RIGHT side of the line P1P2, otherwise returns POSITIVE in case of LEFT and ZERO when the point is on the line*/ #define t_areaWithPoints(x1, y1, x2, y2, x3, y3) abs(0.5*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)));//returns the area of a triangle formed by P1, p2, p3 //Base Conversions #define toBin(bin, n) bin= bitset<8>(n).to_string()//returns a corresponding 8 bit Binary string 'bin' of integer 'n' #define toOct(oct, n, ch) /*char ch[100]*/sprintf(ch, "%o", n); oct= ch;//returns a string 'oct'(maximum 100 length): Octal represent of number 'n' #define toHex(hex, n, ch) /*char ch[100]*/sprintf(ch, "%x", n); hex= ch;//returns a string 'hex'(maximum 100 length): Hexadecimal represent of number 'n' #define intToString(s, n, itos) /*stringstream itos;*/ itos<<n; s= itos.str();//converts a number 'n' to a string 's' #define stringToint(n, s) stringstream stoi(s); stoi>>n;//converts a string 's' to a number 'n'---ONLY ONCE USABLE--- //Others #define substring(s1, s2) strstr(s1.c_str(), s2.c_str())//returns true if s1 contains s2 in O(n^2) complexity #define strCharRemove(s, c) s.erase(remove(s.begin(), s.end(), c), s.end());//Removes all character 'c' from the string 's' #define strLastCharRemove(s) s.erase(s.end()-1)//Removes last(position is given by s.end()-1) character form string 's' #define vectorEraseSingle(v, pos) v.erase(v.begin()+pos)//Erases an element from "pos' position in zero based index from the vector 'v' #define vectorEraseRange(v, spos, fpos) v.erase(v.begin()+spos, v.begin()+fpos)//Erases range inclusive spos' to EXCLUSIVE(without) 'fpos' from vector 'v' #define lowerBound(v, elem) (lower_bound(v.begin(), v.end(), elem))-v.begin();/*returns the lower bound of 'elem' in integer(ZERO BASED INDEX), where lower bound means the LEFTMOST index where there is any integer which is GREATER OR EQUAL to 'elem'.*/ #define upperBound(v, elem) (upper_bound(v.begin(), v.end(), elem))-v.begin();/*returns the upper bound of 'elem' in integer(ZERO BASED INDEX), where upper bound means the LEFTMOST index where there is any integer which is GREATER than 'elem'.*/ #define setLowerBound(st, elem) st.lower_bound(elem);/*returns the lower bound ITERATOR of 'elem' in the stl set 'st', where lower bound means the LEFTMOST index where there is any integer which is GREATER OR EQUAL to 'elem'.*/ #define setUpperBound(st, elem) st.upper_bound(elem);/*returns the upper bound ITERATOR of 'elem' in the stl set 'st', where upper bound means the LEFTMOST index where there is any integer which is GREATER than 'elem'.*/ #define clearPQ(pq, type) pq= priority_queue<type>()/*It clears a priority queue by redeclaration*/ #define minPQ(PQ_name, type) priority_queue<type, vector<type>, greater<type> > PQ_name;/*min priority queue with built in type i.e int or long long etc. */ #define sortArr(arr, sz) sort(arr+1, arr+(sz+1));/*Sorts an array from index 1 to index 'sz'*/ /*Macro ends here*/ /*Frequently used Function starts here*/ //Bit set /*ll Set(ll mask, ll pos){return mask = (mask OR ((ll)1<<pos));}*//*Sets pos'th bit HIGH of the mask and returns*//**Replace OR by Bitwise OR sign when using**/ bool check(ll mask, ll pos){return (bool)(mask & ((ll)1<<pos));}/*Checks if the pos'th bit is HIGH or not of the mask*/ /*Frequently used Function ends here*/ using namespace std; //#define int ll #define all(x) x.begin() , x.end() #define PB push_back #define F first #define S second #define _sz(x) (int)x.size() #define debug(x) cerr << #x << " = " << x << endl typedef long long ll ; typedef pair<int , int> pii ; const int MAX_N = 2010 , MAX_X = 2010 * 2 , MAX_Y = 2010 * 4 , MAX_M = 200 * 1000 + 19 ; const int inf = 2e9 + 19 ; const int MOD = 1e9 + 7 ; int a[MAX_M] , b[MAX_M] , n ; int dp[MAX_X][MAX_X] , C[MAX_Y][MAX_X] ; ll ans = 0 ; ll mul(ll x , ll y) { return 1LL * x * y % MOD ; } ll sum(ll x , ll y) { x += y; if (x < 0) x += MOD; else if (x >= MOD) x -= MOD; return x; } int main() { ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ; cin >> n ; for (int i = 1 ; i <= n ; i ++) { cin >> a[i] >> b[i] ; dp[MAX_N - a[i]][MAX_N - b[i]] ++ ; } for (int i = 1 ; i < MAX_X ; i ++) for (int j = 1 ; j < MAX_X ; j ++) dp[i][j] = sum(sum(dp[i][j] , dp[i - 1][j]) , dp[i][j - 1]) ; for (int i = 0 ; i < MAX_Y ; i ++) { C[i][0] = C[i][i] = 1 ; for (int j = 1 ; j < min(i , MAX_X) ; j ++) { C[i][j] = sum(C[i - 1][j] , C[i - 1][j - 1]) ; //if (i == 8038) // debug(j) ; } } for (int i = 1 ; i <= n ; i ++) ans = sum(ans , dp[MAX_N + a[i]][MAX_N + b[i]]) , ans = sum(ans, -C[a[i] * 2 + b[i] * 2][a[i] * 2]); ans = mul(ans , (MOD + 1) / 2) ; if (ans < 0) ans += MOD ; cout << ans ; return (0) ; }
a.cc:31:12: error: 'long long long' is too long for GCC 31 | #define ll long long | ^~~~ a.cc:99:19: note: in expansion of macro 'll' 99 | typedef long long ll ; | ^~ a.cc:31:17: error: 'long long long' is too long for GCC 31 | #define ll long long | ^~~~ a.cc:99:19: note: in expansion of macro 'll' 99 | typedef long long ll ; | ^~ a.cc:31:17: error: declaration does not declare anything [-fpermissive] 31 | #define ll long long | ^~~~ a.cc:99:19: note: in expansion of macro 'll' 99 | typedef long long ll ; | ^~ a.cc:34:13: error: expected unqualified-id before numeric constant 34 | #define inf LLONG_MAX | ^~~~~~~~~ a.cc:103:11: note: in expansion of macro 'inf' 103 | const int inf = 2e9 + 19 ; | ^~~
s910630543
p04051
C++
/* بسم الله الرحمن الرحیم */ /* شهید حاج قاسم سلیمانی انتقام سخت نزدیک است */ #include <bits/stdc++.h> using namespace std ; #define int ll #define all(x) x.begin() , x.end() #define PB push_back #define F first #define S second #define _sz(x) (int)x.size() #define debug(x) cerr << #x << " = " << x << endl typedef long long ll ; typedef pair<int , int> pii ; const int MAX_N = 2010 , MAX_X = 2010 * 2 , MAX_Y = 2010 * 4 , MAX_M = 200 * 1000 + 19 ; const int inf = 2e9 + 19 ; const int MOD = 1e9 + 7 ; ll a[MAX_M] , b[MAX_M] , n ; int dp[MAX_X][MAX_X] , C[MAX_Y][MAX_X] ; ll ans = 0 ; int mul(ll x , ll y) { return 1LL * x * y % MOD ; } int sum(ll x , ll y) { x += y; if (x < 0) x += MOD; else if (x >= MOD) x -= MOD; return x; } int main() { ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ; cin >> n ; for (int i = 1 ; i <= n ; i ++) { cin >> a[i] >> b[i] ; dp[MAX_N - a[i]][MAX_N - b[i]] ++ ; } for (int i = 1 ; i < MAX_X ; i ++) for (int j = 1 ; j < MAX_X ; j ++) dp[i][j] = sum(sum(dp[i][j] , dp[i - 1][j]) , dp[i][j - 1]) ; for (int i = 0 ; i < MAX_Y ; i ++) { C[i][0] = C[i][i] = 1 ; for (int j = 1 ; j < min(i , MAX_X) ; j ++) { C[i][j] = sum(C[i - 1][j] , C[i - 1][j - 1]) ; //if (i == 8038) // debug(j) ; } } for (int i = 1 ; i <= n ; i ++) ans = sum(ans , dp[MAX_N + a[i]][MAX_N + b[i]]) , ans = sum(ans, -C[a[i] * 2 + b[i] * 2][a[i] * 2]); ans = (mul(ans , (MOD + 1)) / 2) % MOD ; if (ans < 0) ans += MOD ; cout << ans ; return (0) ; }
a.cc:10:13: error: '::main' must return 'int' 10 | #define int ll | ^~ a.cc:45:1: note: in expansion of macro 'int' 45 | int main() { | ^~~
s268183133
p04051
C++
/* بسم الله الرحمن الرحیم */ /* شهید حاج قاسم سلیمانی انتقام سخت نزدیک است */ #include <bits/stdc++.h> using namespace std ; #define int ll #define all(x) x.begin() , x.end() #define PB push_back #define F first #define S second #define _sz(x) (int)x.size() #define debug(x) cerr << #x << " = " << x << endl typedef long long ll ; typedef pair<int , int> pii ; const int MAX_N = 2010 , MAX_X = 2010 * 2 , MAX_Y = 2010 * 4 , MAX_M = 200 * 1000 + 19 ; const int inf = 2e9 + 19 ; const int MOD = 1e9 + 7 ; ll a[MAX_M] , b[MAX_M] , n ; int dp[MAX_X][MAX_X] , C[MAX_Y][MAX_X] ; ll ans = 0 ; int mul(ll x , ll y) { return 1LL * x * y % MOD ; } int sum(ll x , ll y) { x += y; if (x < 0) x += MOD; else if (x >= MOD) x -= MOD; return x; } int main() { ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ; cin >> n ; for (int i = 1 ; i <= n ; i ++) { cin >> a[i] >> b[i] ; dp[MAX_N - a[i]][MAX_N - b[i]] ++ ; } for (int i = 1 ; i < MAX_X ; i ++) for (int j = 1 ; j < MAX_X ; j ++) dp[i][j] = sum(sum(dp[i][j] , dp[i - 1][j]) , dp[i][j - 1]) ; for (int i = 0 ; i < MAX_Y ; i ++) { C[i][0] = C[i][i] = 1 ; for (int j = 1 ; j < min(i , MAX_X) ; j ++) { C[i][j] = sum(C[i - 1][j] , C[i - 1][j - 1]) ; //if (i == 8038) // debug(j) ; } } for (int i = 1 ; i <= n ; i ++) ans = sum(ans , dp[MAX_N + a[i]][MAX_N + b[i]]) , ans = sum(ans, -C[a[i] * 2 + b[i] * 2][a[i] * 2]); ans = (mul(ans , (MOD + 1)) / 2) % MOD ; if (ans < 0) ans += MOD ; cout << ans ; return (0) ; }
a.cc:10:13: error: '::main' must return 'int' 10 | #define int ll | ^~ a.cc:45:1: note: in expansion of macro 'int' 45 | int main() { | ^~~
s151207768
p04051
C++
/* بسم الله الرحمن الرحیم */ /* شهید حاج قاسم سلیمانی انتقام سخت نزدیک است */ #include <bits/stdc++.h> using namespace std ; #define all(x) x.begin() , x.end() #define PB push_back #define F first #define S second #define _sz(x) (int)x.size() #define debug(x) cerr << #x << " = " << x << endl typedef long long ll ; typedef pair<int , int> pii ; const int MAX_N = 2019 , MAX_X = 4019 , MAX_Y = 8019 ; const int inf = 2e9 + 19 ; const int MOD = 1e9 + 7 ; int Fact[MAX_Y] , FactRev[MAX_Y] , a[MAX_N * 100] , b[MAX_N * 100] , dp[MAX_X][MAX_X] , n , C[MAX_Y][MAX_X] ; ll ans = 0 ; int mul(int x , int y) { return 1LL * x * y % MOD ; } int sum(int x , int y) { x += y; if (x < 0) x += MOD; else if (x >= MOD) x -= MOD; return x; } int main() { ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ; cin >> n ; for (int i = 1 ; i <= n ; i ++) { cin >> a[i] >> b[i] ; dp[MAX_N - a[i]][MAX_N - b[i]] ++ ; } for (int i = 1 ; i < MAX_X ; i ++) for (int j = 1 ; j < MAX_X ; j ++) dp[i][j] = sum(sum(dp[i][j] , dp[i - 1][j]) , dp[i][j - 1]) ; for (int i = 0 ; i<MAX_Y ; i ++){ C[i][0] = C[i][i] = 1 ; for (int j = 1 ; j < min(i , MAX_X) ; j ++) C[i][j] = sum(C[i - 1][j] , C[i - 1][j - 1]) % MOD ; } for (int i = 1 ; i <= n ; i ++) ans = sum(ans , dp[MAX_N + a[i]][MAX_N + b[i]]) , ans = sum(ans, -C[a[i] * 2 + b[i] * 2][a[i] * 2]); ans = mul(ans, pw(2, MOD - 2)) ; cout << ans ; return (0) ; }
a.cc: In function 'int main()': a.cc:58:24: error: 'pw' was not declared in this scope; did you mean 'pow'? 58 | ans = mul(ans, pw(2, MOD - 2)) ; | ^~ | pow
s431853499
p04051
C++
/* بسم الله الرحمن الرحیم */ /* شهید حاج قاسم سلیمانی انتقام سخت نزدیک است */ #include <bits/stdc++.h> using namespace std ; #define all(x) x.begin() , x.end() #define PB push_back #define F first #define S second #define _sz(x) (int)x.size() #define debug(x) cerr << #x << " = " << x << endl typedef long long ll ; typedef pair<int , int> pii ; const int MAX_N = 2019 , MAX_X = 4019 , MAX_Y = 8019 ; const int inf = 2e9 + 19 ; const int MOD = 1e9 + 7 ; int Fact[MAX_Y] , FactRev[MAX_Y] , a[MAX_N * 100] , b[MAX_N * 100] , dp[MAX_X][MAX_X] , n , C[MAX_Y][MAX_X] ; ll ans = 0 ; int mul(int x , int y) { return 1LL * x * y % MOD ; } int sum(int x , int y) { x += y; if (x < 0) x += MOD; else if (x >= MOD) x -= MOD; return x; } int pw(ll x , ll y) { ll res = 1 ; while (y) { if (y & 1) res = mul(res, x); x = mul(x, x); y >>= 1 ; } return res; } int main() { ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ; prep() ; cin >> n ; for (int i = 1 ; i <= n ; i ++) { cin >> a[i] >> b[i] ; dp[MAX_N - a[i]][MAX_N - b[i]] ++ ; } for (int i = 1 ; i < MAX_X ; i ++) for (int j = 1 ; j < MAX_X ; j ++) dp[i][j] = sum(sum(dp[i][j] , dp[i - 1][j]) , dp[i][j - 1]) ; for (int i = 0 ; i<MAX_Y ; i ++){ C[i][0] = C[i][i] = 1 ; for (int j = 1 ; j < min(i , MAX_X) ; j ++) C[i][j] = sum(C[i - 1][j] , C[i - 1][j - 1]) % MOD ; } for (int i = 1 ; i <= n ; i ++) ans = sum(ans , dp[MAX_N + a[i]][MAX_N + b[i]]) , ans = sum(ans, -C[a[i] * 2 + b[i] * 2][a[i] * 2]); ans = mul(ans, pw(2, MOD - 2)) ; cout << ans ; return (0) ; }
a.cc: In function 'int main()': a.cc:54:9: error: 'prep' was not declared in this scope 54 | prep() ; | ^~~~
s317955010
p04051
C++
v#include<bits/stdc++.h> using namespace std; const int N = 200 * 1000 + 20, mod = 1e9 + 7, X = 4000 + 20; int x[N], y[N], dp[X][X], c[X][X], n, ans; int sum(int a, int b) { return ((1LL * a + b) % mod + mod) % mod; } int mul(int a, int b) { return ((1LL * a * b) % mod + mod) % mod; } int pw(int a, int b) { int res = 1, tmp = a; while (b) { if (b & 1) res = mul(res, tmp); tmp = mul(tmp, tmp); b >>= 1; } return res; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i]; for (int i = 0; i <= 4000; i++) { c[i][0] = 1; for (int j = 1; j <= i; j++) c[i][j] = sum(c[i - 1][j], c[i - 1][j - 1]); } for (int i = 0; i < n; i++) dp[2000 - x[i]][2000 - y[i]]++; for (int i = 0; i <= 4000; i++) for (int j = 0; j <= 4000; j++) { if (i) dp[i][j] = sum(dp[i][j], dp[i - 1][j]); if (j) dp[i][j] = sum(dp[i][j], dp[i][j - 1]); } for (int i = 0; i < n; i++) ans = sum(ans, dp[x[i] + 2000][y[i] + 2000]); for (int i = 0; i < n; i++) ans = sum(ans, -c[x[i] + x[i] + y[i] + y[i]][x[i] + x[i]]); ans = mul(ans, pw(2, mod - 2)); return cout << ans << "\n", 0; }
a.cc:1:2: error: stray '#' in program 1 | v#include<bits/stdc++.h> | ^ a.cc:1:1: error: 'v' does not name a type 1 | v#include<bits/stdc++.h> | ^ a.cc: In function 'int main()': a.cc:27:5: error: 'ios_base' has not been declared 27 | ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); | ^~~~~~~~ a.cc:27:39: error: 'cin' was not declared in this scope 27 | ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); | ^~~ a.cc:27:51: error: 'cout' was not declared in this scope 27 | ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); | ^~~~
s842274925
p04051
C++
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back const int MAXN = 2e5 + 100, maxval = 2010, mod = 1e9 + 7; int n; int a[MAXN], b[MAXN]; int dp[maxval << 1][maxval << 1]; long long fact[MAXN], invfact[MAXN]; long long ans; long long pw(long long a, long long b) { if (!b) return 1LL; long long tmp = pw(a, b / 2); tmp = tmp * tmp % mod; if (b & 1) tmp = tmp * a % mod; return tmp; } inline void sum(int &a, int b) { a += b; if (a >= mod) a -= mod; else if (a < 0) a += mod; } long long comb(int n, int r) { return fact[n] * (invfact[r] * invfact[n - r] % mod) % mod; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); fact[0] = 1; invfact[0] = pw(fact[0], mod - 2); for (int i = 1; i < MAXN; i++) { fact[i] = fact[i - 1] * i % mod; invfact[i] = pw(fact[i], mod - 2); } cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; dp[maxval - a[i]][maxval - b[i]]++; } for (int i = 0; i < maxval * 2 - 2; i++) for (int j = 0; j < maxval * 2 - 2; j++) { sum(dp[i + 1][j], dp[i][j]); sum(dp[i][j + 1], dp[i][j]); } for (int i = 0; i < n; i++) ans = (ans + dp[maxval + a[i]][maxval + b[i]]) % mod; for (int i = 0; i < n; i++) ans = (ans - comb(2 * a[i] + 2 * b[i], 2 * a[i]) + mod) % mod; cout << ans * invfact(2) % mod << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:68:26: error: 'invfact' cannot be used as a function 68 | cout << ans * invfact(2) % mod << '\n'; | ~~~~~~~^~~
s603246528
p04051
C++
#include <bits/stdc++.h> #define BIT(n) (1LL << (n)) #define BITF(n, i) (((n) >> i) & 1) #define REP(i, n) for (int i = 0; i < n; i++) #define REPB(i, n) for (int i = 0; i < BIT(n); i++) #define REPS(i, x) for (int i = 1; i <= x; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define REPZ(i, x) for (int i = 0; i <= x; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORA(i, n) for (auto &&i : n) #define FORS(i, m, n) for (int i = m; i <= n; i++) using namespace std; #define PRINTARR(x, y) \ cerr << #x << "=\n"; \ for (auto itr = x; itr != y; itr++) cerr << *itr << " "; \ cerr << endl; #define PRINTARR2(x, i0, i1) \ cerr << #x << "=\n"; \ for (int ii0 = 0; ii0 < i0; ii0++) { \ for (int ii1 = 0; ii1 < i1; ii1++) cerr << x[ii0][ii1] << " "; \ cerr << endl; \ } #define DUMPOUT cerr // vector template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } // pair template <typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> &pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; } // vector template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "{"; REP(i, (int)vec.size()) os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", "); os << "}"; return os; } // map template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) { os << "{"; FORA(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; } os << "}"; return os; } // set template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) { os << "{"; FORA(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; } os << "}"; return os; } void dump_func() { DUMPOUT << endl; } template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) DUMPOUT << ", "; dump_func(std::move(tail)...); } #ifdef DEBUG_ #define DEB #define DUMP(...) \ DUMPOUT << " " << string(#__VA_ARGS__) << ": " \ << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \ << " ", \ dump_func(__VA_ARGS__) #else #define DEB if (false) #define DUMP(...) #endif #define ALL(v) v.begin(), v.end() #define fst first #define snd second #define mp make_pair #define pb push_back #define epb emplace_back #define int long long #define pint pair<int, int> #define ld long double using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <class T> using vec = std::vector<T>; template <class T> void print(const T &x) { cout << x << "\n"; } const int MOD = 1000000007, INF0 = 1061109567, INF = INF0 * INF0; const double EPS = 1e-10, PI = acos(-1.0); const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; #define MAXN 200200 #define MAXSIZE (1 << 25) /* Fast Fourier/Cosine/Sine Transform dimension :one data length :power of 2 decimation :frequency radix :4, 2 data :inplace table :use functions cdft: Complex Discrete Fourier Transform rdft: Real Discrete Fourier Transform ddct: Discrete Cosine Transform ddst: Discrete Sine Transform dfct: Cosine Transform of RDFT (Real Symmetric DFT) dfst: Sine Transform of RDFT (Real Anti-symmetric DFT) function prototypes void cdft(signed, signed, double *, signed *, double *); void rdft(signed, signed, double *, signed *, double *); void ddct(signed, signed, double *, signed *, double *); void ddst(signed, signed, double *, signed *, double *); void dfct(signed, double *, double *, signed *, double *); void dfst(signed, double *, double *, signed *, double *); -------- Complex DFT (Discrete Fourier Transform) -------- [definition] <case1> X[k] = sum_j=0^n-1 x[j]*exp(2*pi*i*j*k/n), 0<=k<n <case2> X[k] = sum_j=0^n-1 x[j]*exp(-2*pi*i*j*k/n), 0<=k<n (notes: sum_j=0^n-1 is a summation from j=0 to n-1) [usage] <case1> ip[0] = 0; // first time only cdft(2*n, 1, a, ip, w); <case2> ip[0] = 0; // first time only cdft(2*n, -1, a, ip, w); [parameters] 2*n :data length (signed) n >= 1, n = power of 2 a[0...2*n-1] :input/output data (double *) input data a[2*j] = Re(x[j]), a[2*j+1] = Im(x[j]), 0<=j<n output data a[2*k] = Re(X[k]), a[2*k+1] = Im(X[k]), 0<=k<n ip[0...*] :work area for bit reversal (signed *) length of ip >= 2+sqrt(n) strictly, length of ip >= 2+(1<<(signed)(log(n+0.5)/log(2))/2). ip[0],ip[1] are posigneders of the cos/sin table. w[0...n/2-1] :cos/sin table (double *) w[],ip[] are initialized if ip[0] == 0. [remark] Inverse of cdft(2*n, -1, a, ip, w); is cdft(2*n, 1, a, ip, w); for (j = 0; j <= 2 * n - 1; j++) { a[j] *= 1.0 / n; } . -------- Real DFT / Inverse of Real DFT -------- [definition] <case1> RDFT R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2 I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0<k<n/2 <case2> IRDFT (excluding scale) a[k] = (R[0] + R[n/2]*cos(pi*k))/2 + sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) + sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k<n [usage] <case1> ip[0] = 0; // first time only rdft(n, 1, a, ip, w); <case2> ip[0] = 0; // first time only rdft(n, -1, a, ip, w); [parameters] n :data length (signed) n >= 2, n = power of 2 a[0...n-1] :input/output data (double *) <case1> output data a[2*k] = R[k], 0<=k<n/2 a[2*k+1] = I[k], 0<k<n/2 a[1] = R[n/2] <case2> input data a[2*j] = R[j], 0<=j<n/2 a[2*j+1] = I[j], 0<j<n/2 a[1] = R[n/2] ip[0...*] :work area for bit reversal (signed *) length of ip >= 2+sqrt(n/2) strictly, length of ip >= 2+(1<<(signed)(log(n/2+0.5)/log(2))/2). ip[0],ip[1] are posigneders of the cos/sin table. w[0...n/2-1] :cos/sin table (double *) w[],ip[] are initialized if ip[0] == 0. [remark] Inverse of rdft(n, 1, a, ip, w); is rdft(n, -1, a, ip, w); for (j = 0; j <= n - 1; j++) { a[j] *= 2.0 / n; } . -------- DCT (Discrete Cosine Transform) / Inverse of DCT -------- [definition] <case1> IDCT (excluding scale) C[k] = sum_j=0^n-1 a[j]*cos(pi*j*(k+1/2)/n), 0<=k<n <case2> DCT C[k] = sum_j=0^n-1 a[j]*cos(pi*(j+1/2)*k/n), 0<=k<n [usage] <case1> ip[0] = 0; // first time only ddct(n, 1, a, ip, w); <case2> ip[0] = 0; // first time only ddct(n, -1, a, ip, w); [parameters] n :data length (signed) n >= 2, n = power of 2 a[0...n-1] :input/output data (double *) output data a[k] = C[k], 0<=k<n ip[0...*] :work area for bit reversal (signed *) length of ip >= 2+sqrt(n/2) strictly, length of ip >= 2+(1<<(signed)(log(n/2+0.5)/log(2))/2). ip[0],ip[1] are posigneders of the cos/sin table. w[0...n*5/4-1] :cos/sin table (double *) w[],ip[] are initialized if ip[0] == 0. [remark] Inverse of ddct(n, -1, a, ip, w); is a[0] *= 0.5; ddct(n, 1, a, ip, w); for (j = 0; j <= n - 1; j++) { a[j] *= 2.0 / n; } . -------- DST (Discrete Sine Transform) / Inverse of DST -------- [definition] <case1> IDST (excluding scale) S[k] = sum_j=1^n A[j]*sin(pi*j*(k+1/2)/n), 0<=k<n <case2> DST S[k] = sum_j=0^n-1 a[j]*sin(pi*(j+1/2)*k/n), 0<k<=n [usage] <case1> ip[0] = 0; // first time only ddst(n, 1, a, ip, w); <case2> ip[0] = 0; // first time only ddst(n, -1, a, ip, w); [parameters] n :data length (signed) n >= 2, n = power of 2 a[0...n-1] :input/output data (double *) <case1> input data a[j] = A[j], 0<j<n a[0] = A[n] output data a[k] = S[k], 0<=k<n <case2> output data a[k] = S[k], 0<k<n a[0] = S[n] ip[0...*] :work area for bit reversal (signed *) length of ip >= 2+sqrt(n/2) strictly, length of ip >= 2+(1<<(signed)(log(n/2+0.5)/log(2))/2). ip[0],ip[1] are posigneders of the cos/sin table. w[0...n*5/4-1] :cos/sin table (double *) w[],ip[] are initialized if ip[0] == 0. [remark] Inverse of ddst(n, -1, a, ip, w); is a[0] *= 0.5; ddst(n, 1, a, ip, w); for (j = 0; j <= n - 1; j++) { a[j] *= 2.0 / n; } . -------- Cosine Transform of RDFT (Real Symmetric DFT) -------- [definition] C[k] = sum_j=0^n a[j]*cos(pi*j*k/n), 0<=k<=n [usage] ip[0] = 0; // first time only dfct(n, a, t, ip, w); [parameters] n :data length - 1 (signed) n >= 2, n = power of 2 a[0...n] :input/output data (double *) output data a[k] = C[k], 0<=k<=n t[0...n/2] :work area (double *) ip[0...*] :work area for bit reversal (signed *) length of ip >= 2+sqrt(n/4) strictly, length of ip >= 2+(1<<(signed)(log(n/4+0.5)/log(2))/2). ip[0],ip[1] are posigneders of the cos/sin table. w[0...n*5/8-1] :cos/sin table (double *) w[],ip[] are initialized if ip[0] == 0. [remark] Inverse of a[0] *= 0.5; a[n] *= 0.5; dfct(n, a, t, ip, w); is a[0] *= 0.5; a[n] *= 0.5; dfct(n, a, t, ip, w); for (j = 0; j <= n; j++) { a[j] *= 2.0 / n; } . -------- Sine Transform of RDFT (Real Anti-symmetric DFT) -------- [definition] S[k] = sum_j=1^n-1 a[j]*sin(pi*j*k/n), 0<k<n [usage] ip[0] = 0; // first time only dfst(n, a, t, ip, w); [parameters] n :data length + 1 (signed) n >= 2, n = power of 2 a[0...n-1] :input/output data (double *) output data a[k] = S[k], 0<k<n (a[0] is used for work area) t[0...n/2-1] :work area (double *) ip[0...*] :work area for bit reversal (signed *) length of ip >= 2+sqrt(n/4) strictly, length of ip >= 2+(1<<(signed)(log(n/4+0.5)/log(2))/2). ip[0],ip[1] are posigneders of the cos/sin table. w[0...n*5/8-1] :cos/sin table (double *) w[],ip[] are initialized if ip[0] == 0. [remark] Inverse of dfst(n, a, t, ip, w); is dfst(n, a, t, ip, w); for (j = 1; j <= n - 1; j++) { a[j] *= 2.0 / n; } . Appendix : The cos/sin table is recalculated when the larger table required. w[] and ip[] are compatible with all routines. */ void cdft(signed n, signed isgn, double *a, signed *ip, double *w) { void makewt(signed nw, signed *ip, double *w); void bitrv2(signed n, signed *ip, double *a); void bitrv2conj(signed n, signed *ip, double *a); void cftfsub(signed n, double *a, double *w); void cftbsub(signed n, double *a, double *w); if (n > (ip[0] << 2)) { makewt(n >> 2, ip, w); } if (n > 4) { if (isgn >= 0) { bitrv2(n, ip + 2, a); cftfsub(n, a, w); } else { bitrv2conj(n, ip + 2, a); cftbsub(n, a, w); } } else if (n == 4) { cftfsub(n, a, w); } } void rdft(signed n, signed isgn, double *a, signed *ip, double *w) { void makewt(signed nw, signed *ip, double *w); void makect(signed nc, signed *ip, double *c); void bitrv2(signed n, signed *ip, double *a); void cftfsub(signed n, double *a, double *w); void cftbsub(signed n, double *a, double *w); void rftfsub(signed n, double *a, signed nc, double *c); void rftbsub(signed n, double *a, signed nc, double *c); signed nw, nc; double xi; nw = ip[0]; if (n > (nw << 2)) { nw = n >> 2; makewt(nw, ip, w); } nc = ip[1]; if (n > (nc << 2)) { nc = n >> 2; makect(nc, ip, w + nw); } if (isgn >= 0) { if (n > 4) { bitrv2(n, ip + 2, a); cftfsub(n, a, w); rftfsub(n, a, nc, w + nw); } else if (n == 4) { cftfsub(n, a, w); } xi = a[0] - a[1]; a[0] += a[1]; a[1] = xi; } else { a[1] = 0.5 * (a[0] - a[1]); a[0] -= a[1]; if (n > 4) { rftbsub(n, a, nc, w + nw); bitrv2(n, ip + 2, a); cftbsub(n, a, w); } else if (n == 4) { cftfsub(n, a, w); } } } void ddct(signed n, signed isgn, double *a, signed *ip, double *w) { void makewt(signed nw, signed *ip, double *w); void makect(signed nc, signed *ip, double *c); void bitrv2(signed n, signed *ip, double *a); void cftfsub(signed n, double *a, double *w); void cftbsub(signed n, double *a, double *w); void rftfsub(signed n, double *a, signed nc, double *c); void rftbsub(signed n, double *a, signed nc, double *c); void dctsub(signed n, double *a, signed nc, double *c); signed j, nw, nc; double xr; nw = ip[0]; if (n > (nw << 2)) { nw = n >> 2; makewt(nw, ip, w); } nc = ip[1]; if (n > nc) { nc = n; makect(nc, ip, w + nw); } if (isgn < 0) { xr = a[n - 1]; for (j = n - 2; j >= 2; j -= 2) { a[j + 1] = a[j] - a[j - 1]; a[j] += a[j - 1]; } a[1] = a[0] - xr; a[0] += xr; if (n > 4) { rftbsub(n, a, nc, w + nw); bitrv2(n, ip + 2, a); cftbsub(n, a, w); } else if (n == 4) { cftfsub(n, a, w); } } dctsub(n, a, nc, w + nw); if (isgn >= 0) { if (n > 4) { bitrv2(n, ip + 2, a); cftfsub(n, a, w); rftfsub(n, a, nc, w + nw); } else if (n == 4) { cftfsub(n, a, w); } xr = a[0] - a[1]; a[0] += a[1]; for (j = 2; j < n; j += 2) { a[j - 1] = a[j] - a[j + 1]; a[j] += a[j + 1]; } a[n - 1] = xr; } } void ddst(signed n, signed isgn, double *a, signed *ip, double *w) { void makewt(signed nw, signed *ip, double *w); void makect(signed nc, signed *ip, double *c); void bitrv2(signed n, signed *ip, double *a); void cftfsub(signed n, double *a, double *w); void cftbsub(signed n, double *a, double *w); void rftfsub(signed n, double *a, signed nc, double *c); void rftbsub(signed n, double *a, signed nc, double *c); void dstsub(signed n, double *a, signed nc, double *c); signed j, nw, nc; double xr; nw = ip[0]; if (n > (nw << 2)) { nw = n >> 2; makewt(nw, ip, w); } nc = ip[1]; if (n > nc) { nc = n; makect(nc, ip, w + nw); } if (isgn < 0) { xr = a[n - 1]; for (j = n - 2; j >= 2; j -= 2) { a[j + 1] = -a[j] - a[j - 1]; a[j] -= a[j - 1]; } a[1] = a[0] + xr; a[0] -= xr; if (n > 4) { rftbsub(n, a, nc, w + nw); bitrv2(n, ip + 2, a); cftbsub(n, a, w); } else if (n == 4) { cftfsub(n, a, w); } } dstsub(n, a, nc, w + nw); if (isgn >= 0) { if (n > 4) { bitrv2(n, ip + 2, a); cftfsub(n, a, w); rftfsub(n, a, nc, w + nw); } else if (n == 4) { cftfsub(n, a, w); } xr = a[0] - a[1]; a[0] += a[1]; for (j = 2; j < n; j += 2) { a[j - 1] = -a[j] - a[j + 1]; a[j] -= a[j + 1]; } a[n - 1] = -xr; } } void dfct(signed n, double *a, double *t, signed *ip, double *w) { void makewt(signed nw, signed *ip, double *w); void makect(signed nc, signed *ip, double *c); void bitrv2(signed n, signed *ip, double *a); void cftfsub(signed n, double *a, double *w); void rftfsub(signed n, double *a, signed nc, double *c); void dctsub(signed n, double *a, signed nc, double *c); signed j, k, l, m, mh, nw, nc; double xr, xi, yr, yi; nw = ip[0]; if (n > (nw << 3)) { nw = n >> 3; makewt(nw, ip, w); } nc = ip[1]; if (n > (nc << 1)) { nc = n >> 1; makect(nc, ip, w + nw); } m = n >> 1; yi = a[m]; xi = a[0] + a[n]; a[0] -= a[n]; t[0] = xi - yi; t[m] = xi + yi; if (n > 2) { mh = m >> 1; for (j = 1; j < mh; j++) { k = m - j; xr = a[j] - a[n - j]; xi = a[j] + a[n - j]; yr = a[k] - a[n - k]; yi = a[k] + a[n - k]; a[j] = xr; a[k] = yr; t[j] = xi - yi; t[k] = xi + yi; } t[mh] = a[mh] + a[n - mh]; a[mh] -= a[n - mh]; dctsub(m, a, nc, w + nw); if (m > 4) { bitrv2(m, ip + 2, a); cftfsub(m, a, w); rftfsub(m, a, nc, w + nw); } else if (m == 4) { cftfsub(m, a, w); } a[n - 1] = a[0] - a[1]; a[1] = a[0] + a[1]; for (j = m - 2; j >= 2; j -= 2) { a[2 * j + 1] = a[j] + a[j + 1]; a[2 * j - 1] = a[j] - a[j + 1]; } l = 2; m = mh; while (m >= 2) { dctsub(m, t, nc, w + nw); if (m > 4) { bitrv2(m, ip + 2, t); cftfsub(m, t, w); rftfsub(m, t, nc, w + nw); } else if (m == 4) { cftfsub(m, t, w); } a[n - l] = t[0] - t[1]; a[l] = t[0] + t[1]; k = 0; for (j = 2; j < m; j += 2) { k += l << 2; a[k - l] = t[j] - t[j + 1]; a[k + l] = t[j] + t[j + 1]; } l <<= 1; mh = m >> 1; for (j = 0; j < mh; j++) { k = m - j; t[j] = t[m + k] - t[m + j]; t[k] = t[m + k] + t[m + j]; } t[mh] = t[m + mh]; m = mh; } a[l] = t[0]; a[n] = t[2] - t[1]; a[0] = t[2] + t[1]; } else { a[1] = a[0]; a[2] = t[0]; a[0] = t[1]; } } void dfst(signed n, double *a, double *t, signed *ip, double *w) { void makewt(signed nw, signed *ip, double *w); void makect(signed nc, signed *ip, double *c); void bitrv2(signed n, signed *ip, double *a); void cftfsub(signed n, double *a, double *w); void rftfsub(signed n, double *a, signed nc, double *c); void dstsub(signed n, double *a, signed nc, double *c); signed j, k, l, m, mh, nw, nc; double xr, xi, yr, yi; nw = ip[0]; if (n > (nw << 3)) { nw = n >> 3; makewt(nw, ip, w); } nc = ip[1]; if (n > (nc << 1)) { nc = n >> 1; makect(nc, ip, w + nw); } if (n > 2) { m = n >> 1; mh = m >> 1; for (j = 1; j < mh; j++) { k = m - j; xr = a[j] + a[n - j]; xi = a[j] - a[n - j]; yr = a[k] + a[n - k]; yi = a[k] - a[n - k]; a[j] = xr; a[k] = yr; t[j] = xi + yi; t[k] = xi - yi; } t[0] = a[mh] - a[n - mh]; a[mh] += a[n - mh]; a[0] = a[m]; dstsub(m, a, nc, w + nw); if (m > 4) { bitrv2(m, ip + 2, a); cftfsub(m, a, w); rftfsub(m, a, nc, w + nw); } else if (m == 4) { cftfsub(m, a, w); } a[n - 1] = a[1] - a[0]; a[1] = a[0] + a[1]; for (j = m - 2; j >= 2; j -= 2) { a[2 * j + 1] = a[j] - a[j + 1]; a[2 * j - 1] = -a[j] - a[j + 1]; } l = 2; m = mh; while (m >= 2) { dstsub(m, t, nc, w + nw); if (m > 4) { bitrv2(m, ip + 2, t); cftfsub(m, t, w); rftfsub(m, t, nc, w + nw); } else if (m == 4) { cftfsub(m, t, w); } a[n - l] = t[1] - t[0]; a[l] = t[0] + t[1]; k = 0; for (j = 2; j < m; j += 2) { k += l << 2; a[k - l] = -t[j] - t[j + 1]; a[k + l] = t[j] - t[j + 1]; } l <<= 1; mh = m >> 1; for (j = 1; j < mh; j++) { k = m - j; t[j] = t[m + k] + t[m + j]; t[k] = t[m + k] - t[m + j]; } t[0] = t[m + mh]; m = mh; } a[l] = t[0]; } a[0] = 0; } /* -------- initializing routines -------- */ #include <math.h> void makewt(signed nw, signed *ip, double *w) { void bitrv2(signed n, signed *ip, double *a); signed j, nwh; double delta, x, y; ip[0] = nw; ip[1] = 1; if (nw > 2) { nwh = nw >> 1; delta = atan(1.0) / nwh; w[0] = 1; w[1] = 0; w[nwh] = cos(delta * nwh); w[nwh + 1] = w[nwh]; if (nwh > 2) { for (j = 2; j < nwh; j += 2) { x = cos(delta * j); y = sin(delta * j); w[j] = x; w[j + 1] = y; w[nw - j] = y; w[nw - j + 1] = x; } bitrv2(nw, ip + 2, w); } } } void makect(signed nc, signed *ip, double *c) { signed j, nch; double delta; ip[1] = nc; if (nc > 1) { nch = nc >> 1; delta = atan(1.0) / nch; c[0] = cos(delta * nch); c[nch] = 0.5 * c[0]; for (j = 1; j < nch; j++) { c[j] = 0.5 * cos(delta * j); c[nc - j] = 0.5 * sin(delta * j); } } } /* -------- child routines -------- */ void bitrv2(signed n, signed *ip, double *a) { signed j, j1, k, k1, l, m, m2; double xr, xi, yr, yi; ip[0] = 0; l = n; m = 1; while ((m << 3) < l) { l >>= 1; for (j = 0; j < m; j++) { ip[m + j] = ip[j] + l; } m <<= 1; } m2 = 2 * m; if ((m << 3) == l) { for (k = 0; k < m; k++) { for (j = 0; j < k; j++) { j1 = 2 * j + ip[k]; k1 = 2 * k + ip[j]; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 += 2 * m2; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 -= m2; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 += 2 * m2; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; } j1 = 2 * k + m2 + ip[k]; k1 = j1 + m2; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; } } else { for (k = 1; k < m; k++) { for (j = 0; j < k; j++) { j1 = 2 * j + ip[k]; k1 = 2 * k + ip[j]; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 += m2; xr = a[j1]; xi = a[j1 + 1]; yr = a[k1]; yi = a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; } } } } void bitrv2conj(signed n, signed *ip, double *a) { signed j, j1, k, k1, l, m, m2; double xr, xi, yr, yi; ip[0] = 0; l = n; m = 1; while ((m << 3) < l) { l >>= 1; for (j = 0; j < m; j++) { ip[m + j] = ip[j] + l; } m <<= 1; } m2 = 2 * m; if ((m << 3) == l) { for (k = 0; k < m; k++) { for (j = 0; j < k; j++) { j1 = 2 * j + ip[k]; k1 = 2 * k + ip[j]; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 += 2 * m2; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 -= m2; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 += 2 * m2; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; } k1 = 2 * k + ip[k]; a[k1 + 1] = -a[k1 + 1]; j1 = k1 + m2; k1 = j1 + m2; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; k1 += m2; a[k1 + 1] = -a[k1 + 1]; } } else { a[1] = -a[1]; a[m2 + 1] = -a[m2 + 1]; for (k = 1; k < m; k++) { for (j = 0; j < k; j++) { j1 = 2 * j + ip[k]; k1 = 2 * k + ip[j]; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; j1 += m2; k1 += m2; xr = a[j1]; xi = -a[j1 + 1]; yr = a[k1]; yi = -a[k1 + 1]; a[j1] = yr; a[j1 + 1] = yi; a[k1] = xr; a[k1 + 1] = xi; } k1 = 2 * k + ip[k]; a[k1 + 1] = -a[k1 + 1]; a[k1 + m2 + 1] = -a[k1 + m2 + 1]; } } } void cftfsub(signed n, double *a, double *w) { void cft1st(signed n, double *a, double *w); void cftmdl(signed n, signed l, double *a, double *w); signed j, j1, j2, j3, l; double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; l = 2; if (n > 8) { cft1st(n, a, w); l = 8; while ((l << 2) < n) { cftmdl(n, l, a, w); l <<= 2; } } if ((l << 2) == n) { for (j = 0; j < l; j += 2) { j1 = j + l; j2 = j1 + l; j3 = j2 + l; x0r = a[j] + a[j1]; x0i = a[j + 1] + a[j1 + 1]; x1r = a[j] - a[j1]; x1i = a[j + 1] - a[j1 + 1]; x2r = a[j2] + a[j3]; x2i = a[j2 + 1] + a[j3 + 1]; x3r = a[j2] - a[j3]; x3i = a[j2 + 1] - a[j3 + 1]; a[j] = x0r + x2r; a[j + 1] = x0i + x2i; a[j2] = x0r - x2r; a[j2 + 1] = x0i - x2i; a[j1] = x1r - x3i; a[j1 + 1] = x1i + x3r; a[j3] = x1r + x3i; a[j3 + 1] = x1i - x3r; } } else { for (j = 0; j < l; j += 2) { j1 = j + l; x0r = a[j] - a[j1]; x0i = a[j + 1] - a[j1 + 1]; a[j] += a[j1]; a[j + 1] += a[j1 + 1]; a[j1] = x0r; a[j1 + 1] = x0i; } } } void cftbsub(signed n, double *a, double *w) { void cft1st(signed n, double *a, double *w); void cftmdl(signed n, signed l, double *a, double *w); signed j, j1, j2, j3, l; double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; l = 2; if (n > 8) { cft1st(n, a, w); l = 8; while ((l << 2) < n) { cftmdl(n, l, a, w); l <<= 2; } } if ((l << 2) == n) { for (j = 0; j < l; j += 2) { j1 = j + l; j2 = j1 + l; j3 = j2 + l; x0r = a[j] + a[j1]; x0i = -a[j + 1] - a[j1 + 1]; x1r = a[j] - a[j1]; x1i = -a[j + 1] + a[j1 + 1]; x2r = a[j2] + a[j3]; x2i = a[j2 + 1] + a[j3 + 1]; x3r = a[j2] - a[j3]; x3i = a[j2 + 1] - a[j3 + 1]; a[j] = x0r + x2r; a[j + 1] = x0i - x2i; a[j2] = x0r - x2r; a[j2 + 1] = x0i + x2i; a[j1] = x1r - x3i; a[j1 + 1] = x1i - x3r; a[j3] = x1r + x3i; a[j3 + 1] = x1i + x3r; } } else { for (j = 0; j < l; j += 2) { j1 = j + l; x0r = a[j] - a[j1]; x0i = -a[j + 1] + a[j1 + 1]; a[j] += a[j1]; a[j + 1] = -a[j + 1] - a[j1 + 1]; a[j1] = x0r; a[j1 + 1] = x0i; } } } void cft1st(signed n, double *a, double *w) { signed j, k1, k2; double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i; double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; x0r = a[0] + a[2]; x0i = a[1] + a[3]; x1r = a[0] - a[2]; x1i = a[1] - a[3]; x2r = a[4] + a[6]; x2i = a[5] + a[7]; x3r = a[4] - a[6]; x3i = a[5] - a[7]; a[0] = x0r + x2r; a[1] = x0i + x2i; a[4] = x0r - x2r; a[5] = x0i - x2i; a[2] = x1r - x3i; a[3] = x1i + x3r; a[6] = x1r + x3i; a[7] = x1i - x3r; wk1r = w[2]; x0r = a[8] + a[10]; x0i = a[9] + a[11]; x1r = a[8] - a[10]; x1i = a[9] - a[11]; x2r = a[12] + a[14]; x2i = a[13] + a[15]; x3r = a[12] - a[14]; x3i = a[13] - a[15]; a[8] = x0r + x2r; a[9] = x0i + x2i; a[12] = x2i - x0i; a[13] = x0r - x2r; x0r = x1r - x3i; x0i = x1i + x3r; a[10] = wk1r * (x0r - x0i); a[11] = wk1r * (x0r + x0i); x0r = x3i + x1r; x0i = x3r - x1i; a[14] = wk1r * (x0i - x0r); a[15] = wk1r * (x0i + x0r); k1 = 0; for (j = 16; j < n; j += 16) { k1 += 2; k2 = 2 * k1; wk2r = w[k1]; wk2i = w[k1 + 1]; wk1r = w[k2]; wk1i = w[k2 + 1]; wk3r = wk1r - 2 * wk2i * wk1i; wk3i = 2 * wk2i * wk1r - wk1i; x0r = a[j] + a[j + 2]; x0i = a[j + 1] + a[j + 3]; x1r = a[j] - a[j + 2]; x1i = a[j + 1] - a[j + 3]; x2r = a[j + 4] + a[j + 6]; x2i = a[j + 5] + a[j + 7]; x3r = a[j + 4] - a[j + 6]; x3i = a[j + 5] - a[j + 7]; a[j] = x0r + x2r; a[j + 1] = x0i + x2i; x0r -= x2r; x0i -= x2i; a[j + 4] = wk2r * x0r - wk2i * x0i; a[j + 5] = wk2r * x0i + wk2i * x0r; x0r = x1r - x3i; x0i = x1i + x3r; a[j + 2] = wk1r * x0r - wk1i * x0i; a[j + 3] = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[j + 6] = wk3r * x0r - wk3i * x0i; a[j + 7] = wk3r * x0i + wk3i * x0r; wk1r = w[k2 + 2]; wk1i = w[k2 + 3]; wk3r = wk1r - 2 * wk2r * wk1i; wk3i = 2 * wk2r * wk1r - wk1i; x0r = a[j + 8] + a[j + 10]; x0i = a[j + 9] + a[j + 11]; x1r = a[j + 8] - a[j + 10]; x1i = a[j + 9] - a[j + 11]; x2r = a[j + 12] + a[j + 14]; x2i = a[j + 13] + a[j + 15]; x3r = a[j + 12] - a[j + 14]; x3i = a[j + 13] - a[j + 15]; a[j + 8] = x0r + x2r; a[j + 9] = x0i + x2i; x0r -= x2r; x0i -= x2i; a[j + 12] = -wk2i * x0r - wk2r * x0i; a[j + 13] = -wk2i * x0i + wk2r * x0r; x0r = x1r - x3i; x0i = x1i + x3r; a[j + 10] = wk1r * x0r - wk1i * x0i; a[j + 11] = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[j + 14] = wk3r * x0r - wk3i * x0i; a[j + 15] = wk3r * x0i + wk3i * x0r; } } void cftmdl(signed n, signed l, double *a, double *w) { signed j, j1, j2, j3, k, k1, k2, m, m2; double wk1r, wk1i, wk2r, wk2i, wk3r, wk3i; double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; m = l << 2; for (j = 0; j < l; j += 2) { j1 = j + l; j2 = j1 + l; j3 = j2 + l; x0r = a[j] + a[j1]; x0i = a[j + 1] + a[j1 + 1]; x1r = a[j] - a[j1]; x1i = a[j + 1] - a[j1 + 1]; x2r = a[j2] + a[j3]; x2i = a[j2 + 1] + a[j3 + 1]; x3r = a[j2] - a[j3]; x3i = a[j2 + 1] - a[j3 + 1]; a[j] = x0r + x2r; a[j + 1] = x0i + x2i; a[j2] = x0r - x2r; a[j2 + 1] = x0i - x2i; a[j1] = x1r - x3i; a[j1 + 1] = x1i + x3r; a[j3] = x1r + x3i; a[j3 + 1] = x1i - x3r; } wk1r = w[2]; for (j = m; j < l + m; j += 2) { j1 = j + l; j2 = j1 + l; j3 = j2 + l; x0r = a[j] + a[j1]; x0i = a[j + 1] + a[j1 + 1]; x1r = a[j] - a[j1]; x1i = a[j + 1] - a[j1 + 1]; x2r = a[j2] + a[j3]; x2i = a[j2 + 1] + a[j3 + 1]; x3r = a[j2] - a[j3]; x3i = a[j2 + 1] - a[j3 + 1]; a[j] = x0r + x2r; a[j + 1] = x0i + x2i; a[j2] = x2i - x0i; a[j2 + 1] = x0r - x2r; x0r = x1r - x3i; x0i = x1i + x3r; a[j1] = wk1r * (x0r - x0i); a[j1 + 1] = wk1r * (x0r + x0i); x0r = x3i + x1r; x0i = x3r - x1i; a[j3] = wk1r * (x0i - x0r); a[j3 + 1] = wk1r * (x0i + x0r); } k1 = 0; m2 = 2 * m; for (k = m2; k < n; k += m2) { k1 += 2; k2 = 2 * k1; wk2r = w[k1]; wk2i = w[k1 + 1]; wk1r = w[k2]; wk1i = w[k2 + 1]; wk3r = wk1r - 2 * wk2i * wk1i; wk3i = 2 * wk2i * wk1r - wk1i; for (j = k; j < l + k; j += 2) { j1 = j + l; j2 = j1 + l; j3 = j2 + l; x0r = a[j] + a[j1]; x0i = a[j + 1] + a[j1 + 1]; x1r = a[j] - a[j1]; x1i = a[j + 1] - a[j1 + 1]; x2r = a[j2] + a[j3]; x2i = a[j2 + 1] + a[j3 + 1]; x3r = a[j2] - a[j3]; x3i = a[j2 + 1] - a[j3 + 1]; a[j] = x0r + x2r; a[j + 1] = x0i + x2i; x0r -= x2r; x0i -= x2i; a[j2] = wk2r * x0r - wk2i * x0i; a[j2 + 1] = wk2r * x0i + wk2i * x0r; x0r = x1r - x3i; x0i = x1i + x3r; a[j1] = wk1r * x0r - wk1i * x0i; a[j1 + 1] = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[j3] = wk3r * x0r - wk3i * x0i; a[j3 + 1] = wk3r * x0i + wk3i * x0r; } wk1r = w[k2 + 2]; wk1i = w[k2 + 3]; wk3r = wk1r - 2 * wk2r * wk1i; wk3i = 2 * wk2r * wk1r - wk1i; for (j = k + m; j < l + (k + m); j += 2) { j1 = j + l; j2 = j1 + l; j3 = j2 + l; x0r = a[j] + a[j1]; x0i = a[j + 1] + a[j1 + 1]; x1r = a[j] - a[j1]; x1i = a[j + 1] - a[j1 + 1]; x2r = a[j2] + a[j3]; x2i = a[j2 + 1] + a[j3 + 1]; x3r = a[j2] - a[j3]; x3i = a[j2 + 1] - a[j3 + 1]; a[j] = x0r + x2r; a[j + 1] = x0i + x2i; x0r -= x2r; x0i -= x2i; a[j2] = -wk2i * x0r - wk2r * x0i; a[j2 + 1] = -wk2i * x0i + wk2r * x0r; x0r = x1r - x3i; x0i = x1i + x3r; a[j1] = wk1r * x0r - wk1i * x0i; a[j1 + 1] = wk1r * x0i + wk1i * x0r; x0r = x1r + x3i; x0i = x1i - x3r; a[j3] = wk3r * x0r - wk3i * x0i; a[j3 + 1] = wk3r * x0i + wk3i * x0r; } } } void rftfsub(signed n, double *a, signed nc, double *c) { signed j, k, kk, ks, m; double wkr, wki, xr, xi, yr, yi; m = n >> 1; ks = 2 * nc / m; kk = 0; for (j = 2; j < m; j += 2) { k = n - j; kk += ks; wkr = 0.5 - c[nc - kk]; wki = c[kk]; xr = a[j] - a[k]; xi = a[j + 1] + a[k + 1]; yr = wkr * xr - wki * xi; yi = wkr * xi + wki * xr; a[j] -= yr; a[j + 1] -= yi; a[k] += yr; a[k + 1] -= yi; } } void rftbsub(signed n, double *a, signed nc, double *c) { signed j, k, kk, ks, m; double wkr, wki, xr, xi, yr, yi; a[1] = -a[1]; m = n >> 1; ks = 2 * nc / m; kk = 0; for (j = 2; j < m; j += 2) { k = n - j; kk += ks; wkr = 0.5 - c[nc - kk]; wki = c[kk]; xr = a[j] - a[k]; xi = a[j + 1] + a[k + 1]; yr = wkr * xr + wki * xi; yi = wkr * xi - wki * xr; a[j] -= yr; a[j + 1] = yi - a[j + 1]; a[k] += yr; a[k + 1] = yi - a[k + 1]; } a[m + 1] = -a[m + 1]; } void dctsub(signed n, double *a, signed nc, double *c) { signed j, k, kk, ks, m; double wkr, wki, xr; m = n >> 1; ks = nc / n; kk = 0; for (j = 1; j < m; j++) { k = n - j; kk += ks; wkr = c[kk] - c[nc - kk]; wki = c[kk] + c[nc - kk]; xr = wki * a[j] - wkr * a[k]; a[j] = wkr * a[j] + wki * a[k]; a[k] = xr; } a[m] *= c[0]; } void dstsub(signed n, double *a, signed nc, double *c) { signed j, k, kk, ks, m; double wkr, wki, xr; m = n >> 1; ks = nc / n; kk = 0; for (j = 1; j < m; j++) { k = n - j; kk += ks; wkr = c[kk] - c[nc - kk]; wki = c[kk] + c[nc - kk]; xr = wki * a[k] - wkr * a[j]; a[k] = wkr * a[k] + wki * a[j]; a[j] = xr; } a[m] *= c[0]; } //----// signed a[MAXN]; signed b[MAXN]; double ab[MAXSIZE]; int binpow(int a, int b, int mo) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } const int FACTSIZE = 10100; int fact[FACTSIZE]; int revfact[FACTSIZE]; int ncr(int n, int r) { if (n < r) return 0; int rs = fact[n] * revfact[r]; if (rs >= MOD) rs %= MOD; rs *= revfact[n - r]; if (rs >= MOD) rs %= MOD; return rs; } void init() { fact[0] = 1, revfact[0] = 1; for (int i = 1; i < FACTSIZE; ++i) { fact[i] = fact[i - 1] * i % MOD; revfact[i] = binpow(fact[i], MOD - 2, MOD); } } signed ip[10000]; double w[(MAXSIZE / 4)]; void convolve2(double *a, signed n) { signed s = n + n - 1; // 畳み込み結果のサイズ signed t = 1; // FFT に使う配列のサイズ(2 の累乗) while (t < s) t *= 2; ip[0] = 0; cdft(2 * t, 1, a, ip, w); for (signed i = 0; i < t; i++) { signed addr = 2 * i; double tmpa = a[addr]; a[addr] = a[addr] * a[addr] - a[addr + 1] * a[addr + 1]; a[addr + 1] = 2 * tmpa * a[addr + 1]; } cdft(2 * t, -1, a, ip, w); for (signed j = 0; j < t; j++) { a[j * 2] *= 1.0 / t; a[j] = a[j * 2]; } } signed N; signed main() { init(); cin.tie(0), ios::sync_with_stdio(false); cout << fixed << setprecision(10); int N; cin >> N; signed maxV = 0; REP(i, N) { cin >> a[i] >> b[i]; chmax(maxV, a[i]); chmax(maxV, b[i]); } maxV *= 2; maxV += 1; int maxAB = 0; REP(i, N) { int val = a[i] * maxV + b[i]; ab[2 * val]++; chmax(maxAB, val); } maxAB++; convolve2(ab, maxAB); int ans = 0; int maxV2 = maxV * maxV; DUMP(maxAB, maxV2); REP(i, maxV2) { int i0 = i / maxV; int i1 = i % maxV; int val = round(ab[i]) % MOD; ans += val * ncr(i0 + i1, i0); ans %= MOD; } int cnt = 0; REP(i, N) cnt += ncr(2 * (a[i] + b[i]), 2 * a[i]), cnt %= MOD; cnt = MOD - cnt; ans += cnt; ans %= MOD; ans = ans * revfact[2]; ans %= MOD; print(ans); }
a.cc: In function 'int main()': a.cc:1511:28: error: invalid operands of types 'double' and 'const long long int' to binary 'operator%' 1511 | int val = round(ab[i]) % MOD; | ~~~~~~~~~~~~ ^ ~~~ | | | | double const long long int
s596521219
p04051
C++
#include<iostream> #define mod 1000000007 using namespace std; long long dp[8001][8001],a[8001],b[8001],ans,jc[8001],invjc[8001]; long long C(int a,int b) { return jc[b]*invjc[a]%mod*invjc[b-a]%mod; } long long fast_pow(long long a,int b) { if (b==0) return 1; if (b&1) return fast_pow(a*a%mod,b/2)*a%mod; else return fast_pow(a*a%mod,b/2); } int main() { int n; cin>>n; for (int i=1;i<=n;++i) cin>>a[i]>>b[i]; for (int i=1;i<=n;++i) dp[2000-a[i]][2000-b[i]]++; for (int i=1;i<=4000;++i) for (int j=1;j<=4000;++j) dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod; for (int i=1;i<=n;++i) ans=(ans+dp[a[i]+2000][b[i]+2000])%mod; jc[0]=1; for (int i=1;i<=8000;++i) jc[i]=jc[i-1]*i%mod; invjc[8000]=fast_pow(jc[8000],mod-2); for (int i=7999;i>=0;--i) invjc[i]=invjc[i+1]*(i+1)%mod; for (int i=1;i<=n;++i) ans=(ans-C(2*a[i],2*a[i]+2*b[i])+mod)%mod; cout<<ans*fast_pow(2,mod-2)%mod<<endl; return 0; }
a.cc:4:14: error: '\U0000ff18001' was not declared in this scope 4 | long long dp[8001][8001],a[8001],b[8001],ans,jc[8001],invjc[8001]; | ^~~~~ a.cc: In function 'int main()': a.cc:25:5: error: 'dp' was not declared in this scope 25 | dp[2000-a[i]][2000-b[i]]++; | ^~ a.cc:28:7: error: 'dp' was not declared in this scope 28 | dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod; | ^~ a.cc:30:14: error: 'dp' was not declared in this scope 30 | ans=(ans+dp[a[i]+2000][b[i]+2000])%mod; | ^~
s918053575
p04051
C++
#include<bits/stdc++.h> using namespace std; #define Max(x,y) ((x)>(y)?(x):(y)) #define Min(x,y) ((x)<(y)?(x):(y)) #define ll long long #define ls o<<1 #define rs o<<1|1 const int N=20+10,M=2000+10,inf=0x3f3f3f3f; const ll P=1e9+7; ll n,c[N]; template<class t>void rd(t &x){ x=0;int w=0;char ch=0; while(!isdigit(ch)) w|=ch=='-',ch=getchar(); while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); x=w?-x:x; } void Mod(ll &x){x=(x>=P)?x-P:x;} ll C(int x,int y){return (fac[x]*ifac[y]%P)*ifac[x-y]%P;} ll qpow(ll x,ll y){ ll ret=1ll; while(y){ if(y&1) ret=ret*x%P; x=x*x%P,y>>=1; } return ret; } int main(){ #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif rd(n); for(int i=1;i<=n;++i) rd(a[i]),rd(b[i]),++f[M-a[i]][M-b[i]]; for(int i=1;i<=(M<<1);++i) for(int j=1;j<=(M<<1);++j) f[i][j]+=f[i-1][j],Mod(f[i][j]),f[i][j]+=f[i][j-1],Mod(f[i][j]); fac[0]=fac[1]=1ll; for(int i=2;i<=(M<<2);++i) fac[i]=fac[i-1]*(ll)i%P; ifac[M<<2]=qpow(fac[M<<2],P-2); for(int i=(M<<2);i;--i) ifac[i-1]=ifac[i]*i%P; for(int i=1;i<=n;++i) ans+=f[M+a[i]][M+b[i]],Mod(ans),ans+=(P-C(((a[i]+b[i])<<1),(a[i]<<1))),Mod(ans); printf("%lld",ans*inv2%P); return 0; }
a.cc: In function 'long long int C(int, int)': a.cc:19:27: error: 'fac' was not declared in this scope 19 | ll C(int x,int y){return (fac[x]*ifac[y]%P)*ifac[x-y]%P;} | ^~~ a.cc:19:34: error: 'ifac' was not declared in this scope 19 | ll C(int x,int y){return (fac[x]*ifac[y]%P)*ifac[x-y]%P;} | ^~~~ a.cc: In function 'int main()': a.cc:34:34: error: 'a' was not declared in this scope 34 | for(int i=1;i<=n;++i) rd(a[i]),rd(b[i]),++f[M-a[i]][M-b[i]]; | ^ a.cc:34:43: error: 'b' was not declared in this scope 34 | for(int i=1;i<=n;++i) rd(a[i]),rd(b[i]),++f[M-a[i]][M-b[i]]; | ^ a.cc:34:51: error: 'f' was not declared in this scope 34 | for(int i=1;i<=n;++i) rd(a[i]),rd(b[i]),++f[M-a[i]][M-b[i]]; | ^ a.cc:37:25: error: 'f' was not declared in this scope 37 | f[i][j]+=f[i-1][j],Mod(f[i][j]),f[i][j]+=f[i][j-1],Mod(f[i][j]); | ^ a.cc:38:9: error: 'fac' was not declared in this scope 38 | fac[0]=fac[1]=1ll; | ^~~ a.cc:40:9: error: 'ifac' was not declared in this scope 40 | ifac[M<<2]=qpow(fac[M<<2],P-2); | ^~~~ a.cc:42:31: error: 'ans' was not declared in this scope; did you mean 'abs'? 42 | for(int i=1;i<=n;++i) ans+=f[M+a[i]][M+b[i]],Mod(ans),ans+=(P-C(((a[i]+b[i])<<1),(a[i]<<1))),Mod(ans); | ^~~ | abs a.cc:42:36: error: 'f' was not declared in this scope 42 | for(int i=1;i<=n;++i) ans+=f[M+a[i]][M+b[i]],Mod(ans),ans+=(P-C(((a[i]+b[i])<<1),(a[i]<<1))),Mod(ans); | ^ a.cc:42:40: error: 'a' was not declared in this scope 42 | for(int i=1;i<=n;++i) ans+=f[M+a[i]][M+b[i]],Mod(ans),ans+=(P-C(((a[i]+b[i])<<1),(a[i]<<1))),Mod(ans); | ^ a.cc:42:48: error: 'b' was not declared in this scope 42 | for(int i=1;i<=n;++i) ans+=f[M+a[i]][M+b[i]],Mod(ans),ans+=(P-C(((a[i]+b[i])<<1),(a[i]<<1))),Mod(ans); | ^ a.cc:43:23: error: 'ans' was not declared in this scope; did you mean 'abs'? 43 | printf("%lld",ans*inv2%P); | ^~~ | abs a.cc:43:27: error: 'inv2' was not declared in this scope 43 | printf("%lld",ans*inv2%P); | ^~~~
s559424355
p04051
C++
#include <cstdio> #define rint register int #define N 200005 #define M 2003 using namespace std; const int Mod = 1e9 + 7; const int eps = 2001; int n, a[N], b[N], f[M << 1][M << 1]; int fac[M << 1], inv[M << 1], ifac[M << 1]; inline void prework() { fac[0] = inv[1] = ifac[0] = 1; for (rint i = 1; i <= eps << 1; ++i) fac[i] = 1ll * fac[i - 1] * i % Mod; for (rint i = 2; i <= eps << 1; ++i) inv[i] = 1ll * inv[Mod % i] * (Mod - Mod / i) % Mod; for (rint i = 1; i <= eps << 1; ++i) ifac[i] = 1ll * ifac[i - 1] * inv[i] % Mod; } inline int C(int x, int y) { return 1ll * fac[x + y] * ifac[x] % Mod * ifac[y] % Mod; } int main() { #ifdef whyqx freopen("work.in", "r", stdin); freopen("work.out", "w", stdout); #endif prework(); cin >> n; for (rint i = 1; i <= n; ++i) scanf("%d%d", a + i, b + i), ++f[eps - a[i]][eps - b[i]]; for (rint i = 1; i <= eps << 1; ++i) for (rint j = 1; j <= eps << 1; ++j) (f[i][j] += (f[i - 1][j] + f[i][j - 1]) % Mod) %= Mod; long long ans = 0; for (rint i = 1; i <= n; ++i) (ans += f[eps + a[i]][eps + b[i]]) %= Mod; for (rint i = 1; i <= n; ++i) (ans -= C(a[i] << 1, b[i] << 1)) %= Mod; cout << (ans % Mod + Mod) % Mod * ((Mod + 1) >> 1) % Mod; return 0; }
a.cc: In function 'void prework()': a.cc:14:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 14 | for (rint i = 1; i <= eps << 1; ++i) | ^ a.cc:16:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 16 | for (rint i = 2; i <= eps << 1; ++i) | ^ a.cc:18:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 18 | for (rint i = 1; i <= eps << 1; ++i) | ^ a.cc: In function 'int main()': a.cc:31:16: error: 'cin' was not declared in this scope 31 | prework(); cin >> n; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <cstdio> +++ |+#include <iostream> 2 | #define rint register int a.cc:32:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 32 | for (rint i = 1; i <= n; ++i) | ^ a.cc:35:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 35 | for (rint i = 1; i <= eps << 1; ++i) | ^ a.cc:36:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 36 | for (rint j = 1; j <= eps << 1; ++j) | ^ a.cc:39:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 39 | for (rint i = 1; i <= n; ++i) | ^ a.cc:41:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 41 | for (rint i = 1; i <= n; ++i) | ^ a.cc:43:5: error: 'cout' was not declared in this scope 43 | cout << (ans % Mod + Mod) % Mod * ((Mod + 1) >> 1) % Mod; | ^~~~ a.cc:43:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s804973046
p04051
C++
#include <iostream> #include <vector> #include <queue> using namespace std; typedef long long LL; const int N=200000 + 10; const LL MOD = 1000000007; int n,a[N],b[N]; LL fac[N],inv[N]; 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; } int getId(int x,int y) { return (x+2000)*4000+(y+2000); } int dx[2]={1,0}; int dy[2]={0,1}; bool inside(int x,int y){ return x>=-2000 && x<=2000 && y>=-2000 && y<=2000; } const int V=17000000+2; int S=V-2,T=V-1; struct Edge { int v,nex; } edge[V<<1]; int head[V],tot; int dis[V],in[V]; bool vis[V],canreach[V]; void link(int u,int v){ edge[tot].v=v; edge[tot].nex=head[u]; head[u]=tot++; } void init(){ queue<int> q; q.push(S); canreach[S]=1; while(q.size()){ int u=q.front(); q.pop(); for(int i=head[u];i!=-1;i=edge[i].nex) { int v=edge[i].v; if(!canreach[v]) { q.push(v); canreach[v]=1; } } } for(int i=1;i<V;i++){ if(!canreach[i]) continue; for(int e=head[i];e!=-1;e=edge[e].nex) { in[edge[e].v]++; } } } void BFS(){ queue<int> q; q.push(S); vis[S]=1; dis[S]=1; while(q.size()){ int u=q.front(); q.pop(); //printf("u=%d, %d\n",u,dis[u]); for(int i=head[u];i!=-1;i=edge[i].nex){ //printf("v=%d, %d\n", v, in[v]); int v=edge[i].v; if(in[v]){ --in[v]; (dis[v]+=dis[u])%=MOD; if(in[v]==0) q.push(v); } } } } int main() { memset(head,-1,sizeof(head)); fac[0]=1; inv[0]=1; for(int i=1;i<N;i++){ fac[i]=fac[i-1]*i%MOD; inv[i]=mpow(fac[i],MOD-2); } scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i],&b[i]); } int L=1999; for(int i=-L;i<=L;i++){ for(int j=-L;j<=L;j++){ for(int dir=0;dir<2;dir++){ int nx=i+dx[dir], ny=j+dy[dir]; if(inside(nx,ny)) { link(getId(i,j), getId(nx,ny)); } } } } for(int i=1;i<=n;i++){ link(S,getId(-a[i],-b[i])); } for(int i=1;i<=n;i++){ link(getId(a[i],b[i]),T); } init(); BFS(); LL ans=dis[T]; for(int i=1;i<=n;i++) { ans=ans-(fac[2*a[i]+2*b[i]] * inv[2*a[i]] % MOD * inv[2*b[i]] % MOD); ans=(ans%MOD+MOD)%MOD; } printf("%d\n", ans * (MOD+1)/2 % MOD); }
a.cc: In function 'int main()': a.cc:71:5: error: 'memset' was not declared in this scope 71 | memset(head,-1,sizeof(head)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 | using namespace std;
s468597312
p04051
C++
#include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> #include<set> #define ll long long #define mod 1000000007 #define Mod1(x) (x>=mod?x-mod:x) #define Mod2(x) (x<0?x+mod:x) #define maxn 200010 inline ll read() { ll x=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; return x*f; } inline void write(ll x) { static int buf[20],len; len=0; if(x<0)x=-x,putchar('-'); for(;x;x/=10)buf[len++]=x%10; if(!len)putchar('0'); else while(len)putchar(buf[--len]+'0'); } inline void writeln(ll x){write(x); putchar('\n');} inline void writesp(ll x){write(x); putchar(' ');} const int size=4010,inv2=(mod+1)>>1; struct edge{ int to,nxt; }e[2*size*size+2*maxn]; int fac[2*size],inv[2*size]; int a[maxn],b[maxn]; int fir[size*size],dp[size*size],in[size*size],q[size*size]; int n,tot; inline void add_edge(int x,int y){++in[y]; e[tot].to=y; e[tot].nxt=fir[x]; fir[x]=tot++;} inline int getid(int x,int y){return (x+2000)*4001+(y+2000)+1;} inline power(ll a,ll b) { ll ans=1; for(;b;b>>=1,a=a*a%mod) if(b&1)ans=ans*a%mod; return ans; } inline ll C(ll n,ll m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;} int main() { n=read(); for(int i=1;i<=n;i++) a[i]=read(),b[i]=read(); memset(fir,255,sizeof(fir)); tot=0; for(int i=-2000;i<=2000;i++) for(int j=-2000;j<=2000;j++){ if(i<2000)add_edge(getid(i,j),getid(i+1,j)); if(j<2000)add_edge(getid(i,j),getid(i,j+1)); } int S=0,T=4001*4001+1; for(int i=1;i<=n;i++){ add_edge(S,getid(-a[i],-b[i])); add_edge(getid(a[i],b[i]),T); } // writesp(in[S]); writeln(in[T]); int h=1,t=0; for(int i=0;i<=T;i++) if(!in[i])q[++t]=i; dp[S]=1; while(h<=t){ int now=q[h++]; // if(dp[now]>0&&dp[T]==0)printf("%d %d %d %d %d -> %d %d\n",h,t,now,(now-1)/4001-2000,(now-1)%4001-2000,dp[now],dp[T]); for(int i=fir[now];~i;i=e[i].nxt){ // if(e[i].to==T)printf("%d -> %d : %d %d\n",now,T,dp[now],dp[T]); dp[e[i].to]=Mod1(dp[e[i].to]+dp[now]); --in[e[i].to]; if(!in[e[i].to])q[++t]=e[i].to; } } // for(int i=-2;i<=2;i++){ // for(int j=-2;j<=2;j++) // writesp(dp[getid(i,j)]); // putchar('\n'); // } fac[0]=inv[0]=1; for(int i=1;i<=8000;i++) fac[i]=(ll)fac[i-1]*i%mod,inv[i]=power(fac[i],mod-2); // for(int i=1;i<=10;i++) // printf("%d %d %d\n",i,fac[i],inv[i]); int ans=dp[T]; // writeln(ans); for(int i=1;i<=n;i++) ans=Mod2(ans-C(2*a[i]+2*b[i],2*a[i])); // writeln(ans); writeln((ll)ans*inv2%mod); return 0; }
a.cc:39:9: error: ISO C++ forbids declaration of 'power' with no type [-fpermissive] 39 | inline power(ll a,ll b) | ^~~~~
s967988491
p04051
C++
#include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> #include<set> #define ll long long #define mod 1000000007 #define Mod1(x) (x>=mod?x-mod:x) #define Mod2(x) (x<0?x+mod:x) #define maxn 200010 inline ll read() { ll x=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; return x*f; } inline void write(ll x) { static int buf[20],len; len=0; if(x<0)x=-x,putchar('-'); for(;x;x/=10)buf[len++]=x%10; if(!len)putchar('0'); else while(len)putchar(buf[--len]+'0'); } inline void writeln(ll x){write(x); putchar('\n');} inline void writesp(ll x){write(x); putchar(' ');} const int size=4010,inv2=(mod+1)>>1; struct edge{ int to,nxt; }e[2*size*size+2*maxn]; int fac[2*size],inv[2*size]; int a[maxn],b[maxn]; int fir[size*size],dp[size*size],in[size*size],q[size*size]; int n,tot; inline void add_edge(int x,int y){++in[y]; e[tot].to=y; e[tot].nxt=fir[x]; fir[x]=tot++;} inline getid(int x,int y){return (x+2000)*4001+(y+2000)+1;} ll power(ll a,ll b) { ll ans=1; for(;b;b>>=1,a=a*a%mod) if(b&1)ans=ans*a%mod; return ans; } ll C(ll n,ll m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;} int main() { n=read(); for(int i=1;i<=n;i++) a[i]=read(),b[i]=read(); memset(fir,255,sizeof(fir)); tot=0; for(int i=-2000;i<=2000;i++) for(int j=-2000;j<=2000;j++){ if(i<2000)add_edge(getid(i,j),getid(i+1,j)); if(j<2000)add_edge(getid(i,j),getid(i,j+1)); } int S=0,T=4001*4001+1; for(int i=1;i<=n;i++){ add_edge(S,getid(-a[i],-b[i])); add_edge(getid(a[i],b[i]),T); } // writesp(in[S]); writeln(in[T]); int h=1,t=0; for(int i=0;i<=T;i++) if(!in[i])q[++t]=i; dp[S]=1; while(h<=t){ int now=q[h++]; // if(dp[now]>0&&dp[T]==0)printf("%d %d %d %d %d -> %d %d\n",h,t,now,(now-1)/4001-2000,(now-1)%4001-2000,dp[now],dp[T]); for(int i=fir[now];~i;i=e[i].nxt){ // if(e[i].to==T)printf("%d -> %d : %d %d\n",now,T,dp[now],dp[T]); dp[e[i].to]=Mod1(dp[e[i].to]+dp[now]); --in[e[i].to]; if(!in[e[i].to])q[++t]=e[i].to; } } // for(int i=-2;i<=2;i++){ // for(int j=-2;j<=2;j++) // writesp(dp[getid(i,j)]); // putchar('\n'); // } fac[0]=inv[0]=1; for(int i=1;i<=8000;i++) fac[i]=(ll)fac[i-1]*i%mod,inv[i]=power(fac[i],mod-2); // for(int i=1;i<=10;i++) // printf("%d %d %d\n",i,fac[i],inv[i]); int ans=dp[T]; // writeln(ans); for(int i=1;i<=n;i++) ans=Mod2(ans-C(2*a[i]+2*b[i],2*a[i])); // writeln(ans); writeln((ll)ans*inv2%mod); return 0; }
a.cc:38:8: error: ISO C++ forbids declaration of 'getid' with no type [-fpermissive] 38 | inline getid(int x,int y){return (x+2000)*4001+(y+2000)+1;} | ^~~~~
s622643746
p04051
C++
123
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 123 | ^~~
s387600483
p04051
C++
43241324
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 43241324 | ^~~~~~~~
s992479801
p04051
C++
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <iostream> #include <algorithm> #include <stack> #include <queue> #include <map> #include <set> #include <iomanip> #include <assert.h> #include <fstream> using namespace std; typedef long long ll; const int MAXN = 4005; const int MOD = 1000000007; int n,ans1,ans2; int f[MAXN << 1][MAXN]; int mrk[MAXN][MAXN]; int power(int a,int b) { int res = 1; while (b) { if (b & 1) res = (ll)res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } int main() { ios::sync_with_stdio(false); for (int i = 0;i <= 8000;i++) { f[i][0] = 1; for (int j = 1;j <= min(i,4000);j++) f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % MOD; } cin >> n; for (int a,b,i = 1;i <= n;i++) { cin >> a >> b; (ans2 += f[(a + b) << 1][a << 1]) %= MOD; mrk[2000 - a][2000 - b]++; mrk[2000 + a][2000 + b]++; } memset(f,0,sizeof(f)); for (int i = 0;i <= 4000;i++) for (int j = 0;j <= 4000;j++) { if (i < 2000 && j < 2000) f[i][j] = mrk[i][j]; if (i) (f[i][j] += f[i - 1][j]) %= MOD; if (j) (f[i][j] += f[i][j - 1]) %= MOD; if (i > 2000 && j > 2000) ans1 = ((ll)mrk[i][j] * f[i][j] + ans) % MOD; } cout << ((ll)(ans1 - ans2 + MOD) * (MOD + 1) / 2) % MOD << endl; return 0; }
a.cc: In function 'int main()': a.cc:68:67: error: 'ans' was not declared in this scope; did you mean 'ans2'? 68 | ans1 = ((ll)mrk[i][j] * f[i][j] + ans) % MOD; | ^~~ | ans2
s015037795
p04051
C
#include<stdio.h> int fact(int n); int main() { int n,i,j; scanf("%d",&n); int a[n],b[n]; for(int i=0;i<n;i++) { scanf("%d%d",&a[i],&b[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { sum+=fact(a[i]+b[i]+a[j]+b[j])/(fact(a[i]+a[j])*fact(b[i]+b[j])); } } printf("%d",sum); return 0; } int fact(int n) { int i=n,f=1; while(i!=0) { f=f*i; i--; } return f; }
main.c: In function 'main': main.c:16:1: error: 'sum' undeclared (first use in this function) 16 | sum+=fact(a[i]+b[i]+a[j]+b[j])/(fact(a[i]+a[j])*fact(b[i]+b[j])); | ^~~ main.c:16:1: note: each undeclared identifier is reported only once for each function it appears in
s022362749
p04051
C++
#include <cstdio> #include <cstring> #include <algorithm> #include <set> using namespace std; #define mod 1000000007 #define N 4050 #define m 2001 #define M 200050 typedef long long ll; int f[N][N],n; struct A { int x,y; }a[M]; ll fac[M],inv[M]; const ll inv2=(mod+1)/2; ll qp(ll x,ll y) { ll re=1; for(;y;y>>=1,x=x*x%mod) if(y&1) re=re*x%mod; return re; } ll C(int x,int y) { if(x<y) return 0; return fac[x]*inv[y]%mod*inv[x-y]%mod; } int main() { scanf("%d",&n); int i,j; for(fac[0]=i=1;i<M;i++) fac[i]=fac[i-1]*i%mod; inv[M-1]=qp(fac[M-1],mod-2); for(i=M-2;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod; for(i=1;i<=n;i++) { scanf("%d%d",&a[i].x,&a[i].y); f[m-a[i].x][m-a[i].y]++; } ll ans=0; int lim=m<<1; for(i=1;i<=lim;i++) { for(j=1;j<=lim;j++) { f[i][j]=(ll(f[i][j])+f[i-1][j)+f[i][j-1])%mod; } } for(i=1;i<=n;i++) { ans=(ans+f[m+a[i].x][m+a[i].y])%mod; ans=(ans-C(a[i].x*2+a[i].y*2,a[i].x*2))%mod; } ans=ans*inv2%mod; printf("%lld\n",(ans%mod+mod)%mod); }
a.cc: In function 'int main()': a.cc:39:54: error: expected ']' before ')' token 39 | f[i][j]=(ll(f[i][j])+f[i-1][j)+f[i][j-1])%mod; | ^ | ] a.cc:39:65: error: expected ';' before ')' token 39 | f[i][j]=(ll(f[i][j])+f[i-1][j)+f[i][j-1])%mod; | ^ | ;
s069989211
p04051
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 2e5 + 20; const int maxm = 2e3 + 20; const int mod = 1e9 + 7; ll dp[2 * maxm][2 * maxm] , a[maxn] , b[maxn] , fac[maxn] , caf[maxn]; void mkay(int &a) { while(a >= mod) a -= mod; } int bpw(int a , int b) { if(!b) return 1; int x = bpw(a , b / 2); x = 1LL * x * x % mod; if(b&1) x = 1LL * x * a % mod; return x; } int c(int s , int r) { if(r < 0 || r > s) return 0; return 1LL * fac[s] * caf[r] % mod * caf[s - r] % mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); fac[0] = 1; for(int i = 1; i < maxn; i++) fac[i] = 1LL * fac[i - 1] * i % mod; caf[maxn - 1] = bpw(fac[maxn - 1] , mod - 2); for(int i = maxn - 1; i > 0; i--) caf[i - 1] = 1LL * caf[i] * i % mod; int n; cin >> n; for(int i = 0; i < n; i++) cin >> a[i] >> b[i] , dp[-a[i] + maxm][-b[i] + maxm]++; for(int i = 1; i < 2 * maxm; i++) for(int j = 1; j < 2 * maxm; j++) mkay(dp[i][j] += dp[i - 1][j] + dp[i][j - 1]); int res = 0; for(int i = 0; i < n; i++) { mkay(res += dp[a[i] + maxm][b[i] + maxm]); mkay(res -= c((a[i] + b[i]) * 2 , 2 * a[i])); } cout << 1LL * res * bpw(2 , mod - 2) % mod << endl; }
a.cc: In function 'int main()': a.cc:64:39: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int' 64 | mkay(dp[i][j] += dp[i - 1][j] + dp[i][j - 1]); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:13:16: note: initializing argument 1 of 'void mkay(int&)' 13 | void mkay(int &a) | ~~~~~^
s349242929
p04051
C++
#include <bits/stdc++.h> using namespace std; #define qqqq qqqqq // asdlfjasdjgflajsdgfkjsagjdkfa // aesiufaepwueoqtqp9yerfjkhasdklvbae // faisdufgweaigfvklsdbviagsdigajsbdlkvbsdf // efuigaisdgvfsadgfklsadjlfgsajldgasdf const int MAXN = 2e3 + 10; const int MOD = 1e9 + 7; int n, dp[2 * MAXN][2 * MAXN], go[2 * MAXN][2 * MAXN]; int fac[4 * MAXN]; long long po(long long v, long long u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; } int ente(int i, int j) { return (((fac[j] * po(fac[i], MOD - 2)) % MOD) * po(fac[j - i], MOD - 2)) % MOD; }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s832927741
p04051
C++
#include <bits/stdc++.h> using namespace std; #define qqqq qqqqq const int MAXN = 2e3 + 10; const int MOD = 1e9 + 7; int n, dp[2 * MAXN][2 * MAXN], go[2 * MAXN][2 * MAXN]; int fac[4 * MAXN]; long long po(long long v, long long u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; } int ente(int i, int j) { return (((fac[j] * po(fac[i], MOD - 2)) % MOD) * po(fac[j - i], MOD - 2)) % MOD; }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s555502149
p04051
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define sqr(x) ((x)*(x)) #define mp make_pair #define uint unsigned #define int long long #define PI pair<int,int> 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 int read(){ int 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(int a){ if(a<0){ a=-a; putchar('-'); } if(a>=10)write(a/10); putchar('0'+a%10); } inline void writeln(int a){ if(a<0){ a=-a; putchar('-'); } write(a); puts(""); } inline int rnd(int x){ return rand()%x; } inline ull rnd(){ return ((ull)rand()<<30^rand())<<4|rand()%4; } const int N=2005,M=200005,mod=1000000007; signed n,dp[N<<1][N<<1],a[M],b[M],ans; long dp[N<<2][N<<1]; signed main(){ n=read(); for(int i=1;i<=n;i++){ a[i]=read(); b[i]=read(); dp[-a[i]+N][-b[i]+N]++; } for(int i=1;i<2*N;i++){ for(int j=1;j<2*N;j++){ dp[i][j]=(dp[i-1][j]+dp[i][j-1]+dp[i][j])%mod; } } for(int i=0;i<4*N;i++){ c[i][0]=1; for(int j=1;j<2*N;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod; } for(int i=1;i<=n;i++){ans=(ans+dp[a[i]+N][b[i]+N])%mod; ans=(ans-c[a[i]*2+b[i]*2][a[i]*2])%mod;} cout<<((ll)ans*(mod+1)/2%mod+mod)%mod<<endl; } /* 10*3*4 */
a.cc:42:6: error: conflicting declaration 'long int dp [8020][4010]' 42 | long dp[N<<2][N<<1]; | ^~ a.cc:41:10: note: previous declaration as 'int dp [4010][4010]' 41 | signed n,dp[N<<1][N<<1],a[M],b[M],ans; | ^~ a.cc: In function 'int main()': a.cc:55:17: error: 'c' was not declared in this scope 55 | c[i][0]=1; | ^ a.cc:58:74: error: 'c' was not declared in this scope 58 | for(int i=1;i<=n;i++){ans=(ans+dp[a[i]+N][b[i]+N])%mod; ans=(ans-c[a[i]*2+b[i]*2][a[i]*2])%mod;} | ^
s277067488
p04051
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define sqr(x) ((x)*(x)) #define mp make_pair #define uint unsigned #define int long long #define PI pair<int,int> 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 int read(){ int 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(int a){ if(a<0){ a=-a; putchar('-'); } if(a>=10)write(a/10); putchar('0'+a%10); } inline void writeln(int a){ if(a<0){ a=-a; putchar('-'); } write(a); puts(""); } inline int rnd(int x){ return rand()%x; } inline ull rnd(){ return ((ull)rand()<<30^rand())<<4|rand()%4; } const int N=2005,M=200005,mod=1000000007; signed n,dp[N<<1][N<<1],a[M],b[M],ans; long dp[N<<2][N<<1]; int main(){ n=read(); for(int i=1;i<=n;i++){ a[i]=read(); b[i]=read(); dp[-a[i]+N][-b[i]+N]++; } for(int i=1;i<2*N;i++){ for(int j=1;j<2*N;j++){ dp[i][j]=(dp[i-1][j]+dp[i][j-1]+dp[i][j])%mod; } } for(int i=0;i<4*N;i++){ c[i][0]=1; for(int j=1;j<2*N;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod; } for(int i=1;i<=n;i++){ans=(ans+dp[a[i]+N][b[i]+N])%mod; ans=(ans-c[a[i]*2+b[i]*2][a[i]*2])%mod;} cout<<((ll)ans*(mod+1)/2%mod+mod)%mod<<endl; } /* 10*3*4 */
a.cc:42:6: error: conflicting declaration 'long int dp [8020][4010]' 42 | long dp[N<<2][N<<1]; | ^~ a.cc:41:10: note: previous declaration as 'int dp [4010][4010]' 41 | signed n,dp[N<<1][N<<1],a[M],b[M],ans; | ^~ cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:55:17: error: 'c' was not declared in this scope 55 | c[i][0]=1; | ^ a.cc:58:74: error: 'c' was not declared in this scope 58 | for(int i=1;i<=n;i++){ans=(ans+dp[a[i]+N][b[i]+N])%mod; ans=(ans-c[a[i]*2+b[i]*2][a[i]*2])%mod;} | ^
s040451154
p04051
C++
#include <cstdio> const long long MOD = 1000000007; int a[200001],b[200001]; long long fac[8001],ni[8001],f[4001][4001],ans; int n,x,y,p; long long C(int n,int m) { return fac[n]*ni[m]%MOD*ni[n-m]%MOD; } long long fun(long long a,int k) { long long s=1; while (k) { if (k&1) s=s*a%MOD; a=a*a%MOD; k>>=1; } return s; } int main() { fac[0]=1; for (int i=1; i<=8000; ++i) fac[i]=fac[i-1]*i%MOD; ni[8000]=fun(fac[8000],MOD-2); for (int i=7999; i>0; --i) ni[i]=ni[i+1]*(i+1)%MOD; scanf("%d",&n); for (int i=1; i<=n; ++i) { read(a[i]); read(b[i]); if (a[i]>x) x=a[i]; if (b[i]>y) y=b[i]; f[2000-a[i]][2000-b[i]]++; } for (int i=2000-x; i<=2000+x; ++i) for (int j=2000-y; j<=2000+y; ++j) { if (i>0) { p=f[i][j]+f[i-1][j]; f[i][j]= p>=MOD ? p-MOD : p; } if (j>0) { p=f[i][j]+f[i][j-1]; f[i][j]= p>=MOD ? p-MOD : p; } } for (int i=1; i<=n; ++i) { p=ans+f[2000+a[i]][2000+b[i]]; ans = p>=MOD ? p-MOD : p; p=ans+MOD - C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]); ans = p>=MOD ? p-MOD : p; } ans=ans*ni[2]%MOD; printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:27:9: error: 'read' was not declared in this scope; did you mean 'fread'? 27 | read(a[i]); | ^~~~ | fread
s013256581
p04051
C++
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define pb push_back #define fs first #define sc second #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<double> vd; typedef pair<int, int> pii; typedef pair<ll, int> plli; typedef vector<pii> vpii; typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ost; const int N=4010; const ll P=1e9+7; const ll PH=(P+1)/2; int bn[2*N][2*N], t[2*N]; inline./ a void add(int &x, int y) { x+=y; if(x>=P) x-=P; } int main() { int i, j, n, a, b, ans=0; for(i=0; i<2*N; i++) bn[i][0]=1; for(i=1; i<2*N; i++) for(j=1; j<=i; j++) { bn[i][j]=bn[i-1][j]; add(bn[i][j], bn[i-1][j-1]); } scanf("%d", &n); for(i=0; i<n; i++) { scanf("%d%d", &a, &b); add(ans, P-bn[2*a+2*b][2*b]); for(j=0; j<=a+b; j++) add(t[N-a+j], bn[a+b][j]); } for(i=-N+1; i<N; i++) add(ans, t[i+N]*(ll)t[-i+N]%P); printf("%lld\n",ans*PH%P); return 0; }
a.cc:26:7: error: expected unqualified-id before '.' token 26 | inline./ a void add(int &x, int y) { | ^ a.cc: In function 'int main()': a.cc:36:9: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'? 36 | add(bn[i][j], bn[i-1][j-1]); | ^~~ | std::filesystem::perm_options::add In file included from /usr/include/c++/14/filesystem:51, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200, from a.cc:1: /usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here 219 | add = 0x2, | ^~~ a.cc:41:9: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'? 41 | add(ans, P-bn[2*a+2*b][2*b]); | ^~~ | std::filesystem::perm_options::add /usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here 219 | add = 0x2, | ^~~ a.cc:46:9: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'? 46 | add(ans, t[i+N]*(ll)t[-i+N]%P); | ^~~ | std::filesystem::perm_options::add /usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here 219 | add = 0x2, | ^~~
s350884092
p04051
C++
#include<iostream> using namespace std; main(){ long n; cin>>n; long long a[n],b[n]; long long sum; for(long i=0;i<n;i++){ cin>>a[i]>>b[i]; } for(long i=0;i<n-1;i++){ for(long j=i+1;j<n;j++){ long long aa=1; if(b[i]+b[j]<=a[i]+a[j]){ for(long k=a[i]+a[j]+1;k<=a[i]+a[j]+b[i]+b[j];k++){ aa=k*aa/(k-a[i]-a[j]); }} else{ for(long k=b[i]+b[j]+1;k<=a[i]+a[j]+b[i]+b[j];k++){ aa=k*aa/(k-b[i]-b[j]); } } sum +=aa/bb%(10^9+7); } sum = sum%(10^9+7); } cout<<sum<<endl; return 0; }
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:23:10: error: 'bb' was not declared in this scope; did you mean 'b'? 23 | sum +=aa/bb%(10^9+7); | ^~ | b
s509468562
p04051
C++
#include<iostream> using namespace std; main(){ long n; cin>>n; long long a[n],b[n]; long long sum; for(long i=0;i<n;i++){ cin>>a[i]>>b[i]; } for(long i=0;i<n-1;i++){ for(long j=i+1;j<n;j++){ long long aa=1; if(b[i]+b[j]<=a[i]+a[j]){ for(long k=a[i]+a[j]+1;k<=a[i]+a[j]+b[i]+b[j];k++){ aa=k*aa/(k-a[i]-a[j]); } else{ for(long k=b[i]+b[j]+1;k<=a[i]+a[j]+b[i]+b[j];k++){ aa=k*aa/(k-b[i]-b[j]); } } sum +=aa/bb%(10^9+7); } sum = sum%(10^9+7); } cout<<sum<<endl; return 0; }
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:18:1: error: expected '}' before 'else' 18 | else{ | ^~~~ a.cc:14:25: note: to match this '{' 14 | if(b[i]+b[j]<=a[i]+a[j]){ | ^ a.cc:23:10: error: 'bb' was not declared in this scope; did you mean 'b'? 23 | sum +=aa/bb%(10^9+7); | ^~ | b
s980961754
p04051
C++
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair const int MOD = 1e9 + 7; const int N = 2001; int a[200001]; int b[200001]; int dp[8001][8001]; int choose(int a, int b) { if(a < b) return 0; if(dp[a][b] != -1) return dp[a][b]; if(b == 0) return 1; if(b == 1) return a; dp[a][b] = (long long(choose(a - 1, b)) + long long(choose(a - 1, b - 1)))%MOD; return dp[a][b]; } long long modpow(long long a, long long b) { long long r = 1; while(b) { if(b&1) r = (r*a)%MOD; a = (a*a)%MOD; b>>=1; } return r; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for(int i = 0; i < n; i++) { dp[-a[i]+N][-b[i]+N]++; //dp2[a[i]+N][b[i]+N]++; } for(int i = 1; i <= 4010; i++) { for(int j = 1; j <= 4010; j++) { dp[i][j] = (long long(dp[i][j]) + long long(dp[i - 1][j]) + long long(dp[i][j - 1]))%MOD; } } long long ans = 0; long long ans2 = 0; for(int i = 0; i < n; i++) { ans += dp[a[i]+N][b[i]+N]; ans %= MOD; } memset(dp, -1, sizeof(dp)); for(int i = 0; i < n; i++) { ans2 += choose(2*(a[i]+b[i]), 2*b[i]); ans2 %= MOD; } //cout << ans << ' ' << ans2 << endl; ans = (ans - ans2)%MOD; if(ans < 0) ans += MOD; ans = (ans*modpow(2, MOD - 2))%MOD; if(ans < 0) ans += MOD; cout << ans; return 0; }
a.cc: In function 'int choose(int, int)': a.cc:23:21: error: expected primary-expression before 'long' 23 | dp[a][b] = (long long(choose(a - 1, b)) + long long(choose(a - 1, b - 1)))%MOD; | ^~~~ a.cc:23:21: error: expected ')' before 'long' 23 | dp[a][b] = (long long(choose(a - 1, b)) + long long(choose(a - 1, b - 1)))%MOD; | ~^~~~ | ) a.cc: In function 'int main()': a.cc:58:37: error: expected primary-expression before 'long' 58 | dp[i][j] = (long long(dp[i][j]) + long long(dp[i - 1][j]) + long long(dp[i][j - 1]))%MOD; | ^~~~ a.cc:58:37: error: expected ')' before 'long' 58 | dp[i][j] = (long long(dp[i][j]) + long long(dp[i - 1][j]) + long long(dp[i][j - 1]))%MOD; | ~^~~~ | )
s250717547
p04051
C++
#include <bits/stdc++.h> #define FO(i,a,b) for (int i = (a); i < (b); i++) #define sz(v) int(v.size()) #define N 2048 #define MOD 1000000007 using namespace std; int r[8005][4005]; int c[2005][2005]; int main() { int n; scanf("%d", &n); FO(i,0,n) { int a, b; scanf("%d %d", &a, &b); r[2001-a][2001-b]++; c[a][b]++; } long long ans = 0; FO(y,1,4005) FO(x,1,4005) { r[y][x] += r[y-1][x] + r[y][x-1]; if (r[y][x] >= MOD) r[y][x] -= MOD; if (y >= 2001 && x >= 2001) ans += c[y-2001][x-2001] * 1ll * r[y][x]; } memset(r,0,sizeof r); FO(i,0,8005) r[i][0] = 1; FO(i,1,8005) FO(j,1,min(i+1,4005)) { r[i][j] = r[i-1][j] + r[i-1][j-1]; if (r[i][j] >= MOD) r[i][j] -= MOD; } FO(i,0,2005) FO(j,0,2005) if (c[i][j]) { ans -= r[2*i+2*j][2*i] * 1ll * c[i][j]; } if (ans&1) ans += MOD; ans /= 2; printf("%lld\n", ans % MOD); } [ishraq@Boo E]$ fg vim main.cpp [1]+ Stopped vim main.cpp [ishraq@Boo E]$ cat main.cpp #include <bits/stdc++.h> #define FO(i,a,b) for (int i = (a); i < (b); i++) #define sz(v) int(v.size()) #define MOD 1000000007 using namespace std; int r[8005][4005]; int c[2005][2005]; int main() { int n; scanf("%d", &n); FO(i,0,n) { int a, b; scanf("%d %d", &a, &b); r[2001-a][2001-b]++; c[a][b]++; } long long ans = 0; FO(y,1,4005) FO(x,1,4005) { r[y][x] += r[y-1][x] + r[y][x-1]; if (r[y][x] >= MOD) r[y][x] -= MOD; if (y >= 2001 && x >= 2001) ans += c[y-2001][x-2001] * 1ll * r[y][x]; } memset(r,0,sizeof r); FO(i,0,8005) r[i][0] = 1; FO(i,1,8005) FO(j,1,min(i+1,4005)) { r[i][j] = r[i-1][j] + r[i-1][j-1]; if (r[i][j] >= MOD) r[i][j] -= MOD; } FO(i,0,2005) FO(j,0,2005) if (c[i][j]) { ans -= r[2*i+2*j][2*i] * 1ll * c[i][j]; } if (ans&1) ans += MOD; ans /= 2; printf("%lld\n", ans % MOD); }
a.cc:41:8: error: stray '@' in program 41 | [ishraq@Boo E]$ fg | ^ a.cc:45:8: error: stray '@' in program 45 | [ishraq@Boo E]$ cat main.cpp | ^ a.cc:41:1: error: expected unqualified-id before '[' token 41 | [ishraq@Boo E]$ fg | ^ a.cc:55:5: error: redefinition of 'int r [8005][4005]' 55 | int r[8005][4005]; | ^ a.cc:11:5: note: 'int r [8005][4005]' previously declared here 11 | int r[8005][4005]; | ^ a.cc:56:5: error: redefinition of 'int c [2005][2005]' 56 | int c[2005][2005]; | ^ a.cc:12:5: note: 'int c [2005][2005]' previously declared here 12 | int c[2005][2005]; | ^ a.cc:58:5: error: redefinition of 'int main()' 58 | int main() { | ^~~~ a.cc:14:5: note: 'int main()' previously defined here 14 | int main() { | ^~~~
s817368956
p04051
C++
#include <bits/stdc++.h> // iostream is too mainstream #include <cstdio> // bitch please #include <iostream> #include <algorithm> #include <cstdlib> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <cmath> #include <iomanip> #include <time.h> #define dibs reserve #define OVER9000 1234567890 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++) #define tisic 47 #define soclose 1e-8 #define chocolate win // so much chocolate #define patkan 9 #define ff first #define ss second #define abs(x) ((x < 0)?-(x):x) #define uint unsigned int #define dbl long double #define pi 3.14159265358979323846 using namespace std; // mylittledoge #ifdef DONLINE_JUDGE // palindromic tree is better than splay tree! #define lld I64d #endif long long mod =1000000007; long long pw(long long a, long long e) { if(e <= 0) return 1; long long x =pw(a,e/2); x =(x*x)%mod; if(e%2 != 0) x =(x*a)%mod; return x;} int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int N; cin >> N; vector<long long> fac(10000,1),inv(10000,1); for(int i =1; i < 10000; i++) { fac[i] =(i*fac[i-1])%mod; inv[i] =pw(fac[i],mod-2);} poly P(2048,vector<long long>(2048,0)); for(int i =0; i < N; i++) { int a,b; cin >> a >> b; P[a][b]++;} poly P0 =P; for(int i =2000; i > 0; i--) for(int j =2000; j > 0; j--) { P[i][j-1] +=P[i][j]; if(P[i][j-1] >= mod) P[i][j-1] -=mod; P[i-1][j] +=P[i][j]; if(P[i-1][j] >= mod) P[i-1][j] -=mod; P[i][j] =0;} long long ans =0; for(int i =2000; i >= -2000; i--) for(int j =2000; j >= -2000; j--) { int x1 =max(i,0), y1 =max(-i,0); int x2 =max(j,0), y2 =max(-j,0); long long x =(fac[x1+x2+y1+y2]*inv[x1+x2])%mod; x =(x*inv[y1+y2])%mod; long long p =(P[x1][y1]*P[x2][y2])%mod; ans =(ans+p*x)%mod;} for(int i =0; i < 2048; i++) for(int j =0; j < 2048; j++) { long long x =(fac[2*(i+j)]*inv[2*i])%mod; x =(x*inv[2*j])%mod; ans =(ans-P0[i][j]%mod*x)%mod;} ans =(ans*inv[2])%mod; if(ans < 0) ans +=mod; cout << ans << "\n"; return 0;} // look at my code // my code is amazing
a.cc: In function 'int main()': a.cc:59:9: error: 'poly' was not declared in this scope 59 | poly P(2048,vector<long long>(2048,0)); | ^~~~ a.cc:63:17: error: 'P' was not declared in this scope 63 | P[a][b]++;} | ^ a.cc:64:13: error: expected ';' before 'P0' 64 | poly P0 =P; | ^~~ | ; a.cc:67:17: error: 'P' was not declared in this scope 67 | P[i][j-1] +=P[i][j]; | ^ a.cc:79:31: error: 'P' was not declared in this scope 79 | long long p =(P[x1][y1]*P[x2][y2])%mod; | ^ a.cc:84:27: error: 'P0' was not declared in this scope; did you mean 'y0'? 84 | ans =(ans-P0[i][j]%mod*x)%mod;} | ^~ | y0
s724454197
p04051
C++
#include<vector> #include<cmath> #include<map> #include<cstdlib> #include<iostream> #include<sstream> #include<fstream> #include<string> #include<algorithm> #include<cstring> #include<cstdio> #include<set> #include<stack> #include<bitset> #include<functional> #include<ctime> #include<queue> #include<deque> #include<complex> using namespace std; #define pb push_back #define pf push_front typedef long long lint; typedef complex<double> P; #define mp make_pair #define fi first #define se second typedef pair<int,int> pint; #define All(s) s.begin(),s.end() #define rAll(s) s.rbegin(),s.rend() #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) lint mo=1000000007; lint ma[4100][4100]; int A[252521],B[252521]; lint extgcd(lint a, lint b, lint &x, lint &y) { lint g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } lint invMod(lint a, lint m) { lint x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0; } #define N 4096 const double pi = 4.0*atan(1.0); const P I(0, 1); vector<P> fft(int n, double theta, vector<P> a) { for (int m = n; m >= 2; m >>= 1) { int mh = m >> 1; for (int i = 0; i < mh; i++) { P w = exp(i*theta*I); for (int j = i; j < n; j += m) { int k = j + mh; P x = a[j] - a[k]; a[j] += a[k]; a[k] = w * x; } } theta *= 2; } int i = 0; for (int j = 1; j < n - 1; j++) { for (int k = n >> 1; k > (i ^= k); k >>= 1); if (j < i) swap(a[i], a[j]); } return a; } vector<vector<P> > fft2(int n,double theta, vector<vector<P> > a){ for (int m = n; m >= 2; m >>= 1) { int mh = m >> 1; for (int i = 0; i < mh; i++) { P w = exp(i*theta*I); for (int j = i; j < n; j += m) { int k = j + mh; vector<P> x; rep(l,n) x.pb(a[j][l] - a[k][l]); rep(l,n) a[j][l] += a[k][l]; rep(l,n) a[k][l] = w * x[l]; } } theta *= 2; } int i = 0; for (int j = 1; j < n - 1; j++) { for (int k = n >> 1; k > (i ^= k); k >>= 1); if (j < i) swap(a[i], a[j]); } return a; } int main() { int n,a,b;lint out=0; memset(ma,0,sizeof(ma)); scanf("%d",&n); rep(i,n){ scanf("%d %d",&A[i],&B[i]);ma[A[i]][B[i]]++; } vector<P> vec(4100,P(0,0)); vector<vector<P> > mat(4100,vec); rep(i,2050) rep(j,2050) mat[i][j].real()+=P(ma[i][j],0); //cout<<a<<endl; rep(i,4100) mat[i]=fft(N,2*pi/N,mat[i]); mat=fft2(N,2*pi/N,mat); rep(i,N) rep(j,N) mat[i][j]*=mat[i][j]; mat=fft2(N,-2*pi/N,mat); rep(i,4100) mat[i]=fft(N,-2*pi/N,mat[i]); //cout<<a<<endl; vector<lint> zyo,rz; zyo.pb(1); rep(i,N) zyo.pb((zyo[i]*(i+1))%mo); rep(i,N) rz.pb(invMod(zyo[i],mo)); rep(i,4098) rep(j,4098){ lint x=(lint)(mat[i][j].real()+0.01); x/=N*N; ma[i][j]=x; } rep(i,n) ma[A[i]*2][B[i]*2]--; rep(i,4098) rep(j,4098){ lint x=ma[i][j]/2; if(x>0){ //cout<<i<<' '<<j<<' '<<x<<endl; out+=((x*zyo[i+j]%mo)*rz[i])%mo*rz[j]; out%=mo; } } cout<<out<<endl; }
a.cc: In function 'int main()': a.cc:102:49: error: no match for 'operator+=' (operand types are 'double' and 'P' {aka 'std::complex<double>'}) 102 | rep(i,2050) rep(j,2050) mat[i][j].real()+=P(ma[i][j],0); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
s040923796
p04051
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define forn(i, a, n) for (int i = a; i < n; ++i) #define ford(i, a, n) for (int i = n - 1; i >= a; --i) #define fore(i, a, n) for (int i = a; i <= n; ++i) #define all(a) (a).begin(), (a).end() #define fs first #define sn second #define trace(a)\ for (auto i : a) cerr << i << ' ';\ cerr << '\n' #define eb emplace_back #ifndef M_PI const ld M_PI = acos(-1.0); #endif const ld eps = 1e-9; const int INF = 2000000000; const ll LINF = 1ll * INF * INF; const ll MOD = 1000000007; /* * Let R denote the ring of integers modulo 2^64. * * Our goal here is to develop a fast and straightforward way of multiplying * polynomials in R[x]. * */ /* * Our first step is to note that the standard Radix-2 FFT has the problem that * its inverse transform requires division by 2, which is not invertible in R. * * We solve this by employing a Radix-3 FFT, which handles arrays whose size is * a power of 3, and whose inverse transform requires division by 3. * * Now for FFT to work, the ring has to have a sufficiently powerful 3^m'th * root of unity, and since the unit ring of R is Z_2 x Z_{2^62}, it only has * roots of unity of order 2^m. * * The first step to solving this is by expanding the ring to have a 3rd root * of unity. This extension can be realized as the ring R[omega]/(omega^2 + * omega + 1), that is polynomials of the form a + b*omega, with the property * that omega^2 = - omega - 1. It follows that omega^3 = 1. * * We call this new ring T and define the following type for its elements. */ struct T { uint64_t a, b; T() : a(0), b(0) { } T(uint64_t x) : a(x), b(0) { } T(uint64_t a, uint64_t b) : a(a), b(b) { } //The conjugate of a + b*omega is given by mapping omega -> omega^2 T conj() { return T{a - b, -b}; } T operator-() { return T{-a, -b}; } }; /* * A couple of useful constants: `OMEGA` is a third root of unity, `OMEGA2` is * its square and `INV3` is the multiplicative inverse of 3. */ const T OMEGA = {0, 1}; const T OMEGA2 = {-1ull, -1ull}; const T INV3 = {12297829382473034411ull, 0}; /* * Standard operators. */ T operator+(const T &u, const T &v) { return {u.a + v.a, u.b + v.b}; } T operator-(const T &u, const T &v) { return {u.a - v.a, u.b - v.b}; } T operator*(const T &u, const T &v) { return {u.a*v.a - u.b*v.b, u.b*v.a + u.a*v.b - u.b*v.b}; } void operator+=(T &u, const T &v) { u.a += v.a; u.b += v.b; } void operator-=(T &u, const T &v) { u.a -= v.a; u.b -= v.b; } void operator*=(T &u, const T &v) { uint64_t tmp=u.a; u.a=u.a*v.a - u.b*v.b; u.b=u.b*v.a + tmp*v.b - u.b*v.b; } // We pack the main algorithm in a class of its own, mainly because we will have // to allocate some temporary working memory. class Conv64 { public: // Returns the product of two polynomials from the ring R[x]. vector<int64_t> multiply(const vector<int64_t> &p, const vector<int64_t> &q) { vector<uint64_t> pp(p.size()), qq(q.size()); for (uint64_t i = 0; i < p.size(); ++i) { pp[i] = p[i]; } for (uint64_t i = 0; i < q.size(); ++i) { qq[i] = q[i]; } uint64_t s = 1; while (s < p.size() + q.size() - 1) { s *= 3; } pp.resize(s); qq.resize(s); vector<int64_t> res(s); multiply_cyclic_raw(pp.data(), qq.data(), pp.size(), (uint64_t*)res.data()); res.resize(p.size() + q.size() - 1); return res; } private: // Temporary space. T *tmp; // Returns the product of a polynomial and the monomial x^t in the ring // T[x]/(x^m - omega). The result is placed in `to`. // NOTE: t must be in the range [0,3m] void twiddle(T *p, uint64_t m, uint64_t t, T *to) { if (t == 0 || t == 3*m) { for (uint64_t j = 0; j < m; ++j) { to[j] = p[j]; } return; } uint64_t tt; T mult = 1; if (t < m) { tt = t; } else if (t < 2*m) { tt = t - m; mult = OMEGA; } else { tt = t - 2*m; mult = OMEGA2; } for (uint64_t j=0;j<tt;j++) { to[j] = p[m - tt + j]*OMEGA*mult; } for (uint64_t j=tt;j<m;j++) { to[j] = p[j-tt]*mult; } } // A "Decimation In Frequency" In-Place Radix-3 FFT Routine. // Input: A polynomial from (T[x]/(x^m - omega))[y]/(y^r - 1). // Output: Its Fourier transform (w.r.t. y) in 3-reversed order. void fftdif(T *p, uint64_t m, uint64_t r) { if (r == 1) return; uint64_t rr = r/3; uint64_t pos1 = m*rr, pos2 = 2*m*rr; for (uint64_t i = 0; i < rr; ++i) { for (uint64_t j = 0; j < m; ++j) { tmp[j] = p[i*m + j] + p[pos1 + i*m + j] + p[pos2 + i*m + j]; tmp[m + j] = p[i*m + j] + OMEGA*p[pos1 + i*m + j] + OMEGA2*p[pos2 + i*m + j]; tmp[2*m + j] = p[i*m + j] + OMEGA2*p[pos1 + i*m + j] + OMEGA*p[pos2 + i*m + j]; p[i*m + j] = tmp[j]; } twiddle(tmp + m, m, 3*i*m/r, p + pos1 + i*m); twiddle(tmp + 2*m, m, 6*i*m/r, p + pos2 + i*m); } fftdif(p, m, rr); fftdif(p + pos1, m, rr); fftdif(p + pos2, m, rr); } // A "Decimation In Time" In-Place Radix-3 Inverse FFT Routine. // Input: A polynomial in (T[x]/(x^m - omega))[y]/(y^r - 1) with coefficients // in 3-reversed order. // Output: Its inverse Fourier transform in normal order. void fftdit(T *p, uint64_t m, uint64_t r) { if (r == 1) return; uint64_t rr = r/3; uint64_t pos1 = m*rr, pos2 = 2*m*rr; fftdit(p, m, rr); fftdit(p + pos1, m, rr); fftdit(p + pos2, m, rr); for (uint64_t i = 0; i < rr; ++i) { twiddle(p + pos1 + i*m, m, 3*m - 3*i*m/r, tmp + m); twiddle(p + pos2 + i*m, m, 3*m - 6*i*m/r, tmp + 2*m); for(uint64_t j = 0; j < m; ++j) { tmp[j] = p[i*m + j]; p[i*m + j] = tmp[j] + tmp[m + j] + tmp[2*m + j]; p[i*m + pos1 + j] = tmp[j] + OMEGA2*tmp[m + j] + OMEGA*tmp[2*m + j]; p[i*m + pos2 + j] = tmp[j] + OMEGA*tmp[m + j] + OMEGA2*tmp[2*m + j]; } } } // Computes the product of two polynomials in T[x]/(x^n - omega), where n is // a power of 3. The result is placed in `to`. void mul(T *p, T *q, uint64_t n, T *to) { if (n <= 27) { // O(n^2) grade-school multiplication for (uint64_t i = 0; i < n; ++i) { to[i]=0; } for (uint64_t i = 0; i < n; ++i) { for (uint64_t j = 0; j < n - i; ++j) { to[i + j] += p[i]*q[j]; } for (uint64_t j = n - i; j < n; ++j) { to[i + j - n] += p[i]*q[j]*OMEGA; } } return; } uint64_t m = 1; while (m*m < n) { m *= 3; } uint64_t r = n/m; T inv = 1; for (uint64_t i = 1; i < r; i *= 3) { inv *= INV3; } /********************************************************** * THE PRODUCT IN (T[x]/(x^m - omega))[y] / (y^r - omega) * **********************************************************/ // Move to the ring (T[x]/(x^m - omega))[y]/(y^r - 1) via the map y -> x^(m/r) y for (uint64_t i = 0; i < r; ++i) { twiddle(p + m*i, m, m/r*i, to + m*i); twiddle(q + m*i, m, m/r*i, to + n + m*i); } // Multiply using FFT fftdif(to, m, r); fftdif(to + n, m, r); for (uint64_t i = 0; i < r; ++i) { mul(to + m*i, to + n + m*i, m, to +2*n + m*i); } fftdit(to + 2*n, m, r); for (uint64_t i = 0; i < n; ++i) { to[2*n + i] *= inv; } // Return to the ring (T[x]/(x^m - omega))[y]/(y^r - omega) for (uint64_t i = 0; i < r; ++i) { twiddle(to + 2*n + m*i, m, 3*m - m/r*i, to + n + m*i); } /************************************************************ * THE PRODUCT IN (T[x]/(x^m - omega^2))[y] / (y^r - omega) * ************************************************************/ // Use conjugation to move to the ring (T[x]/(x^m - omega))[y]/(y^r - omega^2). // Then move to (T[x]/(x^m - omega))[y]/(y^r - 1) via the map y -> x^(2m/r) y for (uint64_t i = 0; i < r; ++i) { for (uint64_t j = 0; j < m; ++j) { p[m*i + j] = p[m*i + j].conj(); q[m*i + j] = q[m*i + j].conj(); } twiddle(p + m*i, m, 2*m/r*i, to + m*i); twiddle(q + m*i, m, 2*m/r*i, p + m*i); } fftdif(to, m, r); fftdif(p, m, r); for (uint64_t i = 0; i < r; ++i) { mul(to + m*i, p + m*i, m, to + 2*n + m*i); } fftdit(to + 2*n, m, r); for (uint64_t i = 0; i < n; ++i) { to[2*n + i] *= inv; } for (uint64_t i = 0; i < r; ++i) { twiddle(to + 2*n + m*i, m, 3*m - 2*m/r*i, q + m*i); } /************************************************************************** * The product in (T[x]/(x^(2m) + x^m + 1))[y]/(y^r - omega) via CRT, and * * unravelling the substitution y = x^m at the same time. * **************************************************************************/ for (uint64_t i = 0; i < n; ++i) { to[i] = 0; } for (uint64_t i = 0; i < r; ++i) { for (uint64_t j = 0; j < m; ++j) { to[i*m + j] += (1 - OMEGA)*to[n + i*m + j] + (1 - OMEGA2)*q[i*m + j].conj(); if (i*m + m + j < n) { to[i*m + m + j] += (OMEGA2 - OMEGA)*(to[n + i*m + j] - q[i*m + j].conj()); } else { to[i*m + m + j - n] += (1 - OMEGA2)*(to[n + i*m + j] - q[i*m + j].conj()); } } } for (uint64_t i = 0; i < n; ++i) { to[i] *= INV3; } } // Computes the product of two polynomials from the ring R[x]/(x^n - 1), where // n must be a power of three. The result is placed in target which must have // space for n elements. void multiply_cyclic_raw(uint64_t *p, uint64_t *q, uint64_t n, uint64_t *target) { // If n = 3^k, let m = 3^(floor(k/2)) and r = 3^(ceil(k/2)) uint64_t m = 1; while (m*m <= n) { m *= 3; } m /= 3; uint64_t r = n/m; // Compute 3^(-r) T inv = 1; for (uint64_t i = 1; i < r; i *= 3) { inv *= INV3; } // Allocate some working memory, the layout is as follows: // pp: length n // qq: length n // to: length n + 3*m // tmp: length 3*m T *buf = new T[3*n + 6*m]; T *pp = buf; T *qq = buf + n; T *to = buf + 2*n; tmp = buf + 3*n + 3*m; for (uint64_t i = 0; i < n; ++i) { pp[i] = p[i]; qq[i] = q[i]; } // By setting y = x^m, we may write our polynomials in the form // (p_0 + p_1 x + ... + p_{m-1} x^{m-1}) // + (p_m + ... + p_{2m-1} x^{m-1}) y // + ... // + (p_{(r-1)m} + ... + p_{rm - 1} x^{m-1}) y^r // // In this way we can view p and q as elements of the ring S[y]/(y^r - 1), // where S = R[x]/(x^m - omega), and since r <= 3m, we know that x^{3m/r} is // an rth root of unity. We can therefore use FFT to calculate the product // in S[y]/(y^r - 1). fftdif(pp, m, r); fftdif(qq, m, r); for (uint64_t i = 0; i < r; ++i) { mul(pp + i*m, qq + i*m, m, to + i*m); } fftdit(to, m, r); for (uint64_t i = 0; i<n; ++i) { pp[i] = to[i]*inv; } // Now, the product in (T[x]/(x^m - omega^2))[y](y^r - 1) is simply the // conjugate of the product in (T[x]/(x^m - omega))[y]/(y^r - 1), because // there is no omega-component in the data. // // By the Chinese Remainder Theorem we can obtain the product in the // ring (T[x]/(x^(2m) + x^m + x))[y]/(y^r - 1), and then set y=x^m to get // the result. for (uint64_t i = 0; i < n; ++i) to[i] = 0; for (uint64_t i = 0; i < r; ++i) { for (uint64_t j = 0; j < m; ++j) { to[i*m + j] += (1 - OMEGA)*pp[i*m + j] + (1 - OMEGA2)*pp[i*m + j].conj(); if (i*m + m + j < n) { to[i*m + m + j] += (OMEGA2 - OMEGA)*(pp[i*m + j] - pp[i*m + j].conj()); } else { to[i*m + m + j - n] += (OMEGA2 - OMEGA) * (pp[i*m + j] - pp[i*m + j].conj()); } } } for (uint64_t i = 0; i < n; ++i) { target[i] = (to[i]*INV3).a; } delete[] buf; } }; const int N = 2010; ll bin[N][N]; int main() { ios::sync_with_stdio(false); cin.tie(0); Conv64 c; int n; cin >> n; vector<int64_t> in(N * N); forn(i, 0, n) { int a, b; cin >> a >> b; in[a * N + b]++; } vector<int64_t> res = c.multuply(in, in); forn(i, 0, N) bin[i][0] = 1; forn(i, 0, N) bin[0][i] = 1; forn(i, 1, N) forn(j, 1, N) bin[i][j] = (bin[i][j - 1] + bin[i - 1][j]) % MOD; ll ans = 0; forn(x, 0, N * N) { ll a = x / N, b = x % N; ans += bin[a][b] * c[x]; ans %= MOD; } cout << ans << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:425:33: error: 'class Conv64' has no member named 'multuply'; did you mean 'multiply'? 425 | vector<int64_t> res = c.multuply(in, in); | ^~~~~~~~ | multiply a.cc:432:37: error: no match for 'operator[]' (operand types are 'Conv64' and 'int') 432 | ans += bin[a][b] * c[x]; | ^
s877606431
p04051
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define forn(i, a, n) for (int i = a; i < n; ++i) #define ford(i, a, n) for (int i = n - 1; i >= a; --i) #define fore(i, a, n) for (int i = a; i <= n; ++i) #define all(a) (a).begin(), (a).end() #define fs first #define sn second #define trace(a)\ for (auto i : a) cerr << i << ' ';\ cerr << '\n' #define eb emplace_back #ifndef M_PI const ld M_PI = acos(-1.0); #endif const ld eps = 1e-9; const int INF = 2000000000; const ll LINF = 1ll * INF * INF; const ll MOD = 1000000007; /* * Let R denote the ring of integers modulo 2^64. * * Our goal here is to develop a fast and straightforward way of multiplying * polynomials in R[x]. * */ /* * Our first step is to note that the standard Radix-2 FFT has the problem that * its inverse transform requires division by 2, which is not invertible in R. * * We solve this by employing a Radix-3 FFT, which handles arrays whose size is * a power of 3, and whose inverse transform requires division by 3. * * Now for FFT to work, the ring has to have a sufficiently powerful 3^m'th * root of unity, and since the unit ring of R is Z_2 x Z_{2^62}, it only has * roots of unity of order 2^m. * * The first step to solving this is by expanding the ring to have a 3rd root * of unity. This extension can be realized as the ring R[omega]/(omega^2 + * omega + 1), that is polynomials of the form a + b*omega, with the property * that omega^2 = - omega - 1. It follows that omega^3 = 1. * * We call this new ring T and define the following type for its elements. */ struct T { uint64_t a, b; T() : a(0), b(0) { } T(uint64_t x) : a(x), b(0) { } T(uint64_t a, uint64_t b) : a(a), b(b) { } //The conjugate of a + b*omega is given by mapping omega -> omega^2 T conj() { return T{a - b, -b}; } T operator-() { return T{-a, -b}; } }; /* * A couple of useful constants: `OMEGA` is a third root of unity, `OMEGA2` is * its square and `INV3` is the multiplicative inverse of 3. */ const T OMEGA = {0, 1}; const T OMEGA2 = {-1ull, -1ull}; const T INV3 = {12297829382473034411ull, 0}; /* * Standard operators. */ T operator+(const T &u, const T &v) { return {u.a + v.a, u.b + v.b}; } T operator-(const T &u, const T &v) { return {u.a - v.a, u.b - v.b}; } T operator*(const T &u, const T &v) { return {u.a*v.a - u.b*v.b, u.b*v.a + u.a*v.b - u.b*v.b}; } void operator+=(T &u, const T &v) { u.a += v.a; u.b += v.b; } void operator-=(T &u, const T &v) { u.a -= v.a; u.b -= v.b; } void operator*=(T &u, const T &v) { uint64_t tmp=u.a; u.a=u.a*v.a - u.b*v.b; u.b=u.b*v.a + tmp*v.b - u.b*v.b; } // We pack the main algorithm in a class of its own, mainly because we will have // to allocate some temporary working memory. class Conv64 { public: // Returns the product of two polynomials from the ring R[x]. vector<int64_t> multiply(const vector<int64_t> &p, const vector<int64_t> &q) { vector<uint64_t> pp(p.size()), qq(q.size()); for (uint64_t i = 0; i < p.size(); ++i) { pp[i] = p[i]; } for (uint64_t i = 0; i < q.size(); ++i) { qq[i] = q[i]; } uint64_t s = 1; while (s < p.size() + q.size() - 1) { s *= 3; } pp.resize(s); qq.resize(s); vector<int64_t> res(s); multiply_cyclic_raw(pp.data(), qq.data(), pp.size(), (uint64_t*)res.data()); res.resize(p.size() + q.size() - 1); return res; } private: // Temporary space. T *tmp; // Returns the product of a polynomial and the monomial x^t in the ring // T[x]/(x^m - omega). The result is placed in `to`. // NOTE: t must be in the range [0,3m] void twiddle(T *p, uint64_t m, uint64_t t, T *to) { if (t == 0 || t == 3*m) { for (uint64_t j = 0; j < m; ++j) { to[j] = p[j]; } return; } uint64_t tt; T mult = 1; if (t < m) { tt = t; } else if (t < 2*m) { tt = t - m; mult = OMEGA; } else { tt = t - 2*m; mult = OMEGA2; } for (uint64_t j=0;j<tt;j++) { to[j] = p[m - tt + j]*OMEGA*mult; } for (uint64_t j=tt;j<m;j++) { to[j] = p[j-tt]*mult; } } // A "Decimation In Frequency" In-Place Radix-3 FFT Routine. // Input: A polynomial from (T[x]/(x^m - omega))[y]/(y^r - 1). // Output: Its Fourier transform (w.r.t. y) in 3-reversed order. void fftdif(T *p, uint64_t m, uint64_t r) { if (r == 1) return; uint64_t rr = r/3; uint64_t pos1 = m*rr, pos2 = 2*m*rr; for (uint64_t i = 0; i < rr; ++i) { for (uint64_t j = 0; j < m; ++j) { tmp[j] = p[i*m + j] + p[pos1 + i*m + j] + p[pos2 + i*m + j]; tmp[m + j] = p[i*m + j] + OMEGA*p[pos1 + i*m + j] + OMEGA2*p[pos2 + i*m + j]; tmp[2*m + j] = p[i*m + j] + OMEGA2*p[pos1 + i*m + j] + OMEGA*p[pos2 + i*m + j]; p[i*m + j] = tmp[j]; } twiddle(tmp + m, m, 3*i*m/r, p + pos1 + i*m); twiddle(tmp + 2*m, m, 6*i*m/r, p + pos2 + i*m); } fftdif(p, m, rr); fftdif(p + pos1, m, rr); fftdif(p + pos2, m, rr); } // A "Decimation In Time" In-Place Radix-3 Inverse FFT Routine. // Input: A polynomial in (T[x]/(x^m - omega))[y]/(y^r - 1) with coefficients // in 3-reversed order. // Output: Its inverse Fourier transform in normal order. void fftdit(T *p, uint64_t m, uint64_t r) { if (r == 1) return; uint64_t rr = r/3; uint64_t pos1 = m*rr, pos2 = 2*m*rr; fftdit(p, m, rr); fftdit(p + pos1, m, rr); fftdit(p + pos2, m, rr); for (uint64_t i = 0; i < rr; ++i) { twiddle(p + pos1 + i*m, m, 3*m - 3*i*m/r, tmp + m); twiddle(p + pos2 + i*m, m, 3*m - 6*i*m/r, tmp + 2*m); for(uint64_t j = 0; j < m; ++j) { tmp[j] = p[i*m + j]; p[i*m + j] = tmp[j] + tmp[m + j] + tmp[2*m + j]; p[i*m + pos1 + j] = tmp[j] + OMEGA2*tmp[m + j] + OMEGA*tmp[2*m + j]; p[i*m + pos2 + j] = tmp[j] + OMEGA*tmp[m + j] + OMEGA2*tmp[2*m + j]; } } } // Computes the product of two polynomials in T[x]/(x^n - omega), where n is // a power of 3. The result is placed in `to`. void mul(T *p, T *q, uint64_t n, T *to) { if (n <= 27) { // O(n^2) grade-school multiplication for (uint64_t i = 0; i < n; ++i) { to[i]=0; } for (uint64_t i = 0; i < n; ++i) { for (uint64_t j = 0; j < n - i; ++j) { to[i + j] += p[i]*q[j]; } for (uint64_t j = n - i; j < n; ++j) { to[i + j - n] += p[i]*q[j]*OMEGA; } } return; } uint64_t m = 1; while (m*m < n) { m *= 3; } uint64_t r = n/m; T inv = 1; for (uint64_t i = 1; i < r; i *= 3) { inv *= INV3; } /********************************************************** * THE PRODUCT IN (T[x]/(x^m - omega))[y] / (y^r - omega) * **********************************************************/ // Move to the ring (T[x]/(x^m - omega))[y]/(y^r - 1) via the map y -> x^(m/r) y for (uint64_t i = 0; i < r; ++i) { twiddle(p + m*i, m, m/r*i, to + m*i); twiddle(q + m*i, m, m/r*i, to + n + m*i); } // Multiply using FFT fftdif(to, m, r); fftdif(to + n, m, r); for (uint64_t i = 0; i < r; ++i) { mul(to + m*i, to + n + m*i, m, to +2*n + m*i); } fftdit(to + 2*n, m, r); for (uint64_t i = 0; i < n; ++i) { to[2*n + i] *= inv; } // Return to the ring (T[x]/(x^m - omega))[y]/(y^r - omega) for (uint64_t i = 0; i < r; ++i) { twiddle(to + 2*n + m*i, m, 3*m - m/r*i, to + n + m*i); } /************************************************************ * THE PRODUCT IN (T[x]/(x^m - omega^2))[y] / (y^r - omega) * ************************************************************/ // Use conjugation to move to the ring (T[x]/(x^m - omega))[y]/(y^r - omega^2). // Then move to (T[x]/(x^m - omega))[y]/(y^r - 1) via the map y -> x^(2m/r) y for (uint64_t i = 0; i < r; ++i) { for (uint64_t j = 0; j < m; ++j) { p[m*i + j] = p[m*i + j].conj(); q[m*i + j] = q[m*i + j].conj(); } twiddle(p + m*i, m, 2*m/r*i, to + m*i); twiddle(q + m*i, m, 2*m/r*i, p + m*i); } fftdif(to, m, r); fftdif(p, m, r); for (uint64_t i = 0; i < r; ++i) { mul(to + m*i, p + m*i, m, to + 2*n + m*i); } fftdit(to + 2*n, m, r); for (uint64_t i = 0; i < n; ++i) { to[2*n + i] *= inv; } for (uint64_t i = 0; i < r; ++i) { twiddle(to + 2*n + m*i, m, 3*m - 2*m/r*i, q + m*i); } /************************************************************************** * The product in (T[x]/(x^(2m) + x^m + 1))[y]/(y^r - omega) via CRT, and * * unravelling the substitution y = x^m at the same time. * **************************************************************************/ for (uint64_t i = 0; i < n; ++i) { to[i] = 0; } for (uint64_t i = 0; i < r; ++i) { for (uint64_t j = 0; j < m; ++j) { to[i*m + j] += (1 - OMEGA)*to[n + i*m + j] + (1 - OMEGA2)*q[i*m + j].conj(); if (i*m + m + j < n) { to[i*m + m + j] += (OMEGA2 - OMEGA)*(to[n + i*m + j] - q[i*m + j].conj()); } else { to[i*m + m + j - n] += (1 - OMEGA2)*(to[n + i*m + j] - q[i*m + j].conj()); } } } for (uint64_t i = 0; i < n; ++i) { to[i] *= INV3; } } // Computes the product of two polynomials from the ring R[x]/(x^n - 1), where // n must be a power of three. The result is placed in target which must have // space for n elements. void multiply_cyclic_raw(uint64_t *p, uint64_t *q, uint64_t n, uint64_t *target) { // If n = 3^k, let m = 3^(floor(k/2)) and r = 3^(ceil(k/2)) uint64_t m = 1; while (m*m <= n) { m *= 3; } m /= 3; uint64_t r = n/m; // Compute 3^(-r) T inv = 1; for (uint64_t i = 1; i < r; i *= 3) { inv *= INV3; } // Allocate some working memory, the layout is as follows: // pp: length n // qq: length n // to: length n + 3*m // tmp: length 3*m T *buf = new T[3*n + 6*m]; T *pp = buf; T *qq = buf + n; T *to = buf + 2*n; tmp = buf + 3*n + 3*m; for (uint64_t i = 0; i < n; ++i) { pp[i] = p[i]; qq[i] = q[i]; } // By setting y = x^m, we may write our polynomials in the form // (p_0 + p_1 x + ... + p_{m-1} x^{m-1}) // + (p_m + ... + p_{2m-1} x^{m-1}) y // + ... // + (p_{(r-1)m} + ... + p_{rm - 1} x^{m-1}) y^r // // In this way we can view p and q as elements of the ring S[y]/(y^r - 1), // where S = R[x]/(x^m - omega), and since r <= 3m, we know that x^{3m/r} is // an rth root of unity. We can therefore use FFT to calculate the product // in S[y]/(y^r - 1). fftdif(pp, m, r); fftdif(qq, m, r); for (uint64_t i = 0; i < r; ++i) { mul(pp + i*m, qq + i*m, m, to + i*m); } fftdit(to, m, r); for (uint64_t i = 0; i<n; ++i) { pp[i] = to[i]*inv; } // Now, the product in (T[x]/(x^m - omega^2))[y](y^r - 1) is simply the // conjugate of the product in (T[x]/(x^m - omega))[y]/(y^r - 1), because // there is no omega-component in the data. // // By the Chinese Remainder Theorem we can obtain the product in the // ring (T[x]/(x^(2m) + x^m + x))[y]/(y^r - 1), and then set y=x^m to get // the result. for (uint64_t i = 0; i < n; ++i) to[i] = 0; for (uint64_t i = 0; i < r; ++i) { for (uint64_t j = 0; j < m; ++j) { to[i*m + j] += (1 - OMEGA)*pp[i*m + j] + (1 - OMEGA2)*pp[i*m + j].conj(); if (i*m + m + j < n) { to[i*m + m + j] += (OMEGA2 - OMEGA)*(pp[i*m + j] - pp[i*m + j].conj()); } else { to[i*m + m + j - n] += (OMEGA2 - OMEGA) * (pp[i*m + j] - pp[i*m + j].conj()); } } } for (uint64_t i = 0; i < n; ++i) { target[i] = (to[i]*INV3).a; } delete[] buf; } }; const int N = 2010; ll bin[N][N]; int main() { ios::sync_with_stdio(false); cin.tie(0); Conv64 c; int n; cin >> n; vector<int64_t> in(N * N); forn(i, 0, n) { int a, b; cin >> a >> b; in[a * N + b]++l } vector<int64_t> res = c.multuply(in, in); forn(i, 0, N) bin[i][0] = 1; forn(i, 0, N) bin[0][i] = 1; forn(i, 1, N) forn(j, 1, N) bin[i][j] = (bin[i][j - 1] + bin[i - 1][j]) % MOD; ll ans = 0; forn(x, 0, N * N) { ll a = x / N, b = x % N; ans += bin[a][b] * c[x]; ans %= MOD; } cout << ans << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:423:32: error: expected ';' before 'l' 423 | in[a * N + b]++l | ^ | ; a.cc:425:33: error: 'class Conv64' has no member named 'multuply'; did you mean 'multiply'? 425 | vector<int64_t> res = c.multuply(in, in); | ^~~~~~~~ | multiply a.cc:432:37: error: no match for 'operator[]' (operand types are 'Conv64' and 'int') 432 | ans += bin[a][b] * c[x]; | ^
s570188151
p04051
C++
#include<vector> #include<cmath> #include<map> #include<cstdlib> #include<iostream> #include<sstream> #include<fstream> #include<string> #include<algorithm> #include<cstring> #include<cstdio> #include<set> #include<stack> #include<bitset> #include<functional> #include<ctime> #include<queue> #include<deque> #include<complex> using namespace std; #define pb push_back #define pf push_front typedef long long lint; typedef complex<double> P; #define mp make_pair #define fi first #define se second typedef pair<int,int> pint; #define All(s) s.begin(),s.end() #define rAll(s) s.rbegin(),s.rend() #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) lint mo=1000000007; lint ma[4100][4100]; int A[252521],B[252521]; lint extgcd(lint a, lint b, lint &x, lint &y) { lint g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } lint invMod(lint a, lint m) { lint x, y; if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0; } #define N 4096 const double pi = 4.0*atan(1.0); const P I(0, 1); vector<P> fft(int n, double theta, vector<P> a) { for (int m = n; m >= 2; m >>= 1) { int mh = m >> 1; for (int i = 0; i < mh; i++) { P w = exp(i*theta*I); for (int j = i; j < n; j += m) { int k = j + mh; P x = a[j] - a[k]; a[j] += a[k]; a[k] = w * x; } } theta *= 2; } int i = 0; for (int j = 1; j < n - 1; j++) { for (int k = n >> 1; k > (i ^= k); k >>= 1); if (j < i) swap(a[i], a[j]); } return a; } vector<vector<P> > fft2(int n,double theta, vector<vector<P> > a){ for (int m = n; m >= 2; m >>= 1) { int mh = m >> 1; for (int i = 0; i < mh; i++) { P w = exp(i*theta*I); for (int j = i; j < n; j += m) { int k = j + mh; vector<P> x; rep(l,n) x.pb(a[j][l] - a[k][l]); rep(l,n) a[j][l] += a[k][l]; rep(l,n) a[k][l] = w * x[l]; } } theta *= 2; } int i = 0; for (int j = 1; j < n - 1; j++) { for (int k = n >> 1; k > (i ^= k); k >>= 1); if (j < i) swap(a[i], a[j]); } return a; } int main() { int n,a,b;lint out=0; memset(ma,0,sizeof(ma)); scanf("%d",&n); rep(i,n){ scanf("%d %d",&A[i],&B[i]);ma[A[i]][B[i]]++; } vector<P> vec(4100,P(0,0)); vector<vector<P> > mat(4100,vec); rep(i,2050) rep(j,2050) mat[i][j].real()=ma[i][j]; //cout<<a<<endl; rep(i,4100) mat[i]=fft(N,2*pi/N,mat[i]); mat=fft2(N,2*pi/N,mat); rep(i,N) rep(j,N) mat[i][j]*=mat[i][j]; mat=fft2(N,-2*pi/N,mat); rep(i,4100) mat[i]=fft(N,-2*pi/N,mat[i]); //cout<<a<<endl; vector<lint> zyo,rz; zyo.pb(1); rep(i,N) zyo.pb((zyo[i]*(i+1))%mo); rep(i,N) rz.pb(invMod(zyo[i],mo)); rep(i,4098) rep(j,4098){ lint x=(lint)(mat[i][j].real()+0.01); x/=N*N; ma[i][j]=x; } rep(i,n) ma[A[i]*2][B[i]*2]--; rep(i,4098) rep(j,4098){ lint x=ma[i][j]/2; if(x>0){ //cout<<i<<' '<<j<<' '<<x<<endl; out+=((x*zyo[i+j]%mo)*rz[i])%mo*rz[j]; out%=mo; } } cout<<out<<endl; }
a.cc: In function 'int main()': a.cc:102:47: error: lvalue required as left operand of assignment 102 | rep(i,2050) rep(j,2050) mat[i][j].real()=ma[i][j]; | ~~~~~~~~~~~~~~^~
s659171877
p04051
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <cmath> #include <map> using namespace std; #define MOD 1000000007 #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD) typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; int N, A[202020], B[202020]; //vector<i64> kind[4004]; i64 u[4020][4020]; int v[2010][2010]; int main() { scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d%d", A + i, B + i); A[i] += B[i]; } for (int i = 0; i < N; ++i) v[A[i]][B[i]] += 1; for (int i = 2000; i >= 0; --i) { for (int j = 2000; j >= 0; --j) { v[i][j] = ((j > 0 ? v[i + 1][j]) + (i > 0 ? v[i][j + 1] : 0)) % MOD; } } for (int i = 0; i < N; ++i) { for (int j = 0; j <= 2000; ++j) u[A[i] + j][B[i]] += v[j][0]; for (int j = 0; j <= 2000; ++j) u[A[i]][B[i] + j] += v[0][j]; } for (int i = 4000; i >= 0; --i) { for (int j = 4000; j >= 0; --j) { u[i][j] = (u[i + 1][j] + u[i][j + 1]) % MOD; } } printf("%lld\n", u[0][0]); return 0; }
a.cc: In function 'int main()': a.cc:35:56: error: expected ':' before ')' token 35 | v[i][j] = ((j > 0 ? v[i + 1][j]) + (i > 0 ? v[i][j + 1] : 0)) % MOD; | ^ | : a.cc:35:56: error: expected primary-expression before ')' token