submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s475147447 | p03676 | C++ | #include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
const int maxn=1e5+7;
const int mod=1e9+7;
int a[maxn];
int vis[maxn]={0};
long long f[maxn];
inline long long qpow(long long a,long long b){long long r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline long long inv(long long b){return qpow(b,mod-2);}
void init(){f[0] = 1;for (int i=1;i<=maxn;i++)f[i] = (f[i-1]*i) % mod;}
long long c(int x,int y){return f[x]*inv(f[y])%mod*inv(f[x-y])%mod;}
int main()
{
init();
int n;
cin>>n;
int p1,p2;
for (int i=1;i<=n+1;i++)
{
cin>>a[i];
if (vis[a[i]])
{
p1=vis[a[i]]-1;
p2=i;
}
vis[a[i]]=i;
}
for (int i=1;i<=n+1;i++)
{
long long ans=c(n+1,i)%mod;
if (n+1-p2+p1>=i-1) ans=(ans-c(n+1-p2+p1,i-1)+mod)%mod;
while (ans<0) ans=(ans+mod)%mod
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:44:48: error: expected ';' before 'cout'
44 | while (ans<0) ans=(ans+mod)%mod
| ^
| ;
45 | cout<<ans<<endl;
| ~~~~
|
s942517088 | p03676 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
const double EPS = 1e-10;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
struct Combination{
vector<long long> _fac,_finv,_inv;
const int m = MOD;
Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
_fac[0] = _fac[1] = 1;
_finv[0] = _finv[1] = 1;
_inv[1] = 1;
for(int i = 2; i <= sz; i++){
_fac[i] = _fac[i-1]*i%m;
_inv[i] = m-_inv[m%i]*(m/i)%m;
_finv[i] = _finv[i-1]*_inv[i]%m;
}
}
inline int fac(int n){return _fac[n];}
inline int inv(int n){return _inv[n];}
inline int finv(int n){return _finv[n];}
int comb(int n,int k){
if(n < k) return 0;
if(n < 0 || k < 0) return 0;
return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
}
};
int main(){
int n; cin >> n;
vector<int> a(n+1);
rep(i,n+1){
cin >> a[i];
a[i]--;
}
map<int,int> mp;
int two;
int l,r;
rep(i,n+1){
mp[a[i]]++;
if(mp[a[i]] == 2){
r = i;
two = a[i];
break;
}
}
rep(i,n+1){
if(a[i] == two){
l = i;
break;
}
}
Combination C(200000);
repr(i,1,n+2){
int ans = (C.comb(n+1,i)-C.comb(n-r+l,i-1))+MOD)%MOD;
cout << ans << endl;
}
}
| a.cc: In function 'int main()':
a.cc:86:56: error: expected ',' or ';' before ')' token
86 | int ans = (C.comb(n+1,i)-C.comb(n-r+l,i-1))+MOD)%MOD;
| ^
|
s489876704 | p03676 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
void Yes(){
cout<<"Yes"<<endl;
exit(0);
}
void No(){
cout<<"No"<<endl;
exit(0);
}
long long mod_inverse(long long x) {
long long ret = 1; long long n = mod - 2;
while (n) {
if (n & 1)ret = ret * x % mod;
x = x * x % mod; n >>= 1;
}
return ret;
}
ll fact[100100], inv_fact[100100];
ll comb(ll n, ll r) {
if(n < r || r < 0) return 0;
ll ret = fact[n] * inv_fact[n - r] % mod * inv_fact[r] % mod;
return rt;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n; cin >> n;
fact[0] = 1LL; inv_fact[0] = 1LL;
rep1(i, n) {
fact[i] = fact[i - 1] * i % mod;
inv_fact[i] = mod_inverse(fact[i]);
}
rep1(k, n + 1) {
ll ans = comb(n - 1, k) + comb(n - 1, k - 1) + comb(n - 1, k - 2);
ans %= mod;
cout << ans << endl;
}
return 0;
} | a.cc: In function 'll comb(ll, ll)':
a.cc:68:12: error: 'rt' was not declared in this scope; did you mean 'ret'?
68 | return rt;
| ^~
| ret
|
s426636539 | p03676 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int se[112345];
signed main(){
int n;
cin>>n;
vector<ll> avec;
rep(i,n){
ll a;cin>>a;avec.push_back(a);
}
COMinit();
int idx=0;
int idxb=0;
rep(i,n){
se[avec[i]]++;
if(se[avec[i]]>1)idx=i;
}
rep(i,n){
if(avec[idx]==avec[i]){
idxb=i;
break;
}
}
dump(idx);dump(idxb);
swap(idx,idxb);
int b=idxb-idx-1;int c=n-idxb;
ll ans=0LL;
rep(i,n+1){
int k=i+1;
if(i==0)cout<<n<<endl;
else cout<<(COM(n-1,k)+COM(idx+c,k-1)+2*(COM(idx+b+c,k-1)-COM(idx+c,k-1))%mod+COM(n-1,k-2)))%mod<<endl;
}
} | a.cc: In function 'int main()':
a.cc:75:100: error: expected ';' before ')' token
75 | else cout<<(COM(n-1,k)+COM(idx+c,k-1)+2*(COM(idx+b+c,k-1)-COM(idx+c,k-1))%mod+COM(n-1,k-2)))%mod<<endl;
| ^
| ;
|
s337705957 | p03676 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=1e5+100;
const LL MOD=1e9+7;
int n;
LL a[N];
int v[N];
LL fac[N],finv[N],inv[N];
void make()
{
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for(int i=2;i<100010;i++)
{
inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
fac[i]=fac[i-1]* i%MOD;
finv[i]=finv[i-1]*inv[i]%MOD;
}
}
LL C(int x,int y)
{
if(x<y) return 0;
return fac[x]*(finv[y]*finv[x-y]%MOD)%MOD;
}
int main ()
{
cin>>n;
for(int i = 1; i <= n + 1; ++i){
cin >> a[i];
v[a[i]]++;
}
LL pos1,pos2;
for(int i = 1; i <= n + 1; ++i){
if(v[a[i]] == 2 && !pos1){
pos1 = i;
}
else if(v[a[i]] == 2) {
pos2 = i;
}
}
LL ans;
make();
for (i=0;i<=n;i++)
{
ans=C(n+1,i+1);
ans-=C(n-pos2+pos1,i);
if (ans<0) ans+=MOD;
printf("%d\n",ans);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:49:14: error: 'i' was not declared in this scope
49 | for (i=0;i<=n;i++)
| ^
|
s001573301 | p03676 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=1e5+100;
const LL MOD=1e9+7;
int n;
LL a[N];
int v[N];
LL fac[N],finv[N],inv[N];
void make()
{
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for(int i=2;i<100010;i++)
{
inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
fac[i]=fac[i-1]* i%MOD;
finv[i]=finv[i-1]*inv[i]%MOD;
}
}
LL C(int x,int y)
{
if(x<y) return 0;
return fac[x]*(finv[y]*finv[x-y]%MOD)%MOD;
}
int main ()
{
cin>>n;
for(int i = 1; i <= n + 1; ++i){
cin >> a[i];
v[a[i]]++;
}
LL pos1,pos2;
for(int i = 1; i <= n + 1; ++i){
if(v[a[i]] == 2 && !pos1){
pos1 = i;
}
else if(v[a[i]] == 2) {
pos2 = i;
}
}
LL ans;
make();
for (i=0;i<=n;i++)
{
ans=C(n+1,i+1);
ans-=C(n-pos2+pos1,i);
if (ans<0) ans+=MOD;
printf("%d\n",ans);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:49:14: error: 'i' was not declared in this scope
49 | for (i=0;i<=n;i++)
| ^
|
s219328232 | p03676 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
int maxn;
int vis[100005];
LL fac[100005]={1,1};
LL opp[100005]={1,1};
LL fi[100005]={1,1};
void init()
{
for(int i=2; i<=100000; ++i)
{
fac[i] = fac[i-1]*i%mod;
opp[i] = (mod-mod/i)*opp[mod%i]%mod;
fi[i] = fi[i-1]*opp[i]%mod;
}
}
LL c(LL n, LL m)
{
return fac[n]*op_fa[n-m]%mod*op_fa[m]%mod;
}
int main()
{
init();
int n,dist;
scanf("%d",&n);
for(int i=1;i<=n+1;i++)
{
int temp;
scanf("%d",&temp);
if(mak[temp])
dist = mak[temp] + n - i;
mak[temp] = i;
}
long long ans;
for(int i=1;i<=n+1;i++)
{
ans = c((long long)(n+1), (long long)(i))%mod;
if(dist>=i-1)
{
ans= (ans - c((long long)dist, (long long)(i-1)) + mod)%mod;
}
printf("%lld\n",ans);
}
return 0;
} | a.cc: In function 'LL c(LL, LL)':
a.cc:21:19: error: 'op_fa' was not declared in this scope
21 | return fac[n]*op_fa[n-m]%mod*op_fa[m]%mod;
| ^~~~~
a.cc: In function 'int main()':
a.cc:32:20: error: 'mak' was not declared in this scope
32 | if(mak[temp])
| ^~~
a.cc:34:17: error: 'mak' was not declared in this scope
34 | mak[temp] = i;
| ^~~
|
s678212634 | p03676 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
using namespace std;
//typedef long long ll;
long long po(long a, long b){
if(b==0){
return 1;
}
long long z = po(a,b/2);
z = mod(z*z);
if(b%2!=0){
z = mod(a*z);
}
return z;
}
//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=100010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
inv[1]=1;
for(int i=2;i<=SIZE;i++){
inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
}
kai[0]=invkai[0]=1;
for(int i=1;i<=SIZE;i++){
kai[i]=(kai[i-1]*i)%MOD;
invkai[i]=(invkai[i-1]*inv[i])%MOD;
}
}
long long comb(long long a, long long b){
if(b<0 || a<b){
return 0;
}
return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}
int main(){
invinit();
int n;
cin>>n;
int a[n];
map<int> mp;
int fi=-1,si=-1;
REP(i,n){
cin>>a[i];
mp[a[i]]++;
if(mp[a[i]]==2){
si=i;
}
}
REP(i,n){
if(a[i]==a[si]){
fi=i;
break;
}
}
long long ans;
long long sur=0;
REPP(k,n+1){
ans = comb(n+1,k);
REP(i,k){
if(i<=fi && k-1-i<=n-1-si){
sur += mod(comb(fi,i)*comb(n-1-si,k-1-i));
}
}
ans = mod(ans - sur);
cout<<ans<<endl;
sur = 0;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:10: error: wrong number of template arguments (1, should be at least 2)
58 | map<int> mp;
| ^
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:62:7: error: invalid types 'int[int]' for array subscript
62 | mp[a[i]]++;
| ^
a.cc:63:10: error: invalid types 'int[int]' for array subscript
63 | if(mp[a[i]]==2){
| ^
|
s037865441 | p03676 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
using namespace std;
//typedef long long ll;
long long po(long a, long b){
if(b==0){
return 1;
}
long long z = po(a,b/2);
z = mod(z*z);
if(b%2!=0){
z = mod(a*z);
}
return z;
}
//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=100010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
inv[1]=1;
for(int i=2;i<=SIZE;i++){
inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
}
kai[0]=invkai[0]=1;
for(int i=1;i<=SIZE;i++){
kai[i]=(kai[i-1]*i)%MOD;
invkai[i]=(invkai[i-1]*inv[i])%MOD;
}
}
long long comb(long long a, long long b){
if(b<0 || a<b){
return 0;
}
return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}
int main(){
invinit();
int n;
cin>>n;
int a[n];
map<int> mp;
int fi=-1,si=-1;
REP(i,n){
cin>>a[i];
mp[a[i]++];
if(mp[a[i]]==2){
si=i;
}
}
REP(i,n){
if(a[i]==a[si]){
fi=i;
break;
}
}
long long ans;
long long sur=0;
REPP(k,n+1){
ans = comb(n+1,k);
REP(i,k){
if(i<=fi && k-1-i<=n-1-si){
sur += mod(comb(fi,i)*comb(n-1-si,k-1-i));
}
}
ans = mod(ans - sur);
cout<<ans<<endl;
sur = 0;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:10: error: wrong number of template arguments (1, should be at least 2)
58 | map<int> mp;
| ^
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:62:7: error: invalid types 'int[int]' for array subscript
62 | mp[a[i]++];
| ^
a.cc:63:10: error: invalid types 'int[int]' for array subscript
63 | if(mp[a[i]]==2){
| ^
|
s324542152 | p03676 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
//using namespace std;
//typedef long long ll;
long long po(long a, long b){
if(b==0){
return 1;
}
long long z = po(a,b/2);
z = mod(z*z);
if(b%2!=0){
z = mod(a*z);
}
return z;
}
//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=100010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
inv[1]=1;
for(int i=2;i<=SIZE;i++){
inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
}
kai[0]=invkai[0]=1;
for(int i=1;i<=SIZE;i++){
kai[i]=(kai[i-1]*i)%MOD;
invkai[i]=(invkai[i-1]*inv[i])%MOD;
}
}
long long comb(long long a, long long b){
if(b<0 || a<b){
return 0;
}
return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}
int main(){
invinit();
int n;
cin>>n;
int a[n];
map<int> mp;
int fi=-1,si=-1;
REP(i,n){
cin>>a[i];
mp[a[i]++];
if(mp[a[i]]==2){
si=i;
}
}
REP(i,n){
if(a[i]==a[si]){
fi=i;
break;
}
}
long long ans;
long long sur=0;
REPP(k,n+1){
ans = comb(n+1,k);
REP(i,k){
if(i<=fi && k-1-i<=n-1-si){
sur += mod(comb(fi,i)*comb(n-1-si,k-1-i));
}
}
ans = mod(ans - sur);
cout<<ans<<endl;
sur = 0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:56:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
56 | cin>>n;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:58:3: error: 'map' was not declared in this scope
58 | map<int> mp;
| ^~~
a.cc:58:3: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_map.h:102:11: note: 'std::map'
102 | class map
| ^~~
/usr/include/c++/14/map:89:13: note: 'std::pmr::map'
89 | using map
| ^~~
a.cc:58:7: error: expected primary-expression before 'int'
58 | map<int> mp;
| ^~~
a.cc:62:5: error: 'mp' was not declared in this scope
62 | mp[a[i]++];
| ^~
a.cc:83:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
83 | cout<<ans<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:83:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
83 | cout<<ans<<endl;
| ^~~~
| std::endl
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:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s063972709 | p03676 | C++ | N = int(input())
L = [-1] * N
a = [int(i)-1 for i in input().split()]
for i in range(N+1):
if L[a[i]] == -1:
L[a[i]] = i
else:
x1, x2 = (min(L[a[i]], i), max(L[a[i]], i))
A = x1
B = x2-x1-1
C = N-x2
def power(a, b):
if b == 0:
return 1
elif b == 1:
return a % 1000000007
elif b % 2 == 0:
return (power(a, b//2) ** 2) % 1000000007
else:
return (power(a, b//2) ** 2 * a) % 1000000007
def divide(a, b):
return (a * power(b, 1000000005)) % 1000000007
#階乗の逆元を求める
fac_lim = N
fac = [None]*(fac_lim+1)
fac[0] = 1
for i in range(fac_lim):
fac[i+1] = fac[i] * (i+1)
fac[i+1] = fac[i + 1] % 1000000007
fac_inv = [None]*(fac_lim+1)
fac_inv[fac_lim] = power(fac[fac_lim], 1000000005)
for i in range(fac_lim, 0, -1):
fac_inv[i-1] = (fac_inv[i] * i) % 1000000007
def conv(a, b):
if a >= b:
return (fac[a] * fac_inv[a-b] * fac_inv[b]) % 1000000007
else:
return 0
N1_conv = [0]*(N+2)
AC_conv = [0]*(N+2)
for i in range(N+2):
N1_conv[i] = conv(N-1, i)
for i in range(N+2):
AC_conv[i] = conv(A+C, i)
for K in range(1, N+2):
ans = 0
ans += N1_conv[K]
if K>0:
ans += AC_conv[K-1]
ans += 2 * N1_conv[K-1]
ans -= 2 * AC_conv[K-1]
if K>1:
ans += N1_conv[K-2]
ans %= 1000000007
print(ans) | a.cc:27:2: error: invalid preprocessing directive #\U0000968e\U00004e57\U0000306e\U00009006\U00005143\U00003092\U00006c42\U00003081\U0000308b
27 | #階乗の逆元を求める
| ^~~~~~~~~~~~~~~~~~
a.cc:1:1: error: 'N' does not name a type
1 | N = int(input())
| ^
|
s908233350 | p03676 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384
template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }
//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
class compare {
public:
bool operator()(tuple<int, int> a, tuple<int, int> b) {
return (get<1>(a) < get<1>(b));
}
};
vl fact(100002), finv(100002);
ll modpw(ll x, ll k) {
ll res = 1;
while (k != 0) {
if (k & 1) res = res*x % MOD;
x = x*x % MOD;
k = k >> 1;
}
return res;
}
ll comb(ll n, ll k) {
if (n == 0 && k == 0)return 1;
if (n < k || n < 0)return 0;
return fact[n] * finv[n - k] % MOD * finv[k] % MOD;;
}
int main() {
//cin.tie(0);
//ios::sync_with_stdio(false);
ll n, d, fi = -1, se = 0;
cin >> n;
vl v(n), b(n + 1);
fact[0] = 1;
finv[0] = 1;
rep (i,100001) {
fact[i + 1] = (fact[i] * (i + 1)) % MOD;
finv[i + 1] = modpw(fact[i + 1], MOD-2);
}
rep(i, n+1) {
cin >> v[i];
b[v[i]]++;
if (b[v[i]] == 2)d = v[i];
}
rep(i, n+1) {
if (v[i] == d) {
if (fi == -1)fi = i + 1;
else se = i + 1;
}
}
rep(i, n + 1) {
ll ans;
ans = comb(n+1,i+1);
if (i >= 0 && i <= tmp)ans = (ans + MOD - comb(tmp, i)) % MOD;
printf("%lld\n", ans);
}
}
| a.cc: In function 'int main()':
a.cc:87:36: error: 'tmp' was not declared in this scope; did you mean 'tm'?
87 | if (i >= 0 && i <= tmp)ans = (ans + MOD - comb(tmp, i)) % MOD;
| ^~~
| tm
|
s479652897 | p03676 | C++ | #include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;
// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;
// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;
// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
// ARC077
int fact[MAX_N];
int ifact[MAX_N];
int power(int x, int n) {
int res = 1LL;
while (n > 0) {
if (n & 1) (res *= x) %= MOD;
(x *= x) %= MOD;
n >>= 1;
}
return res % MOD;
}
int inv(int x) {
return power(x, MOD - 2);
}
int nCr(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (r > n / 2) r = n - r;
return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}
signed main() {
INIT;
fact[0] = ifact[0] = 1;
FOR(i, 1, MAX_N) {
(fact[i] = fact[i - 1] * i) %= MOD;
ifact[i] = inv(fact[i]);
}
VAR(int, n);
VEC(int, a, n + 1);
vector< int > memo(MAX_N, -1);
int lb = 0, ub = 0;
REP(i, n + 1) {
if (memo[a[i]] > -1) {
lb = memo[a[i]];
ub = i;
break;
}
memo[a[i]] = i;
}
int ans = 0;
REP(i, n + 1) {
(ans = nCr(n + 1, i + 1) + ) %= MOD;
(ans = ans - nCr(n - ub + lb, i) + MOD) %= MOD;
(ans += MOD) %= MOD;
OUT(ans)BR;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:83:44: error: expected primary-expression before ')' token
83 | (ans = nCr(n + 1, i + 1) + ) %= MOD;
| ^
|
s247513147 | p03676 | C++ | int mod_pow(int a, int n, int mod){
int ret = 1;
while(n){
if(n & 1) ret = (long long)ret * a % mod;
a = (long long)a * a % mod;
n >>= 1;
}
return ret;
}
template<int mod>
class NTT {
public:
int get_mod() const { return mod; }
void _ntt(vector<int>& a, int sign){
const int n = (int)a.size();
const int g = 3; //g is primitive root of mod
int h = mod_pow(g, (mod - 1) / n, mod); // h^n = 1
if(sign == -1) h = mod_pow(h, mod-2, mod); //h = h^-1 % mod
int s,x,m,j,k;
int i = 0;
for(j = 1; j < n - 1; ++j){
for(k = n >> 1; k >(i ^= k); k >>= 1);
if (j < i) swap(a[i], a[j]);
}
for (m = 1; m < n; m *= 2){
const int m2 = 2 * m;
const int base = mod_pow(h, n / m2, mod);
int w = 1;
for(x = 0; x < m; x++){
for(s = x; s < n; s += m2){
unsigned int u = a[s];
unsigned int d = (long long)a[s + m] * w % mod;
a[s] = (u + d) % mod;
a[s + m] = (u + mod - d) % mod;
}
w = (long long)w * base % mod;
}
}
}
void ntt(vector<int>& input){
_ntt(input, 1);
}
void intt(vector<int>& input){
_ntt(input, -1);
const int n_inv = mod_pow((int)(input.size()), mod-2, mod);
for(auto& x : input) x = (long long)x * n_inv % mod;
}
void _convolution(const vector<int>& a, const vector<int>& b, vector<int>& _a, vector<int>& _b){
int ntt_size = 1;
while (ntt_size < (int)(a.size()) + (int)(b.size())) ntt_size *= 2;
_a = a, _b = b;
_a.resize(ntt_size); _b.resize(ntt_size);
ntt(_a), ntt(_b);
for(int i = 0; i < ntt_size; i++){
_a[i] = (long long)_a[i] * _b[i] % mod;
}
intt(_a);
}
};
typedef NTT<167772161> NTT_1;
typedef NTT<469762049> NTT_2;
typedef NTT<1224736769> NTT_3;
void convolution(const vector<int>& a, const vector<int>& b, vector<int>& res){
NTT_1 ntt1; NTT_2 ntt2; NTT_3 ntt3;
vector<int> x,_x,y,_y,z,_z;
ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
const int m1 = ntt1.get_mod(), m2 = ntt2.get_mod(), m3 = ntt3.get_mod();
const int m1_inv_m2 = mod_pow(m1, m2-2, m2);
const int m12_inv_m3 = mod_pow((long long)m1 * m2 % m3, m3-2, m3);
const int m12_mod = (long long)m1 * m2 % MOD;
res.resize((int)(x.size()));
for(int i = 0; i < (int)(x.size()); i++){
int v1 = ((long long)y[i] + m2 - x[i]) * m1_inv_m2 % m2;
int v2 = ((long long)z[i] + m3 - (x[i] + (long long)m1 * v1) % m3) * m12_inv_m3 % m3;
res[i] = (x[i] + (long long)m1 * v1 + (long long)m12_mod * v2) % MOD;
}
} | a.cc:15:19: error: 'vector' has not been declared
15 | void _ntt(vector<int>& a, int sign){
| ^~~~~~
a.cc:15:25: error: expected ',' or '...' before '<' token
15 | void _ntt(vector<int>& a, int sign){
| ^
a.cc:41:18: error: 'vector' has not been declared
41 | void ntt(vector<int>& input){
| ^~~~~~
a.cc:41:24: error: expected ',' or '...' before '<' token
41 | void ntt(vector<int>& input){
| ^
a.cc:44:19: error: 'vector' has not been declared
44 | void intt(vector<int>& input){
| ^~~~~~
a.cc:44:25: error: expected ',' or '...' before '<' token
44 | void intt(vector<int>& input){
| ^
a.cc:49:33: error: 'vector' does not name a type
49 | void _convolution(const vector<int>& a, const vector<int>& b, vector<int>& _a, vector<int>& _b){
| ^~~~~~
a.cc:49:39: error: expected ',' or '...' before '<' token
49 | void _convolution(const vector<int>& a, const vector<int>& b, vector<int>& _a, vector<int>& _b){
| ^
a.cc: In member function 'void NTT<mod>::_ntt(int)':
a.cc:16:36: error: 'a' was not declared in this scope
16 | const int n = (int)a.size();
| ^
a.cc:19:20: error: 'sign' was not declared in this scope; did you mean 'signed'?
19 | if(sign == -1) h = mod_pow(h, mod-2, mod); //h = h^-1 % mod
| ^~~~
| signed
a.cc:24:36: error: there are no arguments to 'swap' that depend on a template parameter, so a declaration of 'swap' must be available [-fpermissive]
24 | if (j < i) swap(a[i], a[j]);
| ^~~~
a.cc:24:36: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In member function 'void NTT<mod>::ntt(int)':
a.cc:42:22: error: 'input' was not declared in this scope; did you mean 'int'?
42 | _ntt(input, 1);
| ^~~~~
| int
a.cc: In member function 'void NTT<mod>::intt(int)':
a.cc:45:22: error: 'input' was not declared in this scope; did you mean 'int'?
45 | _ntt(input, -1);
| ^~~~~
| int
a.cc: In member function 'void NTT<mod>::_convolution(int)':
a.cc:51:41: error: 'a' was not declared in this scope
51 | while (ntt_size < (int)(a.size()) + (int)(b.size())) ntt_size *= 2;
| ^
a.cc:51:59: error: 'b' was not declared in this scope
51 | while (ntt_size < (int)(a.size()) + (int)(b.size())) ntt_size *= 2;
| ^
a.cc:52:9: error: '_a' was not declared in this scope
52 | _a = a, _b = b;
| ^~
a.cc:52:14: error: 'a' was not declared in this scope
52 | _a = a, _b = b;
| ^
a.cc:52:17: error: '_b' was not declared in this scope
52 | _a = a, _b = b;
| ^~
a.cc:52:22: error: 'b' was not declared in this scope
52 | _a = a, _b = b;
| ^
a.cc: At global scope:
a.cc:66:24: error: 'vector' does not name a type
66 | void convolution(const vector<int>& a, const vector<int>& b, vector<int>& res){
| ^~~~~~
a.cc:66:30: error: expected ',' or '...' before '<' token
66 | void convolution(const vector<int>& a, const vector<int>& b, vector<int>& res){
| ^
a.cc: In function 'void convolution(int)':
a.cc:68:5: error: 'vector' was not declared in this scope
68 | vector<int> x,_x,y,_y,z,_z;
| ^~~~~~
a.cc:68:12: error: expected primary-expression before 'int'
68 | vector<int> x,_x,y,_y,z,_z;
| ^~~
a.cc:69:27: error: 'a' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^
a.cc:69:30: error: 'b' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^
a.cc:69:33: error: 'x' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^
a.cc:69:36: error: '_x' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^~
a.cc:69:65: error: 'y' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^
a.cc:69:68: error: '_y' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^~
a.cc:69:97: error: 'z' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^
a.cc:69:100: error: '_z' was not declared in this scope
69 | ntt1._convolution(a, b, x, _x), ntt2._convolution(a, b, y, _y), ntt3._convolution(a, b, z, _z);
| ^~
a.cc:73:50: error: 'MOD' was not declared in this scope
73 | const int m12_mod = (long long)m1 * m2 % MOD;
| ^~~
a.cc:74:9: error: 'res' was not declared in this scope
74 | res.resize((int)(x.size()));
| ^~~
|
s347343150 | p03676 | C++ | #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
using namespace std;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;
const int MAX_N = 100005;
int inv[MAX_N],fac[MAX_N],finv[MAX_N];
void make()
{
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for(int i=2;i<MAX_N;i++){
inv[i] = MOD - (ll)inv[MOD%i] * (MOD/i) % MOD;
fac[i] = (ll)fac[i-1] * i % MOD;
finv[i] = (ll)finv[i-1] * inv[i] % MOD;
}
}
int comb(int a,int b)
{
if(a<b || b<0){
return 0;
}
return (ll)fac[a] * ((ll)finv[b] * finv[a-b] % MOD) % MOD;
}
int add(int x,int y)
{
return (x+y)%MOD;
}
int sub(int x,int y)
{
return (x+MOD-y)%MOD;
}
int mul(int x,int y)
{
return (ll)x*y%MOD;
}
int mod_pow(int a, int n, int mod){
int ret = 1;
while(n){
if(n & 1) ret = (long long)ret * a % mod;
a = (long long)a * a % mod;
n >>= 1;
}
return ret;
}
template<int mod, int primitive_root>
class NTT {
public:
int get_mod() const { return mod; }
void _ntt(vector<int>& a, int sign){
const int n = (int)a.size();
const int g = 3; //g is primitive root of mod
int h = mod_pow(g, (mod - 1) / n, mod); // h^n = 1
if(sign == -1) h = mod_pow(h, mod-2, mod); //h = h^-1 % mod
int s,x,m,j,k;
int i = 0;
for(j = 1; j < n - 1; ++j){
for(k = n >> 1; k >(i ^= k); k >>= 1);
if (j < i) swap(a[i], a[j]);
}
for (m = 1; m < n; m *= 2){
const int m2 = 2 * m;
const int base = mod_pow(h, n / m2, mod);
int w = 1;
for(x = 0; x < m; x++){
for(s = x; s < n; s += m2){
unsigned int u = a[s];
unsigned int d = (long long)a[s + m] * w % mod;
a[s] = (u + d) % mod;
a[s + m] = (u + mod - d) % mod;
}
w = (long long)w * base % mod;
}
}
}
void ntt(vector<int>& input){
_ntt(input, 1);
}
void intt(vector<int>& input){
_ntt(input, -1);
const int n_inv = mod_pow((int)(input.size()), mod-2, mod);
for(auto& x : input) x = (long long)x * n_inv % mod;
}
void convolution(const vector<int>& a, const vector<int>& b, vector<int>& _a, vector<int>& _b){
int ntt_size = 1;
while (ntt_size < (int)(a.size()) + (int)(b.size())) ntt_size *= 2;
_a = a, _b = b;
_a.resize(ntt_size); _b.resize(ntt_size);
ntt(_a), ntt(_b);
for(int i = 0; i < ntt_size; i++){
_a[i] = (long long)_a[i] * _b[i] % mod;
}
intt(_a);
}
};
typedef NTT<167772161, 3> NTT_1;
typedef NTT<469762049, 3> NTT_2;
typedef NTT<1224736769, 3> NTT_3;
void convolution(const vector<int>& a, const vector<int>& b, vector<int>& res){
NTT_1 ntt1; NTT_2 ntt2; NTT_3 ntt3;
vector<int> x,_x,y,_y,z,_z;
ntt1.convolution(a, b, x, _x), ntt2.convolution(a, b, y, _y), ntt3.convolution(a, b, z, _z);
const int m1 = ntt1.get_mod(), m2 = ntt2.get_mod(), m3 = ntt3.get_mod();
const int m1_inv_m2 = mod_pow(m1, m2-2, m2);
const int m12_inv_m3 = mod_pow((long long)m1 * m2 % m3, m3-2, m3);
const int m12_mod = (long long)m1 * m2 % MOD;
res.resize((int)(x.size()));
for(int i = 0; i < (int)(x.size()); i++){
int v1 = ((long long)y[i] + m2 - x[i]) * m1_inv_m2 % m2;
int v2 = ((long long)z[i] + m3 - (x[i] + (long long)m1 * v1) % m3) * m12_inv_m3 % m3;
res[i] = (x[i] + (long long)m1 * v1 + (long long)m12_mod * v2) % MOD;
}
}
int cnt[MAX_N];
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vi a(n);
rep(i,n+1){
cin >> a[i];
cnt[a[i]]++;
}
int l = -1, r = -1;
rep(i,n+1){
if(cnt[a[i]] == 2){
if(l < 0){
l = i;
}else{
r = i;
}
}
}
make();
vi x(l+1),y(n-r+1),res;
rep(i,len(x)){
x[i] = comb(l,i);
}
rep(i,len(y)){
y[i] = comb(n-r,i);
}
fast_int32mod_convolution(x,y,res);
srep(k,1,n+2){
int ans = add(add(comb(n-1,k),mul(2,comb(n-1,k-1))),comb(n-1,k-2));
cout << sub(ans,(k-1<len(res))?(res[k-1]):(0)) << "\n";
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:189:5: error: 'fast_int32mod_convolution' was not declared in this scope
189 | fast_int32mod_convolution(x,y,res);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
|
s081361372 | p03676 | Java | import java.io._
import java.util.StringTokenizer
import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag
object Main {
val MOD = 1000000007
val out = new PrintWriter(System.out)
def solve(): Unit = {
val sc = new InputReader(System.in)
val N = sc.nextInt() + 1
val A = map(N)(_ => sc.nextInt())
val dbl = {
val cnt = Array.ofDim[Int](N)
rep(N)(i => cnt(A(i)) += 1)
cnt.indexOf(2)
}
val L = A.indexOf(dbl)
val R = N - A.lastIndexOf(dbl) - 1
def powMod(x: Int, n: Int, m: Int): Int = {
def step(x: Long, n: Int, stack: Long): Long = {
n match {
case 0 => stack
case _ => step(x * x % m, n / 2, if (n % 2 == 1) stack * x % m else stack)
}
}
step(x, n, 1).toInt
}
val F = Array.ofDim[Long](N + 1)
F(0) = 1
rep(N) { i =>
F(i + 1) = F(i) * (i + 1) % MOD
}
val I = Array.ofDim[Long](F.length)
I(N) = powMod(F(N).toInt, MOD - 2, MOD)
// x! = x(x-1)!
// x!I(x!) ≡ (x-1)!I((x-1)!)
// I((x-1)!) ≡ I(x!) * x MODがでかいので(x-1)!はMODと素
rep_r(N) { i =>
I(i) = I(i + 1) * (i + 1) % MOD
}
def comb(n: Int, k: Int): Long = {
if (n < k) 0
else F(n) * I(n - k) % MOD * I(k) % MOD
}
rep(N, 1) { k =>
val ans = (MOD + comb(N, k) - comb(L + R, k - 1)) % MOD
out.println(ans)
}
}
def main(args: Array[String]): Unit = {
solve()
out.flush()
}
class InputReader(val stream: InputStream) {
private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
private var tokenizer: StringTokenizer = _
def next(): String = {
while (tokenizer == null || !tokenizer.hasMoreTokens)
tokenizer = new StringTokenizer(reader.readLine)
tokenizer.nextToken
}
def nextInt(): Int = next().toInt
def nextLong(): Long = next().toLong
def nextChar(): Char = next().charAt(0)
}
def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
var i = offset
val N = n + offset
while(i < N) { f(i); i += 1 }
}
def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
var i = n - 1 + offset
while(i >= offset) { f(i); i -= 1 }
}
def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
val res = Array.ofDim[A](n)
rep(n)(i => res(i) = f(i))
res
}
implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
// todo Orderingだとboxing発生するので自作Orderを用意したい
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
if (as.nonEmpty) Some(as.maxBy(f)) else None
}
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
val map = mutable.Map.empty[K, ArrayBuffer[A]]
rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
map
}
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
var sum = num.zero
rep(as.length)(i => sum = num.plus(sum, f(as(i))))
sum
}
def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
limit(f, ixRange)(cmp.lt)
}
def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
limit(f, ixRange)(cmp.gt)
}
private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
var limA = as(ixRange.head)
var limB = f(limA)
for (i <- ixRange.tail) {
val a = as(i)
val b = f(a)
if (cmp(b, limB)) {
limA = a
limB = b
}
}
(limA, limB)
}
}
implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
}
}
}
| Main.java:1: error: as of release 9, '_' is a keyword, and may not be used as an identifier
import java.io._
^
Main.java:1: error: ';' expected
import java.io._
^
Main.java:2: error: ';' expected
import java.util.StringTokenizer
^
Main.java:4: error: ';' expected
import scala.collection.mutable
^
Main.java:5: error: ';' expected
import scala.util.Sorting
^
Main.java:6: error: <identifier> expected
import math.{abs, max, min}
^
Main.java:7: error: <identifier> expected
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
^
Main.java:8: error: ';' expected
import scala.reflect.ClassTag
^
Main.java:68: error: '{' expected
class InputReader(val stream: InputStream) {
^
Main.java:69: error: ';' expected
private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
^
Main.java:70: error: 'var' is not allowed here
private var tokenizer: StringTokenizer = _
^
Main.java:70: error: ';' expected
private var tokenizer: StringTokenizer = _
^
Main.java:70: error: <identifier> expected
private var tokenizer: StringTokenizer = _
^
Main.java:70: error: as of release 9, '_' is a keyword, and may not be used as an identifier
private var tokenizer: StringTokenizer = _
^
Main.java:70: error: ';' expected
private var tokenizer: StringTokenizer = _
^
Main.java:72: error: ';' expected
def next(): String = {
^
Main.java:74: error: ';' expected
tokenizer = new StringTokenizer(reader.readLine)
^
Main.java:75: error: not a statement
tokenizer.nextToken
^
Main.java:75: error: ';' expected
tokenizer.nextToken
^
Main.java:78: error: ';' expected
def nextInt(): Int = next().toInt
^
Main.java:82: error: unnamed classes are a preview feature and are disabled by default.
def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
^
(use --enable-preview to enable unnamed classes)
Main.java:82: error: <identifier> expected
def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
^
Main.java:83: error: ';' expected
var i = offset
^
Main.java:84: error: ';' expected
val N = n + offset
^
Main.java:85: error: ';' expected
while(i < N) { f(i); i += 1 }
^
Main.java:87: error: <identifier> expected
def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
^
Main.java:88: error: ';' expected
var i = n - 1 + offset
^
Main.java:89: error: ';' expected
while(i >= offset) { f(i); i -= 1 }
^
Main.java:92: error: class, interface, enum, or record expected
def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
^
Main.java:92: error: class, interface, enum, or record expected
def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
^
Main.java:98: error: '{' expected
implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
^
Main.java:100: error: ']' expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: <identifier> expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: <identifier> expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: <identifier> expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: <identifier> expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: illegal start of expression
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: ';' expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: ']' expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:100: error: ';' expected
def maxByOpt[B: Ordering](f: A => B): Option[A] = {
^
Main.java:101: error: ';' expected
if (as.nonEmpty) Some(as.maxBy(f)) else None
^
Main.java:101: error: not a statement
if (as.nonEmpty) Some(as.maxBy(f)) else None
^
Main.java:101: error: ';' expected
if (as.nonEmpty) Some(as.maxBy(f)) else None
^
Main.java:104: error: ']' expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: <identifier> expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: <identifier> expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: <identifier> expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: illegal start of expression
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: ';' expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: ']' expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: ']' expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:104: error: <identifier> expected
def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
^
Main.java:105: error: ']' expected
val map = mutable.Map.empty[K, ArrayBuffer[A]]
^
Main.java:105: error: ']' expected
val map = mutable.Map.empty[K, ArrayBuffer[A]]
^
Main.java:105: error: ';' expected
val map = mutable.Map.empty[K, ArrayBuffer[A]]
^
Main.java:106: error: ';' expected
rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
^
Main.java:106: error: illegal start of expression
rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
^
Main.java:106: error: ';' expected
rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
^
Main.java:107: error: not a statement
map
^
Main.java:107: error: ';' expected
map
^
Main.java:110: error: ']' expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: illegal start of expression
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: ';' expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: ';' expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: ']' expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: ';' expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:110: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:111: error: '}' expected
var sum = num.zero
^
Main.java:111: error: <identifier> expected
var sum = num.zero
^
Main.java:111: error: ';' expected
var sum = num.zero
^
Main.java:112: error: invalid method declaration; return type required
rep(as.length)(i => sum = num.plus(sum, f(as(i))))
^
Main.java:112: error: <identifier> expected
rep(as.length)(i => sum = num.plus(sum, f(as(i))))
^
Main.java:112: error: ';' expected
rep(as.length)(i => sum = num.plus(sum, f(as(i))))
^
Main.java:116: error: class, interface, enum, or record expected
def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
^
Main.java:140: error: '{' expected
implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
^
Main.java:141: error: ']' expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:141: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:141: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:141: error: <identifier> expected
def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
^
Main.java:141: error: illegal start of expression
def sumBy[B](f: A => B)(implicit num: |
s798918706 | p03676 | C++ | // D.
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
typedef long long LL;
static const LL MOD = 1000000007;
static const size_t MAX_N = 100001;
struct modll {
long long x;
modll() { }
modll(long long _x) : x(_x) { }
operator int() const { return (int)x; }
modll operator+(const modll &r) { return (x + r.x) % MOD; }
modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
modll operator*(const modll &r) { return (x * r.x) % MOD; }
modll operator*(int r) { return (x * r) % MOD; }
modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
static modll modinv(int a) { return modpow(a, MOD - 2); }
static modll modpow(int a, int b) {
modll x = a, r = 1;
for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
return r;
}
};
modll combination(LL n, LL r) {
static modll fact[MAX_N + 1], inv[MAX_N + 1];
if (!fact[0]) {
fact[0] = 1;
for (int i = 1; i <= MAX_N; ++i) {
fact[i] = fact[i - 1] * i;
}
inv[MAX_N] = modll::modinv(fact[MAX_N]);
for (int i = MAX_N; i >= 1; --i) {
inv[i - 1] = inv[i] * i;
}
}
return n >= r ? fact[n] * inv[r] * inv[n - r] : 0LL;
}
int main(int argc, char *argv[]) {
int n, d;
cin >> n;
vector<int> pos(n + 1, -1);
for (int i = 0; i <= n; ++i) {
int a;
cin >> a;
if (pos[a] >= 0) {
d = i - pos[a];
}
pos[a] = i;
}
for (int i = 1; i <= n + 1; ++i) {
modll ans = combination(n + 1, i) - combination(n - d, i - 1);
cout << ans << endl;
}
return 0;
}
| a.cc: In function 'modll combination(LL, LL)':
a.cc:47:23: error: operands to '?:' have different types 'modll' and 'long long int'
47 | return n >= r ? fact[n] * inv[r] * inv[n - r] : 0LL;
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:47:23: note: and each type can be converted to the other
|
s783608435 | p03676 | C++ | // D.
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
typedef long long LL;
static const LL MOD = 1000000007;
static const size_t MAX_N = 100001;
struct modll {
long long x;
modll() { }
modll(long long _x) : x(_x) { }
operator int() const { return (int)x; }
modll operator+(const modll &r) { return (x + r.x) % MOD; }
modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
modll operator*(const modll &r) { return (x * r.x) % MOD; }
modll operator*(int r) { return (x * r) % MOD; }
modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
static modll modinv(int a) { return modpow(a, MOD - 2); }
static modll modpow(int a, int b) {
modll x = a, r = 1;
for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
return r;
}
};
modll combination(LL n, LL r) {
static modll fact[MAX_N + 1], inv[MAX_N + 1];
if (!fact[0]) {
fact[0] = 1;
for (int i = 1; i <= MAX_N; ++i) {
fact[i] = fact[i - 1] * i;
}
inv[MAX_N] = modll::modinv(fact[MAX_N]);
for (int i = MAX_N; i >= 1; --i) {
inv[i - 1] = inv[i] * i;
}
}
return n >= r ? fact[n] * inv[r] * inv[n - r] : 0;
}
int main(int argc, char *argv[]) {
int n, d;
cin >> n;
vector<int> pos(n + 1, -1);
for (int i = 0; i <= n; ++i) {
int a;
cin >> a;
if (pos[a] >= 0) {
d = i - pos[a];
}
pos[a] = i;
}
for (int i = 1; i <= n + 1; ++i) {
modll ans = combination(n + 1, i) - combination(n - d, i - 1);
cout << ans << endl;
}
return 0;
}
| a.cc: In function 'modll combination(LL, LL)':
a.cc:47:23: error: operands to '?:' have different types 'modll' and 'int'
47 | return n >= r ? fact[n] * inv[r] * inv[n - r] : 0;
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:47:23: note: and each type can be converted to the other
|
s067762852 | p03676 | C++ | #include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int fac[maxn];
int inv[maxn];
int a[maxn];
int n;
int add;
int fin[maxn];
int id;
long long pow_mod(long long x)
{
long long res = 1;
long long n=mod-2;
while (n)
{
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
int C(int x, int y)
{
return ((1ll * fac[x] * inv[y] )% mod * inv[x - y] )% mod;
}
void init()
{
fac[0] = 1;
fac[1] = 1;
for (int i = 2; i <= n; i ++)
fac[i] = (1ll * fac[i - 1] * i) % mod;
inv[n] = pow_mod(fac[n]);
for (int i = n - 1; i >= 0; i --)
inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
}
void findd()
{
for (int i = 1; i <= n; i ++)
{
if (fin[a[i]]!=0)
{
add = i;
id = a[i];
return
}
fin[a[i]] = i;
}
}
int main()
{
scanf("%d",&n);
n++;
for (int i = 1; i <= n; i ++)
scanf("%d",&a[i]);
init();
findd();
int com=n-add+fin[id]-1;
for (int i = 1; i <= n; ++i)
{
int ans = C(n, i);
if (i - 1 <= com)
ans -= C(com, i - 1);
printf("%d\n",(ans+mod)%mod);
}
return 0;
}
| a.cc: In function 'void findd()':
a.cc:47:9: error: expected primary-expression before '}' token
47 | }
| ^
a.cc:46:19: error: expected ';' before '}' token
46 | return
| ^
| ;
47 | }
| ~
|
s702187616 | p03676 | C++ | #include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll int i=a;i<=b;++i)
#define rep(i,n) for(ll int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=1e9+7;
int INF=1e6;
ll int MAX_N=1e18;
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
ll int inv[1000000]={};
void calc_inv(ll int n){
inv[1]=1;
rep2(i,2,n-1){
inv[i]=(MOD-(MOD/i)*inv[MOD%i]%MOD);
}
}
main(){
ll int n;
calc_inv(110000);
cin>>n;
ll int a[110000];
int count[110000]={};
ll int left,right;
rep(i,n+1){
scanf("%lld",&a[i]);
if(!count[a[i]]) count[a[i]]=1;
else right=i;
}
rep(i,n+1){
if(a[i]==a[right]){ left=i; break;}
}
ll int comb1[110000],comb3[110000];
comb1[0]=1,comb2[0]=1,comb3[0]=1;
rep2(i,1,n+1){
comb1[i]=comb1[i-1]*(n+1-i)%MOD;
comb1[i]=comb1[i]*inv[i]%MOD;
comb3[i]=comb3[i-1]*(n-right+left+1-i)%MOD;
comb3[i]=comb3[i]*inv[i]%MOD;
if(i>n-right+left) comb3[i]=0;
}
rep2(i,1,n+1){
ll int ans=0;
ans+=comb1[i];
ans+=comb1[i-1];
ans-=comb3[i-1];
ans%=MOD;
cout<<ans<<endl;
}
return 0;
} | a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:38:16: error: 'comb2' was not declared in this scope; did you mean 'comb3'?
38 | comb1[0]=1,comb2[0]=1,comb3[0]=1;
| ^~~~~
| comb3
|
s243101849 | p03676 | C++ | #include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll int i=a;i<=b;++i)
#define rep(i,n) for(ll int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=1e9+7;
int INF=1e6;
ll int MAX_N=1e18;
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
ll int inv[1000000]={};
void calc_inv(ll int n){
inv[1]=1;
rep2(i,2,n-1){
inv[i]=(MOD-(MOD/i)*inv[MOD%i]%MOD);
}
}
main(){
ll int n;
calc_inv(110000);
cin>>n;
ll int a[110000];
int count[110000]={};
ll int left,right;
rep(i,n+1){
scanf("%d",&a[i]);
if(!count[a[i]]) count[a[i]]=1;
else right=i;
}
rep(i,n+1){
if(a[i]==a[right]){ left=i; break;}
}
ll int comb1[110000],comb3[110000];
comb1[0]=1,comb2[0]=1,comb3[0]=1;
rep2(i,1,n+1){
comb1[i]=comb1[i-1]*(n+1-i)%MOD;
comb1[i]=comb1[i]*inv[i]%MOD;
comb3[i]=comb3[i-1]*(n-right+left+1-i)%MOD;
comb3[i]=comb3[i]*inv[i]%MOD;
if(i>n-right+left) comb3[i]=0;
}
rep2(i,1,n+1){
ll int ans=0;
ans+=comb1[i];
ans+=comb1[i-1];
ans-=comb3[i-1];
ans%=MOD;
cout<<ans<<endl;
}
return 0;
} | a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:38:16: error: 'comb2' was not declared in this scope; did you mean 'comb3'?
38 | comb1[0]=1,comb2[0]=1,comb3[0]=1;
| ^~~~~
| comb3
|
s199579986 | p03676 | Java |
import java.io.*;
import java.util.*;
class Main{
public static void main(String[] args){
solve();
}
public static void solve(){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n+1];
long etc = (long)Math.pow(10, 9) + 7;
for(int i=0;i<n+1;i++){
a[i] = sc.nextInt();
}
ArrayList<Point> list = new ArrayList<Point>();
int[] judge = new int[n+1];
long[] num = new long[n+2];
num[0] = 1;
long[] dnum = new long[n+2];
dnum[0] = 1;
Arrays.fill(judge, -1);
int left = 0;
int right = 0;
for(int i=0;i<n+1;i++){
if(judge[a[i]] == -1){
judge[a[i]] = i;
}
else{
right = n-i;
left = judge[a[i]];
}
}
for(int i=1;i<=n+1;i++){
num[i] = num[i-1]*(n+2-(long)i);
//num[i] %= etc;
dnum[i] = dnum[i-1]*(long)i;
num[i] /= (long)i;
//dnum[i] %= etc;
}
long[] xnum = new long[right+left+1];
long[] dxnum = new long[right+left+1];
xnum[0] = 1;
dxnum[0] = 1;
for(int i=1;i<=left+right;i++){
xnum[i] = xnum[i-1]*((long)(right+left)+1-(long)i);
dxnum[i] = dxnum[i-1]*(long)i;
xnum[i] /= (long)i;
//xnum[i] %= etc;
//dxnum[i] %= etc;
}
for(int i=1;i<=n;i++){
long count = 1;
if(i==1){
count = n;
}
else{
int y = n+1;
count = num[i]/*dnum[i]*/;
if(right+left+1>=i){
count -= xnum[i-1]/*dxnum[i-1]*/;
}
}
System.out.println(count%etc);
}
System.out.println(1);
}
}
| Main.java:18: error: cannot find symbol
ArrayList<Point> list = new ArrayList<Point>();
^
symbol: class Point
location: class Main
Main.java:18: error: cannot find symbol
ArrayList<Point> list = new ArrayList<Point>();
^
symbol: class Point
location: class Main
2 errors
|
s958684515 | p03676 | C++ | #include <iostream>
int main(void) {
# dummy comment
cout << 0 << endl;
} | a.cc:4:7: error: invalid preprocessing directive #dummy
4 | # dummy comment
| ^~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
5 | cout << 0 << endl;
| ^~~~
| std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:5:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
5 | cout << 0 << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s958409684 | p03676 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int div = 1000000007;
long long fac[100002];
void calc_fac(){
fac[0] = 1;
for(int i = 1; i < 100002; i++){
fac[i] = fac[i-1] * i % div;
}
}
long long pow(long long a, long long n){
if(n==1){return a%div;}
long long half_pow = pow(a, n/2);
if(n%2){
return half_pow * half_pow % div *a %div;
}else{
return half_pow * half_pow % div;
}
}
long long inv(long long a){
return pow(a, div-2);
}
long long c(int n, int k){
return fac[n]*inv(fac[k]) %div *inv(fac[n-k])%div;
}
int main(){
int n, a[100001], cnt_a[100001] = {0}, dup;
cin >> n;
for(int i = 0; i < n+1; i++){
scanf("%d", a+i);
cnt_a[a[i]]++;
if(cnt_a[a[i]] > 1){
dup = a[i];
}
}
int p, q, cnt=0;
for(int i = 0; i < n+1; i++){
if(a[i] == dup && cnt == 0){
p = i;
cnt++;
}else if(a[i] == dup && cnt > 0){
q = i;
}
}
calc_fac();
/*
cout << c(3, 2) << endl;
cout << c(4, 2) << endl;
cout << c(10, 2) << endl;
cout << fac[10] << " " << (fac[10]*inv(2)%div)*inv(8)%div <<endl;
cout<<inv(2) << " " << inv(8) << endl;
*/
//cout << c(2, 2) << endl;
for(int k = 1; k <= n+1; k++){
int ans = c(n+1, k);
if((p+n-q) >= 0 && (k-1) >= 0 && p+n-q >= k-1){
ans -= c(p+n-q, k-1);
}
//cout << p << " " << q << endl;
ans %= div;
cout << ans << endl;
}
return 0;
} | a.cc:5:5: error: 'int div' redeclared as different kind of entity
5 | int div = 1000000007;
| ^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdlib.h:992:14: note: previous declaration 'div_t div(int, int)'
992 | extern div_t div (int __numer, int __denom)
| ^~~
a.cc: In function 'void calc_fac()':
a.cc:11:31: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator%'
11 | fac[i] = fac[i-1] * i % div;
| ~~~~~~~~~~~~~^~~~~
a.cc: In function 'long long int pow(long long int, long long int)':
a.cc:16:22: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator%'
16 | if(n==1){return a%div;}
| ~^~~~
a.cc:19:36: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator%'
19 | return half_pow * half_pow % div *a %div;
| ~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:21:36: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator%'
21 | return half_pow * half_pow % div;
| ~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc: In function 'long long int inv(long long int)':
a.cc:26:22: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator-'
26 | return pow(a, div-2);
| ~~~^~
a.cc: In function 'long long int c(int, int)':
a.cc:30:31: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator%'
30 | return fac[n]*inv(fac[k]) %div *inv(fac[n-k])%div;
| ~~~~~~~~~~~~~~~~~~~^~~~
a.cc: In function 'int main()':
a.cc:71:16: error: overloaded function with no contextual type information
71 | ans %= div;
| ^~~
|
s553554956 | p03676 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 200+10
ll N,A[100010];
ll F[100010];
ll l,r;
ll ans;
ll Fact[100010];
ll Com[100010];
void FC(ll x){
Fact[0]=Com[0]=1;
ll temp=1;
EREP(i,x){
temp=temp*i%MOD;
Fact[i]=temp;
Com[i]=LP(temp,MOD-2);
}
}
ll MC(ll x,ll y){
if(y==0)return 1;
if(x<y)return 0;
return (Fact[x]*((Com[y]*Com[x-y])%MOD))%MOD;
}
int main(){
std::ios_base::sync_with_stdio(false);
cin>>N;
REP(i,100010)F[i]=-1;
REP(i,N+1){
cin>>A[i];
if(F[A[i]]==-1)F[A[i]]=i;
else{
l=F[A[i]];
r=i;
}
}
FC(N+2);
REP(i,N+1){
DEB(MC(N+1,i+1))DEB(MC(l+N-r,i))END
cout<<MC(N+1,i+1)-MC(l+N-r,i)<<endl;
}
return 0;
}
| a.cc: In function 'void FC(ll)':
a.cc:54:16: error: 'LP' was not declared in this scope; did you mean 'P'?
54 | Com[i]=LP(temp,MOD-2);
| ^~
| P
|
s115509504 | p03676 | C++ | #include <iostream>
using namespace std;
#define MOD 1000000007
long long mod(long long x, int n) {
//cout << x << endl;
if(n == 0) return 1;
long long ret = mod(x * x % MOD, n / 2);
if(n % 2) ret = ret * x % MOD;
return ret;
}
long long p(long long l, long long r) {
//cout << "mod: " << l * mod(r, MOD - 2) % MOD << endl;
if(r < 0) return 0;
if(r == 0) return 1;
return l * mod(r, MOD - 2) % MOD;
}
int main() {
int n, idx;
int a[100001], used[100001] = {0};
cin >> n;
for(int i = 0; i <= n; i++) {
cin >> a[i];
used[a[i]]++;
}
int *pp = max_element(used, used + n + 1);
for(idx = n; a[idx] != pp - used; idx--);
long long del = n - idx + 1;
long long l = n + 1, r = 1;
for(int i = 1; i <= n + 1; i++) {
//cout << l << "C" << r << " - " << del << "C" << i - 1 << " = " << p(l, r) << " - " << delp(del, i - 1) << endl;
cout << (p(l, r) - (del < i - 1 ? 0 : p(del, i - 1)) + MOD) % MOD << endl;
l = l * (n + 1 - i) % MOD;
r = r * (i + 1) % MOD;
}
}
| a.cc: In function 'int main()':
a.cc:31:15: error: 'max_element' was not declared in this scope
31 | int *pp = max_element(used, used + n + 1);
| ^~~~~~~~~~~
|
s123435986 | p03676 | C++ | #include<cstdio>
#include<algorithm>
using namespace std;
#define N 300005
#define Mo 1000000007
int i,jm,n,p,k,inv[N],fac[N];
int C(int x,int y)
{
if (x<y) return 0;
return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
int power(int x,int y)
{
}
int main()
{
scanf("%d",&n);
fac[0]=1;
for (i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo;
for (i=0;i<N;++i) inv[i]=power(fac[i],Mo-2);
for (i=1;i<=n+1;++i)
{
scanf("%d",&k);
if (vis[k]) len=k-vis[k]+1;
vis[k]=i;
}
for (i=1;i<=n+1;++i) printf("%d\n",(C(n+1,i)-C(n+1-len,i-1)+Mo)%Mo);
} | a.cc: In function 'int power(int, int)':
a.cc:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
20 | }
| ^
a.cc: In function 'int main()':
a.cc:31:24: error: 'vis' was not declared in this scope
31 | if (vis[k]) len=k-vis[k]+1;
| ^~~
a.cc:31:32: error: 'len' was not declared in this scope
31 | if (vis[k]) len=k-vis[k]+1;
| ^~~
a.cc:32:20: error: 'vis' was not declared in this scope
32 | vis[k]=i;
| ^~~
a.cc:34:63: error: 'len' was not declared in this scope
34 | for (i=1;i<=n+1;++i) printf("%d\n",(C(n+1,i)-C(n+1-len,i-1)+Mo)%Mo);
| ^~~
|
s454720070 | p03676 | C++ | #include<cstdio>
#include<algorithm>
using namespace std;
#define N 300005
#define Mo 1000000007
int i,jm,n,p,k,inv[N],fac[N];
int C(int x,int y)
{
if (x<y) return 0;
return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
int main()
{
scanf("%d",&n);
fac[0]=1;
for (i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo;
for (i=0;i<N;++i) inv[i]=power(fac[i],Mo-2);
for (i=1;i<=n+1;++i)
{
scanf("%d",&k);
if (vis[k]) len=k-vis[k]+1;
vis[k]=i;
}
for (i=1;i<=n+1;++i) printf("%d\n",(C(n+1,i)-C(n+1-len,i-1)+Mo)%Mo);
} | a.cc: In function 'int main()':
a.cc:22:37: error: 'power' was not declared in this scope
22 | for (i=0;i<N;++i) inv[i]=power(fac[i],Mo-2);
| ^~~~~
a.cc:26:24: error: 'vis' was not declared in this scope
26 | if (vis[k]) len=k-vis[k]+1;
| ^~~
a.cc:26:32: error: 'len' was not declared in this scope
26 | if (vis[k]) len=k-vis[k]+1;
| ^~~
a.cc:27:20: error: 'vis' was not declared in this scope
27 | vis[k]=i;
| ^~~
a.cc:29:63: error: 'len' was not declared in this scope
29 | for (i=1;i<=n+1;++i) printf("%d\n",(C(n+1,i)-C(n+1-len,i-1)+Mo)%Mo);
| ^~~
|
s426110632 | p03676 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
bool b[100001] = { false };
int num[100001];
LL fact[100001];
LL inv[100001];
LL inv_fact[100001];
LL mod_pow(LL x, LL a) {
if (a == 0) return 1;
if (a % 2 == 0) {
LL ret = mod_pow(x, a / 2);
return (ret*ret) % MOD;
}
else {
return (x*mod_pow(x, a - 1)) % MOD;
}
}
LL comb(LL n, LL k) {
if (n < k) return 0;
LL ans = (fact[n] * inv_fact[k]) % MOD;
ans = (ans*inv_fact[n - k]) % MOD;
return ans;
}
int main() {
int n, dup[2];
cin >> n;
for (int i = 0; i <= n; i++) {
int a;
cin >> a;
num[i] = a;
if (!b[a - 1])b[a - 1] = true;
else {
dup[1] = i;
break;
}
}
for (int i = 0; i<dup[1]; i++) {
if (num[i] == num[dup[1]])dup[0] = i;
}
fact[0] = 1;
inv_fact[0] = 1;
for (int i = 1; i<n + 1; i++) {
inv[i] = mod_pow(i, MOD - 2);
fact[i] = (fact[i - 1] * i) % MOD;
inv_fact[i] = (inv_fact[i - 1] * inv[i]) % MOD;
}
int cen = dup[1] - dup[0] - 1;
cout << n << endl;
for (int i = 2; i <= n + 1; i++) {
LL sum = 0;
sum = (sum + comb(n - 1, i)) % MOD;
sum = (sum + comb(n - 1, i - 2)) % MOD;
sum = (sum + 2 * comb(n - 1, i - 1)) % MOD;
sum = (sum - comb(n - cen - 1, i - 1) + MOD) % MOD;
cout << sum << endl;
} | a.cc: In function 'int main()':
a.cc:60:10: error: expected '}' at end of input
60 | }
| ^
a.cc:28:12: note: to match this '{'
28 | int main() {
| ^
|
s581266122 | p03676 | C++ |
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll mo=1000000007;
ll combi(ll N_, ll C_) {
const int NUM_=400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
if (fact[0]==0) {
inv[1]=fact[0]=factr[0]=1;
for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
}
if(C_<0 || C_>N_) return 0;
return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int N;
int A[101010];
int num[101010];
vector<int> V;
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
FOR(i,N+1) {
cin>>A[i];
num[A[i]]++;
}
FOR(i,N+1) if(num[A[i]]==2) V.push_back(i);
int a=V[0];
int b=V[1]-V[0]-1;
int c=N-V[1];
for(i=1;i<=N+1;i++) {
if(i==1) {
cout<<N<<endl;
continue;
}
ll ret=0;
// D=0
ret += combi(N-1,i);
// D=1
ret += combi(a+c,i-1);
ret += (combi(a+c+b,i-1)-combi(a+c,i-1))*2;
// D=2
ret += combi(N-1,i-2);
cout<<(ret%mo+mo)%mo<<endl;
}
} | a.cc: In function 'void solve()':
a.cc:30:9: error: 'FOR' was not declared in this scope
30 | FOR(i,N+1) {
| ^~~
|
s255222609 | p03676 | C++ | ll mo=1000000007;
ll combi(ll N_, ll C_) {
const int NUM_=400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
if (fact[0]==0) {
inv[1]=fact[0]=factr[0]=1;
for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
}
if(C_<0 || C_>N_) return 0;
return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int N;
int A[101010];
int num[101010];
vector<int> V;
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
FOR(i,N+1) {
cin>>A[i];
num[A[i]]++;
}
FOR(i,N+1) if(num[A[i]]==2) V.push_back(i);
int a=V[0];
int b=V[1]-V[0]-1;
int c=N-V[1];
for(i=1;i<=N+1;i++) {
if(i==1) {
cout<<N<<endl;
continue;
}
ll ret=0;
// D=0
ret += combi(N-1,i);
// D=1
ret += combi(a+c,i-1);
ret += (combi(a+c+b,i-1)-combi(a+c,i-1))*2;
// D=2
ret += combi(N-1,i-2);
cout<<(ret%mo+mo)%mo<<endl;
}
} | a.cc:1:1: error: 'll' does not name a type
1 | ll mo=1000000007;
| ^~
a.cc:2:1: error: 'll' does not name a type
2 | ll combi(ll N_, ll C_) {
| ^~
a.cc:17:1: error: 'vector' does not name a type
17 | vector<int> V;
| ^~~~~~
a.cc: In function 'void solve()':
a.cc:19:28: error: 'string' was not declared in this scope
19 | int i,j,k,l,r,x,y; string s;
| ^~~~~~
a.cc:21:9: error: 'cin' was not declared in this scope
21 | cin>>N;
| ^~~
a.cc:22:9: error: 'FOR' was not declared in this scope
22 | FOR(i,N+1) {
| ^~~
a.cc:27:15: error: 'V' was not declared in this scope
27 | int a=V[0];
| ^
a.cc:32:25: error: 'cout' was not declared in this scope
32 | cout<<N<<endl;
| ^~~~
a.cc:32:34: error: 'endl' was not declared in this scope
32 | cout<<N<<endl;
| ^~~~
a.cc:35:17: error: 'll' was not declared in this scope; did you mean 'l'?
35 | ll ret=0;
| ^~
| l
a.cc:37:17: error: 'ret' was not declared in this scope
37 | ret += combi(N-1,i);
| ^~~
a.cc:37:24: error: 'combi' was not declared in this scope
37 | ret += combi(N-1,i);
| ^~~~~
a.cc:45:17: error: 'cout' was not declared in this scope
45 | cout<<(ret%mo+mo)%mo<<endl;
| ^~~~
a.cc:45:28: error: 'mo' was not declared in this scope
45 | cout<<(ret%mo+mo)%mo<<endl;
| ^~
a.cc:45:39: error: 'endl' was not declared in this scope
45 | cout<<(ret%mo+mo)%mo<<endl;
| ^~~~
|
s021843981 | p03676 | C++ | #include<iostream>
#include<cmath>
using namespace std;
long long n;
long long a[100010];
int use[100010];
long long jl[100000];
int check;
long long mod=1000000007;
long long C(int a,int b)
{
b=min(b,n+1-b);
if(a==n+1&&jl[b]!=0) return jl[b];
long long x=1;
if(a==n)
{
x=jl[b-1]*(a-b+1)/(b)%mod;
jl[b]=x;
return x;
}
for(int i=0;i<b;i++)
x=x*(a-i)/(i+1);
//if(b==16) cout<<a-i<<" "<<i+1<<" "<<x<<" ";
x%=mod;
if(a==n+1&&jl[b]==0) jl[a]=x;
//cout<<mul(a,b)<<" "<<mul(b,b)<<" ";
return x;
}
int main()
{
scanf("%d",&n);
int num,same1=0,same2=0;
for(int i=1;i<=n+1;i++)
{
scanf("%d",&a[i]);
if(use[a[i]]!=0)same1=use[a[i]],same2=i;
use[a[i]]=i;
}
//cout<<same1<<' '<<same2<<' ';
check=same1+n-same2;
//cout<<check;
jl[1]=n+1;
for(int i=1;i<=n+1;i++)
{
long long x=C(n+1,i);
long long y=0;
if(i<=check+1) y=C(check,i-1);
//cout<<x<<y<<" ";
printf("%lld\n",x-y);
}
}
/*
32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9
*/ | a.cc: In function 'long long int C(int, int)':
a.cc:15:14: error: no matching function for call to 'min(int&, long long int)'
15 | b=min(b,n+1-b);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:15:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
15 | b=min(b,n+1-b);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
|
s257484398 | p03676 | C++ | #include <cassert>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
using ll = long long;
using namespace std;
ll powmod(ll x, ll y, ll p) { // O(log y)
assert (0 <= x and x < p);
assert (0 <= y);
ll z = 1;
for (ll i = 1; i <= y; i <<= 1) {
if (y & i) z = z * x % p;
x = x * x % p;
}
return z;
}
ll inv(ll x, ll p) { // p must be a prime, O(log p)
assert ((x % p + p) % p != 0);
return powmod(x, p-2, p);
}
constexpr int mod = 1e9+7;
int fact(int n) {
static vector<int> memo(1, 1);
if (memo.size() <= n) {
int l = memo.size();
memo.resize(n+1);
repeat_from (i, l, n+1) memo[i] = memo[i-1] *(ll) i % mod;
}
return memo[n];
}
int choose(int n, int r) { // O(n) at first time, otherwise O(\log n)
if (n < r) return 0;
r = min(r, n - r);
return fact(n) *(ll) inv(fact(n-r), mod) % mod *(ll) inv(fact(r), mod) % mod;
}
int main() {
// input
int n; scanf("%d", &n);
vector<int> a(n + 1); repeat (i, n + 1) scanf("%d", &a[i]);
// solve
int dup[2]; {
vector<int> used(n, -1);
repeat (i, n + 1) {
if (used[a[i] - 1] != -1) {
dup[0] = used[a[i] - 1];
dup[1] = i;
break;
}
used[a[i] - 1] = i;
}
}
int l = dup[0];
int m = dup[1] - (dup[0] + 1);
int r = n + 1 - (dup[1] + 1);
repeat_from (k, 1, n + 2) {
ll result = choose(n + 1, k) - choose(l + r, k - 1);
retult = (result + mod) % mod;
printf("%lld\n", result);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:60:9: error: 'retult' was not declared in this scope; did you mean 'result'?
60 | retult = (result + mod) % mod;
| ^~~~~~
| result
|
s717660736 | p03676 | C++ | #include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 binpow(u64 n, u64 x, u64 mod)
{
u64 tgt = 1;
u64 dig = n;
while (x > 0) {
if (x%2) {
tgt = (tgt * dig) % mod;
}
dig = (dig * dig) % mod;
x /= 2;
}
return tgt;
}
class Comb
{
public:
u64 mod; // 10e9+7
vector< u64 > fact;
vector< u64 > factf;
void init(u64 size, u64 imod) {
mod = imod;
fact.resize(size);
factf.resize(size);
fact[0] = 1;
factf[0] = 1;
for (u64 i = 1; i <= size; ++i) {
fact[i] = fact[i-1]*i%mod;
factf[i] = binpow(fact[i], mod-2, mod);
}
}
u64 comb(u64 n, u64 k) {
if (n<k) return 0;
if (n<0) return 0;
if (k==0) return 1;
return (fact[n] * factf[k] * factf[n-k]) % mod;
}
};
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
Comb comb;
comb.init(1e5, 1e9+7);
int n;
cin >> n;
l64 a[n+1];
for (u64 i = 1; i <= n; ++i) {
a[i] = -1;
}
u64 a1, a2;
for (u64 i = 0; i <= n; ++i) {
u64 ai;
cin >> ai;
if (a[ai] >= 0) {
a1 = a[ai];
a2 = i;
break;
}
a[ai] = i;
}
for (u64 i = 1; i <= n+1; ++i) {
u64 up = comb.comb(n+1, i);
u64 dn = comb.comb(n-1-(a2-a1-1), i-1);
if (up>dn) return (up-dn)%(1e9+7);
else return (up+1e9+7-dn)%(1e9+7);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:72:30: error: invalid operands of types 'u64' {aka 'long long unsigned int'} and 'double' to binary 'operator%'
72 | if (up>dn) return (up-dn)%(1e9+7);
| ~~~~~~~^~~~~~~~
| | |
| | double
| u64 {aka long long unsigned int}
a.cc:73:30: error: invalid operands of types 'double' and 'double' to binary 'operator%'
73 | else return (up+1e9+7-dn)%(1e9+7);
| ~~~~~~~~~~~~~^~~~~~~~
| | |
| double double
|
s698976436 | p03676 | C++ | //15:53-17:33
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
ll modpow(ll x,ll n)
{
ll res=1;
while(n>0)
{
if(n&1) res=res*x%mod;
x=x*x%mod;
n>>=1;
}
return res;
}
ll F[300005],R[300005];
void make(){
F[0] = 1;
for(int i=1;i<300005;i++) F[i] = F[i-1]*i%mod;
for(int i=0;i<300005;i++) R[i] = modpow(F[i],mod-2);
}
int n,a[100005],pos[100005];
ll C(int a,int b){ return F[a]*R[b]%mod*R[a-b]%mod;}
int main(){
cin >> n;
int x;a
for(int i=1;i<=n+1;i++){
cin >> a[i];
if(!pos[a[i]]) pos[a[i]] = i;
else{
x = i+1-pos[a[i]];
}
}
make();
for(int k=1;k<=n+1;k++){
ll ret = 0;
//0
if(n-1 >= k) ret += C(n-1,k);
//1
if(n-1 >= k-1) ret += 2LL*C(n-1,k-1);
if(n+1-x >= k-1) ret -= C(n+1-x,k-1);
//2
if(n-1 >= k-2 && k != 1) ret += C(n-1,k-2);
ret = (ret%mod+mod)%mod;
cout << ret << endl;
}
} | a.cc: In function 'int main()':
a.cc:42:16: error: expected ';' before 'for'
42 | int x;a
| ^
| ;
43 | for(int i=1;i<=n+1;i++){
| ~~~
a.cc:43:21: error: 'i' was not declared in this scope
43 | for(int i=1;i<=n+1;i++){
| ^
|
s107431879 | p03676 | C++ | //15:53-17:33
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
ll modpow(ll x,ll n)
{
ll res=1;
while(n>0)
{
if(n&1) res=res*x%mod;
x=x*x%mod;
n>>=1;
}
return res;
}
ll F[300005],R[300005];
void make(){
F[0] = 1;
for(int i=1;i<300005;i++) F[i] = F[i-1]*i%mod;
for(int i=0;i<300005;i++) R[i] = modpow(F[i],mod-2);
}
int n,a[100005],pos[100005];
ll C(int a,int b){ return F[a]*R[b]%mod*R[a-b]%mod;}
int main(){
cin >> n;
int x;a
for(int i=1;i<=n+1;i++){
cin >> a[i];
if(!pos[a[i]]) pos[a[i]] = i;
else{
x = i+1-pos[a[i]];
}
}
make();
for(int k=1;k<=n+1;k++){
ll ret = 0;
//0
if(n-1 >= k) ret += C(n-1,k);
//1
if(n-1 >= k-1) ret += 2LL*C(n-1,k-1);
if(n+1-x >= k-1) ret -= C(n+1-x,k-1);
//2
if(n-1 >= k-2 && k != 1) ret += C(n-1,k-2);
ret = (ret%mod+mod)%mod;
cout << ret << endl;
}
} | a.cc: In function 'int main()':
a.cc:42:16: error: expected ';' before 'for'
42 | int x;a
| ^
| ;
43 | for(int i=1;i<=n+1;i++){
| ~~~
a.cc:43:21: error: 'i' was not declared in this scope
43 | for(int i=1;i<=n+1;i++){
| ^
|
s765699063 | p03676 | C++ | #include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define ll long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;
const LL MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;
int n;
LL id1,id2;
LL a[100048];
int v[100048];
int cnt[100048];
LL fac[100048],finv[100048],inv[100048];
void make()
{
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for(int i=2;i<100010;i++)
{
inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
fac[i]=fac[i-1]* i%MOD;
finv[i]=finv[i-1]*inv[i]%MOD;
}
}
ll C(int x,int y)
{
if(x<y) return 0;
return fac[x]*(finv[y]*finv[x-y]%MOD)%MOD;
}
int main ()
{
LL i;
cin>>n;
memset(cnt,0,sizeof(cnt));
for (i=1;i<=n+1;i++)
{
cin>>a[i];
cnt[a[i]]++;
}
p=p1=0;
for (i=1;i<=n+1;i++)
if (cnt[a[i]]==2)
if (p1==0) p1=i; else p=i;
memset(a, 0, sizeof(a));
memset(v, 0, sizeof(v));
for(ll i = 1; i <= n + 1; ++i){
cin >> a[i];
v[a[i]]++;
}
for(ll i = 1; i <= n + 1; ++i){
if(v[a[i]] == 2 && !id1){
id1 = i;
}
else if(v[a[i]] == 2) {
id2 = i;
}
}
LL ans;
make();
for (i=0;i<=n;i++)
{
ans=C(n+1,i+1);
ans-=C(n-p+p1,i);
if (ans<0) ans+=MOD;
printf("%d\n",ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:65:9: error: 'p' was not declared in this scope
65 | p=p1=0;
| ^
a.cc:65:11: error: 'p1' was not declared in this scope; did you mean 'y1'?
65 | p=p1=0;
| ^~
| y1
|
s134197012 | p03676 | C++ | #include <bits/stdc++.h>
#define ll long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
using namespace std;
const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
return x * f;
}
id[N];
ll jc[N], ny[N];
ll qpow(ll a, ll x)
{
if(x == 1) return a % mod;
ll now = (qpow(a, x / 2) % mod);
if(x % 2 == 1) return ((now * a % mod) * now % mod);
else return (now * now % mod);
}
ll C(int a, int b)
{
if(a < b) return 0;
return (((jc[a] * ny[b] % mod) * ny[a - b]) % mod);
}
int main()
{
jc[0] = 1;
jc[1] = 1;
for(int i = 2; i <= 1e5; i ++)
jc[i] = jc[i - 1] * i, jc[i] = jc[i] % mod;
ny[0] = 1;
ny[1] = 1;
for(int i = 2; i <= 1e5; i ++)
ny[i] = qpow(jc[i], mod - 2);
//for(int i = 1; i <= 10; i ++)
//cout << jc[i] << " " << ny[i] << endl;
int n = read();
memset(id, -1, sizeof(id));
int s, t;
for(int i = 0; i <= n; i ++)
{
int x = read();
x --;
if(id[x] == -1) id[x] = i;
else s = id[x], t = i;
}
//cout << s << " " << t << endl;
//cout << C(5, 3) << " ";
for(int i = 1; i <= n + 1; i ++)
{
ll ret = C(n + 1, i) % mod;
ret = ret - C(s + (n - t), i - 1);
ret %= mod;
if(ret < 0) ret += mod;
printf("%lld\n",ret);
}
return 0;
} | a.cc:22:10: error: 'id' does not name a type; did you mean 'void'?
22 | id[N];
| ^~
| void
a.cc: In function 'int main()':
a.cc:52:16: error: 'id' was not declared in this scope
52 | memset(id, -1, sizeof(id));
| ^~
|
s998200844 | p03676 | C++ | #include <bits/stdc++.h>
#define ll long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
return x * f;
}
int id[N];
ll jc[N], ny[N];
ll qpow(ll a, int x)
{
if(x == 1) return a;
ll now = qpow(a, x / 2);
if(x % 2 == 1) return now * now % mod * a % mod;
else return now * now % mod;
}
ll C(int a, int b)
{
if(a < b) return 0;
return (((jc[a] * ny[b] % mod) * ny[a - b]) % mod);
}
int main()
{
jc[0] = 1;
for(int i = 1; i <= 1e5; i ++)
jc[i] = jc[i - 1] * i, jc[i] = jc[i] % mod;
ny[0] = 1;
for(int i = 1; i <= 1e5; i ++)
ny[i] = qpow(jc[i], mod - 2);
//for(int i = 1; i <= 10; i ++)
// cout << jc[i] << " " << ny[i] << endl;
int n = read();
memset(id, -1, sizeof(id));
int s, t;
for(int i = 0; i <= n; i ++)
{
int a = read();
a --;
if(id[a] == -1) id[a] = i;
else
{
s = id[a];
t = i;
}
}
//cout << s << " " << t << endl;
//cout << C(5, 3) << " ";
for(int i = 1; i <= n + 1; i ++)
{
ll ret = C(n + 1, i), C(s + (n - t), i - 1);
if(ret < 0) ret += mod;
printf("%lld\n",ret);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:67:59: error: expression list treated as compound expression in initializer [-fpermissive]
67 | ll ret = C(n + 1, i), C(s + (n - t), i - 1);
| ^
|
s604891894 | p03676 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
ll mod_pow(ll x, ll n, ll mod) {
if (n == 0) return 1;
ll res = mod_pow(x * x % mod, n / 2, mod);
if (n & 1) res = res * x % mod;
return res;
}
vector<ll> fact, inv;
void fact_inv(int n, ll mod) {
fact.resize(n + 1);
inv.resize(n + 1);
fact[0] = 1;
FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
inv[n] = mod_pow(fact[n], mod - 2, mod);
for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}
ll ncr(ll n, ll r, ll mod) {
if (n < r || r < 0 || n < 0) return 0;
return fact[n] * inv[r] % mod * inv[n - r] % mod;
}
int n;
int a[112345];
bool done[112345];
int main() {
cin >> n;
REP(i, n + 1) scanf("%d", a + i);
int num = -1;
REP(i, n + 1) {
if (done[a[i]]) num = a[i];
done[a[i]] = true;
}
int l = -1, r = -1;
REP(i, n + 1) if (a[i] == num) {
if (l == -1) l = i;
else r = i;
}
fact_inv(112345, MOD);
FOR(k, 1, n + 2) {
ll ans = ncr(n + 1, k, MOD);
ll c = r - l - 1;
if (n - 1 - c >= k - 1) ans -= ncr(n - 1 - c, k - 1, MOD);.
ans = (ans + MOD) % MOD;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:72:75: error: expected primary-expression before '.' token
72 | if (n - 1 - c >= k - 1) ans -= ncr(n - 1 - c, k - 1, MOD);.
| ^
|
s810075112 | p03676 | C++ |
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
auto& in = std::cin;
auto& out = std::cout;
template<typename Arithmetic, typename Integral>
std::enable_if_t< std::is_unsigned<Integral>::value, Arithmetic>
ipow(Arithmetic bace, Integral n)
{
//繰り返し二条法
auto res = (Arithmetic)(1);
while (n > 0) {
if (n & 1) res *= bace;
bace *= bace;
n >>= 1;
}
return res;
}
constexpr bool is_prime(uint32_t N)
{
if (N <= 1) {
return false;
}
for (size_t i = 2; i*i <= N; ++i)
{
if (N%i == 0) {
return false;
}
}
return true;
}
template <uint64_t MOD> class mint_base;
//mint_base_base型用の累乗関数
template <uint64_t MOD> constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept;
//mod計算を自動で行う整数テンプレートクラス
template <uint64_t MOD_ = 1000000007>
class mint_base
{
public:
static constexpr auto MOD = MOD_;
static_assert(!(MOD <= 2), "MOD cannot be below 2.");
static_assert(MOD <= (0xFFFFFFFFFFFFFFFF / 2), "MOD is too big");//加算してオーバーフローしない
static_assert(MOD <= 0xFFFFFFFF, "MOD is too big");//乗算してオーバーフローしない
constexpr mint_base<MOD> operator+(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v += other;
}
constexpr mint_base<MOD> operator-(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v -= other;
}
constexpr mint_base<MOD> operator*(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v *= other;
}
constexpr auto operator/(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v /= other;
}
constexpr mint_base<MOD>& operator+=(const mint_base<MOD> &other) noexcept
{
a += other.a;
if (MOD <= a) { a -= MOD; };
return *this;
}
constexpr mint_base<MOD>& operator-=(const mint_base<MOD> &other) noexcept
{
if (a >= other.a) {
a -= other.a;
}
else {
a = (a + MOD) - other.a;
}
return *this;
}
constexpr mint_base<MOD>& operator*=(const mint_base<MOD> &other) noexcept
{
#if 1
a *= other.a;
a %= MOD;
#else
//MOD <= (MAXUINT64 / 2)条件下
uint64_t b = other.a, v = 0;
while (b > 0) {
if (b & 1) {
v += a;
if (v >= MOD)v -= MOD;
}
a += a;
if (MOD <= a)a -= MOD;
b >>= 1;
}
a = v;
#endif
return *this;
}
constexpr std::enable_if_t<is_prime(MOD), mint_base<MOD>&>
operator/=(const mint_base<MOD> &other) noexcept
{
return *this *= ~other;
}
constexpr mint_base<MOD> operator+()const noexcept { return *this; }
constexpr mint_base<MOD> operator-()const noexcept
{
return{ MOD - a, mod_value_tag{} };
}
constexpr mint_base<MOD>& operator++() noexcept
{
if (MOD <= ++a) { a = 0; };
return *this;
}
constexpr mint_base<MOD>& operator--() noexcept
{
if (a <= 0) { a = MOD; };
--a;
return *this;
}
constexpr mint_base<MOD> operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
constexpr mint_base<MOD> operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
constexpr mint_base<MOD> operator~()const noexcept
{
return ipow(*this, e_phi - 1);
}
constexpr mint_base<MOD>& operator=(const mint_base<MOD> &other) noexcept
{
a = other.a;
return *this;
}
constexpr explicit operator uint64_t()const noexcept
{
return a;
}
constexpr explicit operator unsigned()const noexcept
{
return (unsigned)a;
}
static constexpr uint64_t getmod() noexcept
{
return MOD;
}
constexpr mint_base(uint64_t a_) noexcept :a(a_ % MOD) {}
constexpr mint_base()noexcept : a(0) {}
struct mod_value_tag {};
constexpr mint_base(uint64_t a_, mod_value_tag) :a(a_) {}
private:
static constexpr uint64_t get_e_phi()noexcept {
//オイラー値の導出
uint64_t temp = MOD;
uint64_t m_ = MOD;
for (uint64_t i = 2; i * i <= m_; ++i)
{
if (m_ % i == 0)
{
temp = temp / i * (i - 1);
for (; m_ % i == 0; m_ /= i);
}
}
if (m_ != 1)temp = temp / m_ * (m_ - 1);
return temp;
}
static constexpr uint64_t e_phi = get_e_phi();//オイラー値
uint64_t a;
};
//mint_base型用の累乗関数
template<uint64_t MOD>constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept
{
mint_base<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint_baseの階乗計算
//O(x)時間が必要のため、fact_set関数を推奨する。
template<uint64_t MOD>constexpr mint_base<MOD> fact(mint_base<MOD> x)noexcept
{
mint_base<MOD> res(1);
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
}
return res;
}
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(x)時間が必要
template<uint64_t MOD>std::vector<mint_base<MOD>> fact_set(mint_base<MOD> x = mint_base<MOD>(-1))
{
mint_base<MOD> res(1);
std::vector<mint_base<MOD>> set((uint64_t)(x)+1);
set[0] = 1;
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
set[i] = res;
}
return res;
}
//mint_base型のstreamへの出力
template<uint64_t MOD> std::ostream& operator<<(std::ostream& os, mint_base<MOD> i)
{
os << (uint64_t)i;
return os;
}
//mint_base型のstreamからの入力
template<uint64_t MOD> std::istream& operator >> (std::istream& is, mint_base<MOD>& i)
{
uint64_t tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint_base<1000000007> mint;
namespace mint_literal {
constexpr mint operator""_mi(unsigned long long x)noexcept {
return mint(x);
}
}
using namespace mint_literal;
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(N) //O(1)
template<uint64_t X, uint64_t MOD = mint::MOD>
/*constexpr*/ std::array<mint_base<MOD>, X + 1> fact_set_c()
{
mint_base<MOD> res(1);
std::array<mint_base<MOD>, X + 1> set;
set[0] = 1;
for (uint64_t i = 1; i <= X; ++i)
{
res *= i;
set[i] = res;
}
return set;
}
auto fact = fact_set_c<100001>();
template<typename RET = uint64_t, typename Integral>
RET combination(Integral all, Integral get)
{
assert(all >= get);
get = std::min(all - get, get);
#if 1
//時間計算量O(1)
//(これは罠で、割り算でlogMODくらい使いそう)
return fact[all] / (fact[get] * fact[all - get]);
#else
//時間計算量O(1)
//空間計算量、初期化時間計算量O(N^2)
constexpr int32_t ALL_MAX = 10'000;
static std::vector<RET> DP_comb[ALL_MAX + 1];
if (!DP_comb[all].empty())
{
return DP_comb[all][get];
}
if (DP_comb[0].empty())
{
DP_comb[0].resize(1);
DP_comb[0][0] = (RET)1;
DP_comb[1].resize(1);
DP_comb[1][0] = (RET)1;
}
for (int32_t i = 2; i <= all; i++)
{
if (DP_comb[i].empty())
{
int32_t size = i / 2 + 1;
DP_comb[i].resize(size);
DP_comb[i][0] = (RET)1;
for (int32_t j = 1; j < size - 1; j++)
{
DP_comb[i][j] = DP_comb[i - 1][j - 1] + DP_comb[i - 1][j];
}
DP_comb[i][size - 1] = DP_comb[i - 1][size - 2] + DP_comb[i - 1][(i & 1) ? (size - 1) : (size - 2)];
}
}
return DP_comb[all][get];
#else
//時間計算量O(get + logMOD)
RET ret = (RET)1;
for (Integral i = 1; i <= get; ++i)
{
ret *= all + 1 - i;
ret /= i;
}
return ret;
#endif
}
int32_t N;
int32_t exist[100000] = {};
int32_t dob_f = -1;
int32_t dob_s = -1;
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in.tie(nullptr);
out.tie(nullptr);
in >> N;
for (int32_t i = 0; i < N + 1; ++i)
{
int a;
in >> a; --a;
if (exist[a]) {
dob_f = exist[a];
dob_s = i + 1;
}
else {
exist[a] = i + 1;
}
}
int32_t mid = dob_s - dob_f - 1;
out << N << '\n';
for (int32_t i = 2; i <= N; ++i)
{
///何も考えずに取る
auto total = combination<mint>(N + 1, i);
out << total - combination<mint>(N + 1 - (mid + 2), i - 1) << '\n';
}
out << 1 << endl;
return 0;
}
#endif | a.cc:317:2: error: #else after #else
317 | #else
| ^~~~
a.cc:281: error: the conditional began here
281 | #if 1
a.cc:275:6: error: 'auto fact' redeclared as different kind of entity
275 | auto fact = fact_set_c<100001>();
| ^~~~
a.cc:214:48: note: previous declaration 'template<long unsigned int MOD> constexpr mint_base<MOD> fact(mint_base<MOD>)'
214 | template<uint64_t MOD>constexpr mint_base<MOD> fact(mint_base<MOD> x)noexcept
| ^~~~
a.cc: In instantiation of 'RET combination(Integral, Integral) [with RET = mint_base<1000000007>; Integral = int]':
a.cc:358:33: required from here
358 | auto total = combination<mint>(N + 1, i);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~
a.cc:284:20: error: overloaded function with no contextual type information
284 | return fact[all] / (fact[get] * fact[all - get]);
| ~~~~^
a.cc:284:33: error: overloaded function with no contextual type information
284 | return fact[all] / (fact[get] * fact[all - get]);
| ~~~~^
a.cc:284:45: error: overloaded function with no contextual type information
284 | return fact[all] / (fact[get] * fact[all - get]);
| ~~~~^
|
s209793840 | p03676 | C++ | #include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
using namespace std;
const ll Maxn = 123456;
const ll Mod = 1000000007;
ll A[Maxn];
ll fact[Maxn];
ll inv[Maxn], ifact[Maxn];
ll freq[Maxn];
template<typename T, typename T1>
T mod(T x, T1 p)
{
x %= p;
while (x < 0)
x += p;
return x;
}
template<typename T>
T inverse(T x, T p) {
x = mod(x, p);
if (x == 1)
return x;
return mod((1LL * (-p / x) * (inv[p % x] % p)) , p);
// Since inverse of p % x is already calculated.
}
ll NcR(ll n, ll r) {
ll ret = (1LL * ifact[n - r] * ifact[r]) % Mod ;
ret = (1LL * ret * fact[n]) % Mod;
return ret;
}
int main()
{
ios_base::sync_with_stdio(false);
fact[0] = 1;
ifact[0] = 1;
for(ll i = 1; i < Maxn; i++) {
fact[i] = 1LL * fact[i - 1] * i % Mod;
}
ifact[0] = 1;
for(ll i = 1; i < Maxn; i++) {
ifact[i] = 1LL * ifact[i - 1] * inverse(i, Mod) % Mod;
}
for(ll i = 1; i < Maxn; i++) {
inv[i] = inverse(i, Mod);
ifact[i] = ifact[i - 1] * inv[i] % Mod;
}
ll n;
cin>>n;
n++;
//cout<<NcR(4,2)<<endl;
ll num=1;
for(ll i=0;i<n;i++)
{cin>>A[i];
freq[A[i]]++;
if(freq[A[i]]==2)
num=A[i];
}
ll i=0,p=0,q=0;
//cout<<num<<endl;
ll idx1,idx2;
while(i<n)
{
if(A[i]==num){idx1=i;break;}
p++;
i++;
}
i=n-1;
while(i>=0)
{
if(A[i]==num){idx2=i;break;}
q++;
i--;
}
ll d = idx2-idx1;
//d++;
// cout<<p<<" "<<q<<endl;
ll ans;
cout<<n-1<<'\n';
for(ll k=2;k<=n;k++)
{
ans= NcR(n,k);
if(k-1<=n-d-1)
{
ans-=NcR(n-d-1,k-1);
if(ans<0)ans+=mod;
}
cout<<ans<<'\n';
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:114:25: error: overloaded function with no contextual type information
114 | if(ans<0)ans+=mod;
| ^~~
|
s611557471 | p03676 | C++ | #include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<ull max_n, ull m>
class nCr_mod_m
{
public:
nCr_mod_m() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[0] = 0;
inv[1] = 1;
for (ull i = 2; i <= max_n; i++) {
inv[i] = m - inv[m % i] * (m / i) % m;
fac[i] = fac[i - 1] * i % m;
finv[i] = finv[i - 1] * inv[i] % m;
}
}
ull C(ull n, ull r) {
if (n < r)
return 0;
return fac[n] * (finv[r] * finv[n - r] % m) % m;
}
private:
ull fac[max_n + 1], inv[max_n + 1], finv[max_n + 1];
};
int main() {
int n, a[100010], have[100010], pos1, pos2;
memset(have, -1, sizeof(have));
nCr_mod_m<100010, 1000000007> nCr;
scanf("%d", &n);
for (int i = 0; i <= n; i++) {
scanf("%d", a + i);
if (have[a[i]] == -1) {
have[a[i]] = i;
} else {
pos1 = have[a[i]];
pos2 = i;
}
}
for (int i = 1; i <= n + 1; i++) {
ull combis = nCr.C(n + 1, i);
combis -= nCr.C(pos1 + (n - pos2), i - 1);
if (combis < 0)
combis += 1000000007;
printf("%lld\n", combis);
}
} | a.cc: In function 'int main()':
a.cc:36:9: error: 'memset' was not declared in this scope
36 | memset(have, -1, sizeof(have));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <deque>
+++ |+#include <cstring>
5 |
|
s712642094 | p03676 | C++ | #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007LL
#define MAX 100000
#define INF 1410065408
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};
ll fact[MAX*10], rfact[MAX+10];
ll comb(ll n, ll r){
return (((fact[n] * rfact[r]) % MOD) * rfact[n-r]) % MOD;
}
signed main(){
int n, d1, d2, tmp;
cin >> n;
vector<int> use(n+1, -1);
rep(n+1){
cin >> tmp;
if(use[tmp] != -1){
d2 = i;
d1 = use[tmp];
break;
}else{
use[tmp] = i;
}
}
fact[0] = fact[1] = 1;
rfact[0] = rfact[1] = 1;
reppp(i, 2, n+1){
fact[i] = (fact[i-1] * i) % MOD;
rfact[i] = 1;
ll k = MOD-2;
ll a = fact[i];
while(k > 0){
if(k & 1){
rfact[i] *= a;
rfact[i] %= MOD;
}
a *= a;
a %= MOD;
k >>= 1;
}
}
printf("%d\n", n); //k=1
if(n > 1) printf("%d\n", (n * (n+1) / 2 - d1 - (n-d2)) % (int)MOD); //k=2;
if(n > 2)
reppp(i, 3, n){
ll ans = comb((ll)n+1, (ll)i);
if(d1 + (n - d2) >= i-1){
//ll dup = comb((ll)(d1+n-d2), i-1);
reppp(j, max(0, i-1-(n-d2)), d1){
dup += (comb((ll)d1, (ll)j) * comb((ll)(n-d2), (ll)(i-1-j))) % MOD;
}
ans -= dup % MOD;
if(ans < 0) ans += MOD;
}
printf("%lld\n", ans);
}
printf("%d\n", 1); //k=n+1;
return 0;
} | a.cc: In function 'int main()':
a.cc:78:21: error: 'dup' was not declared in this scope
78 | dup += (comb((ll)d1, (ll)j) * comb((ll)(n-d2), (ll)(i-1-j))) % MOD;
| ^~~
a.cc:80:24: error: 'dup' was not declared in this scope
80 | ans -= dup % MOD;
| ^~~
|
s761094821 | p03676 | C++ | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
#define MOD 1000000007LL
long long factorial(long long n, long long mod) {
long long ret = 1;
for (long long i = 1; i <= n; i++) {
ret = (ret * i) % mod;
}
return ret;
}
long long inv_mod(long long n, long long mod) {
long long a = n % mod, b = mod - 2, ret = 1;
while (b > 0) {
if (b & 1) ret = (ret * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ret;
}
long long nPr(long long n, long long r, long long mod) {
long long ret = 1;
for (long long i = n; i >= n - r + 1; i--) {
ret = ret * (i % mod) % mod;
}
return ret;
}
ll facts=[100001]
long long nCr(long long n, long long r, long long mod) {
return nPr(n,r,mod) * inv_mod(factorial(r,mod),mod) % mod;
}
long long nCr2(long long n, long long r, long long mod) {
return nPr(n,r,mod) * inv_mod(facts[r],mod) % mod;
}
long long nHr(long long n, long long r, long long mod) {
return nCr(n+r-1,r,mod);
}
long long int le,ri;
long long int n;
long long int a[100001]={};
int main(){
for(int i=0;i<100001;i++)facts[i]=factorial(i,mod);
cin >> n;
int po=0;
for(int i=1;i<=n+1;i++){
cin >> po;
if(a[po]!=0){
le=a[po]-1;
ri=n+1-i;
}
a[po]=i;
}
for(int i=1;i<=n+1;i++){
long long int po=nCr2(n+1,i,MOD);
long long int sub=nCr2(le+ri,i-1,MOD);
cout<<po-sub<<endl;
}
return 0;
} | a.cc:50:11: error: expected identifier before numeric constant
50 | ll facts=[100001]
| ^~~~~~
a.cc:52:1: error: type-specifier invalid in lambda
52 | long long nCr(long long n, long long r, long long mod) {
| ^~~~
a.cc:52:6: error: type-specifier invalid in lambda
52 | long long nCr(long long n, long long r, long long mod) {
| ^~~~
a.cc:52:1: warning: parameter declaration before lambda declaration specifiers only optional with '-std=c++2b' or '-std=gnu++2b' [-Wc++23-extensions]
52 | long long nCr(long long n, long long r, long long mod) {
| ^~~~
a.cc: In lambda function:
a.cc:52:11: error: expected '{' before 'nCr'
52 | long long nCr(long long n, long long r, long long mod) {
| ^~~
a.cc: At global scope:
a.cc:50:10: error: invalid user-defined conversion from '<lambda()>' to 'll' {aka 'long long int'} [-fpermissive]
50 | ll facts=[100001]
| ^~~~~~~~
51 |
|
52 | long long nCr(long long n, long long r, long long mod) {
| ~~~~~~~~~
a.cc:50:10: note: candidate is: 'constexpr<lambda()>::operator void (*)()() const' (near match)
50 | ll facts=[100001]
| ^
a.cc:50:10: note: no known conversion from 'void (*)()' to 'll' {aka 'long long int'}
a.cc:52:11: error: expected ',' or ';' before 'nCr'
52 | long long nCr(long long n, long long r, long long mod) {
| ^~~
a.cc: In function 'long long int nCr2(long long int, long long int, long long int)':
a.cc:56:40: error: invalid types 'll {aka long long int}[long long int]' for array subscript
56 | return nPr(n,r,mod) * inv_mod(facts[r],mod) % mod;
| ^
a.cc: In function 'long long int nHr(long long int, long long int, long long int)':
a.cc:60:12: error: 'nCr' was not declared in this scope; did you mean 'nPr'?
60 | return nCr(n+r-1,r,mod);
| ^~~
| nPr
a.cc: In function 'int main()':
a.cc:67:35: error: invalid types 'll {aka long long int}[int]' for array subscript
67 | for(int i=0;i<100001;i++)facts[i]=factorial(i,mod);
| ^
a.cc:67:51: error: 'mod' was not declared in this scope; did you mean 'modf'?
67 | for(int i=0;i<100001;i++)facts[i]=factorial(i,mod);
| ^~~
| modf
|
s093272707 | p03676 | C++ | #include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>
#include "nCr_mod_m.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<ull max_n, ull m>
class nCr_mod_m
{
public:
nCr_mod_m() {
fac[0] = fac[1] = 1;
for (int i = 2; i <= max_n; i++)
fac[i] = fac[i - 1] * i % m;
inv[1] = 1;
for (int i = 2; i <= max_n; i++)
inv[i] = m - inv[m % i] * (m / i) % m;
finv[0] = finv[1] = 1;
for (int i = 2; i <= max_n; i++)
finv[i] = finv[i - 1] * inv[i] % m;
}
ull C(ull n, ull r) {
if (n < r)
return 0;
return fac[n] * (finv[r] * finv[n - r] % m) % m;
}
private:
ull fac[max_n + 1], inv[max_n + 1], finv[max_n + 1];
};
int main() {
int n, a[100010], doubled, pos1, pos2;
bool have[100010] = { false };
nCr_mod_m<100010, 1000000007> nCr;
scanf("%d", &n);
for (int i = 0; i <= n; i++) {
scanf("%d", a + i);
if (have[a[i]]) {
doubled = a[i];
pos2 = i;
for (int j = 0; j < i; j++)
if (a[j] == doubled)
pos1 = j;
}
have[a[i]] = true;
}
printf("%d\n", n);
for (int i = 2; i <= n; i++) {
ull combis = nCr.C(n + 1, i);
combis -= nCr.C(pos1 + (n - pos2), i - 1);
if (combis < 0)
combis += 1000000007;
printf("%d\n", combis);
}
printf("%d\n", 1);
} | a.cc:5:10: fatal error: nCr_mod_m.h: No such file or directory
5 | #include "nCr_mod_m.h"
| ^~~~~~~~~~~~~
compilation terminated.
|
s199108619 | p03676 | C++ | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
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; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
long D[114514];
i64 Powmod(i64 a, i64 b, i64 p)
{
if (b == 0) return 1;
if (b % 2 == 0)
{
i64 d = Powmod(a, b / 2, p);
return d * d % p;
}
else
{
return a * Powmod(a, b - 1, p) % p;
}
}
int main()
{
memset(D, -1, sizeof(D));
int N;
scanf("%d", &N);
int A[114514];
for(int i = 0; i <= N; i++)
{
scanf("%d", &A[i]);
}
int C[114514];
//memset(C, -1, sizeof(C));
i64 K[114514];
K[0] = 1;
C[0] = -1;
for (int i = 1; i <= N + 1; i++)
{
K[i] = (K[i - 1] * (long)i) % mod;
C[i] = -1;
}
int l = -1, r = -1;
for (int i = 0; i <= N; i++)
{
int x = A[i];
if (C[x] == -1)
{
C[x] = i;
}
else
{
l = C[x];
r = i;
break;
}
}
//printf("%d %d\n",l,r);
int W = l + N - r;
printf("%d\n", N);
for (int i = 2; i <= N; i++)
{
i64 p;
if(D[i]!=-1)p =D[i];
else
{
D[i] = Powmod(K[i], mod - 2, mod);
p = D[i];
}
i64 d = K[N + 1] * p % mod;
f(D[N + i - 1]!=-1)p =D[i];
else
{
D[N + 1 - i] = Powmod(K[N + i - 1], mod - 2, mod);
p = D[i];
}
d = d * p % mod;
if (i == 2)
{
d -= l;
d -= N - r;
}
else
{
if (i - 1 <= W)
{
if(D[i - 1]!=-1)p =D[i - 1];
else
{
D[i- 1] = Powmod(K[i - 1], mod - 2, mod);
p = D[i - 1];
}
long e = K[W] *p % mod;
if(D[i - 1]!=-1)p =D[i - 1];
else
{
D[W - i+ 1] = Powmod(K[W - i + 1], mod - 2, mod);
p = D[W - i + 1];
}
e = e * Powmod(p, mod - 2, mod);
d -= e;
}
}
while (d< 0)
{
d += mod;
}
d %= mod;
printf("%lld\n", d);
}
printf("1\n");
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:17: error: 'f' was not declared in this scope
85 | f(D[N + i - 1]!=-1)p =D[i];
| ^
a.cc:86:17: error: 'else' without a previous 'if'
86 | else
| ^~~~
|
s794388542 | p03676 | C++ | #include <cstdio>
#include <vector>
int N;
int A[100003];
int cnt[100003];
using namespace std;
template< bool B, class T = void >
using enable_if_t = typename enable_if<B,T>::type;
template<int M, bool IsPrime = false>
class Modulo {
using ll = long long;
int n;
static enable_if_t<IsPrime, ll> inv(ll a, ll p) {
return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
public:
Modulo () : n(0) {;}
Modulo (int m) : n(m) {
if (n >= M) n %= M;
else if (n < 0) n = (n % M + M) % M;
}
Modulo (ll m) {
if (m >= M) m %= M;
else if (m < 0) m = (m % M + M) % M;
n = m;
}
explicit operator int() const { return n; }
explicit operator ll() const { return n; }
bool operator==(const Modulo &a) const { return n == a.n; }
Modulo operator+=(const Modulo &a) { n += a.n; if (n >= M) n -= M; return *this; }
Modulo operator-=(const Modulo &a) { n -= a.n; if (n < 0) n += M; return *this; }
Modulo operator*=(const Modulo &a) { n = (ll(n) * a.n) % M; return *this; }
Modulo operator+(const Modulo &a) const { Modulo res = *this; return res += a; }
Modulo operator-(const Modulo &a) const { Modulo res = *this; return res -= a; }
Modulo operator*(const Modulo &a) const { Modulo res = *this; return res *= a; }
Modulo operator^(int n) const {
if (n == 0) return Modulo(1);
const Modulo a = *this;
Modulo res = (a * a) ^ (n / 2);
return n % 2 ? res * a : res;
}
enable_if_t<IsPrime, Modulo> operator/(const Modulo &a) const {
return *this * inv(ll(a), M);
}
};
const int mod = 1000000007;
template<int M = mod> Modulo<M, true> fact(int n, bool sw = true) {
static vector<Modulo<M, true>> v1 = {1}, v2 = {1};
if (n >= (int)v1.size()) {
const int from = v1.size(), to = n + 1024;
v1.reserve(to);
v2.reserve(to);
for (int i = from; i < to; ++i) {
v1.push_back(v1.back() * Modulo<M, true>(i));
v2.push_back(v2.back() / Modulo<M, true>(i));
}
}
return sw ? v1[n] : v2[n];
}
template<int M = mod> Modulo<M, true> comb(int a, int b) {
if (b < 0 || b > a) return 0;
return fact<M>(a, true) * fact<M>(b, false) * fact<M>(a-b, false);
}
using Mod = Modulo<mod, true>;
int main() {
scanf("%d", &N);
for (int i = 1; i <= N + 1; i++) {
int x;
scanf("%d", &x);
A[i] = x;
cnt[x]++;
}
//printf("N: %d\n", N);
int dup = 0;
for (int i = 1; i <= N + 1; i++) {
if (cnt[i] == 2) {
dup = i;
}
}
//printf("dup: %d\n", dup);
int d1i = 0;
int d2i = 0;
int i = 1;
for (; i <= N + 1; i++) {
//printf("i: %d, A[i]: %d\n", i, A[i]);
if (A[i] == dup) {
d1i = i++;
break;
}
}
for (; i <= N + 1; i++) {
//printf("i: %d, A[i]: %d\n", i, A[i]);
if (A[i] == dup) {
d2i = i;
break;
}
}
//printf("d1i: %d, d2i: %d\n", d1i, d2i);
for (int i = 1; i <= N + 1; i++) {
//printf("all: %d\n", N + 1);
auto all = comb<mod>(N + 1, i);
int prev = d1i - 1;
int post = N + 1 - d2i;
//printf("prev: %d, post: %d\n", prev, post);
Mod dupsum = 0;
for (int prev_choice = 0; prev_choice < d1i; prev_choice++) {
int post_choice = i - prev_choice - 1;
if (post_choice < 0) {
continue;
}
//printf("prev_choice: %d, post_choice: %d\n", prev_choice, post_choice);
auto x = comb<mod>(prev, prev_choice);
auto y = comb<mod>(post, post_choice);
dupsum = dupsum + (x * y);
}
printf("%lld\n", static_cast<long long>(all - dupsum));
}
}
| a.cc:17:10: error: reference to 'enable_if_t' is ambiguous
17 | static enable_if_t<IsPrime, ll> inv(ll a, ll p) {
| ^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/type_traits:2711:11: note: candidates are: 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type'
2711 | using enable_if_t = typename enable_if<_Cond, _Tp>::type;
| ^~~~~~~~~~~
a.cc:11:7: note: 'template<bool B, class T> using enable_if_t = typename std::enable_if::type'
11 | using enable_if_t = typename enable_if<B,T>::type;
| ^~~~~~~~~~~
a.cc:46:3: error: reference to 'enable_if_t' is ambiguous
46 | enable_if_t<IsPrime, Modulo> operator/(const Modulo &a) const {
| ^~~~~~~~~~~
/usr/include/c++/14/type_traits:2711:11: note: candidates are: 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type'
2711 | using enable_if_t = typename enable_if<_Cond, _Tp>::type;
| ^~~~~~~~~~~
a.cc:11:7: note: 'template<bool B, class T> using enable_if_t = typename std::enable_if::type'
11 | using enable_if_t = typename enable_if<B,T>::type;
| ^~~~~~~~~~~
a.cc: In instantiation of 'Modulo<M, true> fact(int, bool) [with int M = 1000000007]':
a.cc:69:17: required from 'Modulo<M, true> comb(int, int) [with int M = 1000000007]'
69 | return fact<M>(a, true) * fact<M>(b, false) * fact<M>(a-b, false);
| ~~~~~~~^~~~~~~~~
a.cc:115:25: required from here
115 | auto all = comb<mod>(N + 1, i);
| ~~~~~~~~~^~~~~~~~~~
a.cc:61:30: error: no match for 'operator/' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<Modulo<1000000007, true> >, Modulo<1000000007, true> >::value_type' {aka 'Modulo<1000000007, true>'} and 'Modulo<1000000007, true>')
61 | v2.push_back(v2.back() / Modulo<M, true>(i));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:61:30: note: candidate: 'operator/(long long int, long long int)' (built-in)
a.cc:61:30: note: no known conversion for argument 2 from 'Modulo<1000000007, true>' to 'long long int'
a.cc:61:30: note: candidate: 'operator/(long long int, int)' (built-in)
a.cc:61:30: note: no known conversion for argument 2 from 'Modulo<1000000007, true>' to 'int'
a.cc:61:30: note: candidate: 'operator/(int, long long int)' (built-in)
a.cc:61:30: note: no known conversion for argument 2 from 'Modulo<1000000007, true>' to 'long long int'
a.cc:61:30: note: candidate: 'operator/(int, int)' (built-in)
a.cc:61:30: note: no known conversion for argument 2 from 'Modulo<1000000007, true>' to 'int'
|
s921212990 | p03676 | Java | import java.util.*;
public class Main {
static long MOD = (long)Math.pow(10, 9) + 7;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long[] kaijou = new long[n + 1];
kaijou[0] = 1;
for(int i = 1; i < n + 1; i++) {
kaijou[i] = (kaijou[i - 1] * (long)i) % MOD;
}
int[] suuretu = new int[n + 1];
long[] aho = new long[n + 1];
for(int i = 0; i < n + 1; i++) {
long a = sc.nextLong();
aho[i] = a;
suuretu[a]++;
}
long u = 0;
for(int i = 0; i < n + 1; i++) {
if(suuretu[i] == 2) u = i;
}
int index = 0;
int index2 = 0;
boolean flg = true;
for(int i = 0; i < n + 1; i++) {
if(aho[i] == u) {
if(flg) {
flg = false;
index = i;
} else {
index2 = i;
}
}
}
long unko = (long)(index + n - index2);
long[] dp = new long[unko + 1];
long[] dp2 = new long[n + 2];
for(int k = 0; k < unko + 1; k++) {
long inv = func(kaijou[k], MOD - 2);
long inv2 = func(kaijou[unko - k], MOD - 2);
long ret = (kaijou[unko] * inv) % MOD;
ret = (ret * inv2) % MOD;
dp[k] = ret;
}
for(int k = 0; k < n + 2; k++) {
long inv = func(kaijou[k], MOD - 2);
long inv2 = func(kaijou[n + 1 - k], MOD - 2);
long ret = (kaijou[n + 1] * inv) % MOD;
ret = (ret * inv2) % MOD;
dp2[k] = ret;
}
for(int k = 1; k <= n + 1; k++) {
long ans = dp2[k];
if(k >= 1) {
if(ans >= dp[k - 1]) {
ans -= dp[k - 1];
} else {
ans = (ans + MOD - dp[k - 1]) % MOD;
}
}
System.out.println(ans);
}
}
public static long func(long a, long x) {
if(x == 0) return 1;
long t = func(a, x / 2);
long ret = (t * t) % MOD;
if(x % 2 == 1) ret = (ret * a) % MOD;
return ret;
}
} | Main.java:8: error: incompatible types: possible lossy conversion from long to int
long[] kaijou = new long[n + 1];
^
Main.java:13: error: incompatible types: possible lossy conversion from long to int
int[] suuretu = new int[n + 1];
^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
long[] aho = new long[n + 1];
^
Main.java:18: error: incompatible types: possible lossy conversion from long to int
suuretu[a]++;
^
Main.java:38: error: incompatible types: possible lossy conversion from long to int
long[] dp = new long[unko + 1];
^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
long[] dp2 = new long[n + 2];
^
Main.java:42: error: incompatible types: possible lossy conversion from long to int
long inv2 = func(kaijou[unko - k], MOD - 2);
^
Main.java:43: error: incompatible types: possible lossy conversion from long to int
long ret = (kaijou[unko] * inv) % MOD;
^
Main.java:49: error: incompatible types: possible lossy conversion from long to int
long inv2 = func(kaijou[n + 1 - k], MOD - 2);
^
Main.java:50: error: incompatible types: possible lossy conversion from long to int
long ret = (kaijou[n + 1] * inv) % MOD;
^
10 errors
|
s110909015 | p03676 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN
//関係無いけどMODからどうやって階乗を復元すんだっけ?
ll Combination(int n, int r)
{
if (n <= 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
int numerator[r];
int denominator[r];
for (int k = 0; k < r; k++)
{
numerator[k] = n - r + k + 1;//分子
denominator[k] = k + 1;//分母
}
for (int p = 2; p <= r; p++)
{
int pivot = denominator[p - 1];
if (pivot > 1)
{
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p)
{
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
ll result = 1;
for (int k = 0; k < r; k++)
{
if (numerator[k] > 1){
result *= numerator[k];
result %= MOD;
}
}
return cb[r]=result;
}
int main(void){
int n,a[100010],before,after;
ll ans,cb[100010]={};
map<int,int> b;
cin>>n;
rep(i,n+1){//0-origin
cin>>a[i];
if(b.count(a[i])==0){
b[a[i]]=i;
}else{
before = b[a[i]];
after = i;
}
}
// cout<<before<<","<<after<<endl;
reg(i,1,n+1){
if(i==1){
ans=n;
}else{
if(cb[i]!=0){
ans=cb[i];
}else{
ans=Combination(n+1,i);
}
ans-=Combination(n+1-(after-before+1),i-1);
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'll Combination(int, int)':
a.cc:65:12: error: 'cb' was not declared in this scope
65 | return cb[r]=result;
| ^~
|
s351239225 | p03676 | C++ | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
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; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };
long D[114514];
i64 Powmod(i64 a, i64 b, i64 p)
{
if (b == 0) return 1;
if (b % 2 == 0)
{
i64 d = Powmod(a, b / 2, p);
return d * d % p;
}
else
{
return a * Powmod(a, b - 1, p) % p;
}
}
int main()
{
memset(D, -1, sizeof(D));
int N;
scanf("%d", &N);
int A[114514];
for(int i = 0; i <= N; i++)
{
scanf("%d", &A[i]);
}
int C[114514];
//memset(C, -1, sizeof(C));
i64 K[114514];
K[0] = 1;
C[0] = -1;
for (int i = 1; i <= N + 1; i++)
{
K[i] = (K[i - 1] * (long)i) % mod;
C[i] = -1;
}
int l = -1, r = -1;
for (int i = 0; i <= N; i++)
{
int x = A[i];
if (C[x] == -1)
{
C[x] = i;
}
else
{
l = C[x];
r = i;
break;
}
}
//printf("%d %d\n",l,r);
int W = l + N - r;
printf("%d\n", N);
for (int i = 2; i <= N; i++)
{
i64 p;
if(D[i]!=-1)p =D[i];
else
{
D[i] = Powmod(K[i], mod - 2, mod);
p = D[i];
}
i64 d = K[N + 1] * p % mod;
f(D[N + i - 1]!=-1)p =D[i];
else
{
D[N + 1 - i] = Powmod(K[N + i - 1], mod - 2, mod);
p = D[i];
}
d = d * p % mod;
if (i == 2)
{
d -= l;
d -= N - r;
}
else
{
if (i - 1 <= W)
{
if(D[i - 1]!=-1)p =D[i - 1];
else
{
D[i- 1] = Powmod(K[i - 1], mod - 2, mod);
p = D[i - 1];
}
long e = K[W] *p % mod;
e = e * Powmod(K[W - i + 1], mod - 2, mod);
d -= e;
}
}
while (d< 0)
{
d += mod;
}
d %= mod;
printf("%lld\n", d);
}
printf("1\n");
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:17: error: 'f' was not declared in this scope
85 | f(D[N + i - 1]!=-1)p =D[i];
| ^
a.cc:86:17: error: 'else' without a previous 'if'
86 | else
| ^~~~
|
s415154608 | p03676 | Java | import java.util.*;
public class Main {
static long MOD = (long)Math.pow(10, 9) + 7;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long[] kaijou = new long[n + 1];
kaijou[0] = 1;
for(int i = 1; i < n + 1; i++) {
kaijou[i] = (kaijou[i - 1] * i) % MOD;
}
int[] suuretu = new int[n + 1];
long[] aho = new long[n + 1];
for(int i = 0; i < n + 1; i++) {
long a = sc.nextLong();
aho[i] = a;
suuretu[a]++;
}
long u = 0;
for(int i = 0; i < n + 1; i++) {
if(suuretu[i] == 2) u = i;
}
int index = 0;
int index2 = 0;
boolean flg = true;
for(int i = 0; i < n + 1; i++) {
if(aho[i] == u) {
if(flg) {
flg = false;
index = i;
} else {
index2 = i;
}
}
}
long unko = (long)(index + n - index2);
long[] dp = new long[unko + 1];
long[] dp2 = new long[n + 2];
for(int k = 0; k < unko + 1; k++) {
long inv = func(kaijou[k], MOD - 2);
long inv2 = func(kaijou[unko - k], MOD - 2);
long ret = (kaijou[unko] * inv) % MOD;
ret = (ret * inv2) % MOD;
dp[k] = ret;
}
for(int k = 0; k < n + 2; k++) {
long inv = func(kaijou[k], MOD - 2);
long inv2 = func(kaijou[n + 1 - k], MOD - 2);
long ret = (kaijou[n + 1] * inv) % MOD;
ret = (ret * inv2) % MOD;
dp2[k] = ret;
}
for(int k = 1; k <= n + 1; k++) {
long ans = dp2[k];
if(k >= 1) {
if(ans >= dp[k - 1]) {
ans -= dp[k - 1];
} else {
ans = (ans + MOD - dp[k - 1]) % MOD;
}
}
System.out.println(ans);
}
}
public static long func(long a, long x) {
if(x == 0) return 1;
long t = func(a, x / 2);
long ret = (t * t) % MOD;
if(x % 2 == 1) ret = (ret * a) % MOD;
return ret;
}
} | Main.java:8: error: incompatible types: possible lossy conversion from long to int
long[] kaijou = new long[n + 1];
^
Main.java:13: error: incompatible types: possible lossy conversion from long to int
int[] suuretu = new int[n + 1];
^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
long[] aho = new long[n + 1];
^
Main.java:18: error: incompatible types: possible lossy conversion from long to int
suuretu[a]++;
^
Main.java:38: error: incompatible types: possible lossy conversion from long to int
long[] dp = new long[unko + 1];
^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
long[] dp2 = new long[n + 2];
^
Main.java:42: error: incompatible types: possible lossy conversion from long to int
long inv2 = func(kaijou[unko - k], MOD - 2);
^
Main.java:43: error: incompatible types: possible lossy conversion from long to int
long ret = (kaijou[unko] * inv) % MOD;
^
Main.java:49: error: incompatible types: possible lossy conversion from long to int
long inv2 = func(kaijou[n + 1 - k], MOD - 2);
^
Main.java:50: error: incompatible types: possible lossy conversion from long to int
long ret = (kaijou[n + 1] * inv) % MOD;
^
10 errors
|
s226800402 | p03676 | C++ | #include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
constexpr long MOD = 1000000000 + 7;
long gcd(long a, long b)
{
if (b > a)
swap(a, b);
if (b == 0)
return a;
if (b == 1)
return 1;
return gcd(b, a % b);
}
long COMB[50001][
long comb(long a, long b)
{
if (b > a)
return 0;
if (a - b < b)
return comb(a, a - b);
long x = 1;
vector<long> cs;
cs.push_back(1);
for (long i = 2; i <= b; ++i) {
if (cs.back() >= 1000000000) {
cs.push_back(1);
}
cs.back() *= i;
}
for (long i = 0; i < b; ++i) {
long d = a - i;
for (long& c : cs) {
long g = gcd(d, c);
// cerr << " " << i << " " << d << " " << g << endl;
d /= g;
c /= g;
}
x *= d;
x %= MOD;
}
// assert(c == 1);
// cerr << "GCD " << a << ' ' << b << ' ' << x << endl;
return x;
}
int main()
{
int N;
cin >> N;
++N;
vector<int> a(N);
for (int i = 0; i < N; ++i)
cin >> a[i];
set<int> s;
int dupe = -1;
for (int x : a) {
if (s.find(x) != s.end()) {
dupe = x;
break;
}
s.insert(x);
}
int l = -1;
int r = -1;
for (int i = 0; i < N; ++i) {
if (a[i] == dupe) {
if (l == -1)
l = i;
else
r = i;
}
}
assert(r != -1);
int osz = l + (N - 1) - r;
for (int k = 1; k <= N; ++k) {
long p = comb(N, k);
long q = comb(osz, k - 1);
long v = (p + MOD - q) % MOD;
cout << v << '\n';
}
return 0;
}
| a.cc:32:1: error: expected primary-expression before 'long'
32 | long comb(long a, long b)
| ^~~~
a.cc:30:18: error: expected ']' before 'long'
30 | long COMB[50001][
| ^
| ]
31 |
32 | long comb(long a, long b)
| ~~~~
a.cc: In function 'int main()':
a.cc:102:18: error: 'comb' was not declared in this scope; did you mean 'wctomb'?
102 | long p = comb(N, k);
| ^~~~
| wctomb
|
s617325482 | p03676 | C++ | #include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define FOR(i,N) for(int i=0;i<N;i++)
int mod=1e9+7;
ll mo=1000000007;
map<pair<ll,ll>, ll>mem;
const int NUM_=1000001;
ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
ll combi(ll N_, ll C_) {
if(mem[make_pair(N_, C_)]){
return mem[make_pair(N_, C_)];
}
if(C_<0 || C_>N_) return 0;
return mem[make_pair(N_, C_)]=factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int main() {
memset(fact,0,sizeof(fact));
memset(factr,0,sizeof(factr));
memset(inv,0,sizeof(inv));
if (fact[0]==0) {
inv[1]=fact[0]=factr[0]=1;
for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
}
int n;
cin>>n;
vector<int>a(n+1);
map<int,int>ma;
int d=-1;
int l,r;
for(int i=0;i<n+1;i++){
cin>>a[i];
ma[a[i]]++;
if(ma[a[i]]>1){
d=a[i];
r=n+1-i-1;
}
}
for(int i=0;i<n+1;i++){
if(a[i]==d){
l=i;
break;
}
}
int l_a_r=max(l,r);
cout<<n<<endl;
ll cur=n+1;
for(int i=2;i<n+1;i++){
cur=cur*(n+1-(i-1))/i;
if(i<=l+r+1){
ll ans=combi(l,i-1)+combi(r,i-1);
for(int j=1;j<=min(i-1,l);j++){
if(i-j>1){
ans+=combi(l, j)*combi(r,i-1-j);
}
}
cout<<(cur-ans)%mod<<endl;
} else {
cout<<cur%mod<<endl;
}
}
cout<<1<<endl;
}
| a.cc: In function 'int main()':
a.cc:33:5: error: 'memset' was not declared in this scope
33 | memset(fact,0,sizeof(fact));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include<unordered_set>
+++ |+#include <cstring>
10 | using namespace std;
|
s682262880 | p03676 | C++ | https://arc077.contest.atcoder.jp/submit | a.cc:1:1: error: 'https' does not name a type
1 | https://arc077.contest.atcoder.jp/submit
| ^~~~~
|
s291548113 | p03676 | C++ | #include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
ll MOD = 1000000007;
ll modPow(ll x, ll y)
{
ll r=1, a=x;
while (y > 0) {
if ( (y&1)==1 ) {
r = (r * a) % MOD;
}
a = (a * a) % MOD;
y /= 2;
}
return r;
}
// Modular multiplicative inverse through Fermat's little theorem:
// 繝輔ぉ繝ォ繝槭・縺ョ蟆丞ョ夂炊繧医j, a^-1 竕。 a^(p-2) (mod p) 縺ィ縺・≧縺ョ繧剃スソ縺・i縺励>
// 縺溘□縺励}縺檎エ謨ー縺ョ譎ゅ@縺区・繧顔ォ九◆縺ェ縺・ll modInverse(ll x)
{
return modPow(x, MOD-2);
}
// Modular division x / y, find modular multiplicative inverse of y
// and multiply by x.
ll modDivision(ll p, ll q)
{
return (p * modInverse(q)) % MOD;
}
// Binomial coifficient C(n,k) in O(k) time.
ll n_choose_k(ll n, int k)
{
if (k > n) {
return 0;
}
ll p = 1, q = 1;
for (int i=1; i<=k; i++) {
q = ( q * i) % MOD;
p = ( p * (n - i + 1) ) % MOD;
}
return modDivision( p, q);
}
int main(void)
{
cin.sync_with_stdio(false);
int N;
cin >> N;
vector<ll> As(N+1);
vector<int> count(N+1);
ll target = -1;
REP(n,N+1) {
cin >> As[n];
++count[As[n]];
if (count[As[n]] == 2) target = As[n];
}
// left, mid, right
vector<int> splits(3);
int idx = 0;
for(auto a: As) {
if (a == target) ++idx;
else ++splits[idx];
}
auto left = splits[0];
auto mid = splits[1];
auto right = splits[2];
// REP(n, 3) cout << splits[n] << ",";
// cout << endl;
vector<ll> ans(N+2);
// (i) no targets + more
FOR(k, 1, N) {
ans[k] += n_choose_k(N-1, k);
ans[k] %= MOD;
}
// (ii) two targets + 0 or more
FOR(k, 2, N+2) {
ans[k] += n_choose_k(N-1, k-2);
ans[k] %= MOD;
}
// (iii) one target only
ans[1] += 1;
// (iv) one target + more
FOR(k, 1, N) {
if (k > (N-1 - left - right)) {
ans[k + 1] += 2 * n_choose_k(N-1, k);
ans[k + 1] %= MOD;
}
else {
// auto tmp1 = n_choose_k(N-1, k);
// auto tmp2 = n_choose_k(mid, k);
// ans[k + 1] += tmp2 * 2;
// ans[k + 1] %= MOD;
// ans[k + 1] += (tmp1 - tmp2 + MOD);
// ans[k + 1] %= MOD;
auto tmp1 = n_choose_k(left + right, k);
ans[k + 1] += tmp1;
ans[k + 1] %= MOD;
auto tmp2 = n_choose_k(N-1, k);
ans[k + 1] += 2 * (tmp2 - tmp1 + MOD);
ans[k + 1] %= MOD;
}
}
FOR(i, 1, N+2) cout << ans[i] << endl;
return 0;
}
| a.cc:51:1: error: expected unqualified-id before '{' token
51 | {
| ^
a.cc: In function 'll modDivision(ll, ll)':
a.cc:59:17: error: 'modInverse' was not declared in this scope
59 | return (p * modInverse(q)) % MOD;
| ^~~~~~~~~~
|
s564821707 | p03676 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)
#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()
ll C[100002][100002];
void fillC(int n){
C[0][0] = 1LL;
for(int i=0; i<=n+1; i++){
C[i][0] = 1LL;
C[i][i] = 1LL;
for(int j=1; j<=i-1; j++){
C[i][j] = (C[i-1][j-1]+C[i-1][j]) % MOD;
}
}
}
int main(int argc, const char * argv[]) {
int n;
cin >> n;
vi v;
int x, y;
while(1){
int tmp;
cin >> tmp;
auto itr = find(v.begin(), v.end(), tmp);
if(itr == v.end()){
v.push_back(tmp);
continue;
}
x = itr - v.begin();
//cerr << x << endl;
y = n - v.size();
//cerr << y << endl;
break;
}
fillC(n);
/*
for(int i=0; i<=n+1; i++){
for(int j=0; j<=i; j++){
cerr << C[i][j] << " ";
}
cerr << endl;
}
*/
for(int k=1; k<=n+1; k++){
cout << C[n+1][k] - C[x+y][k-1] << endl;
}
return 0;
}
| a.cc:23:39: error: extended character — is not valid in an identifier
23 | #define REPR(i,M,m) for(int i=M; i>m; i—-)
| ^
a.cc:25:40: error: extended character — is not valid in an identifier
25 | #define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
| ^
|
s664128799 | p03676 | C++ | C:\Filyan\Competitive Programming\CP\CP\Source.cpp | a.cc:1:3: error: stray '\' in program
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
a.cc:1:10: error: stray '\' in program
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
a.cc:1:34: error: stray '\' in program
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
a.cc:1:37: error: stray '\' in program
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
a.cc:1:40: error: stray '\' in program
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
a.cc:1:2: error: found ':' in nested-name-specifier, expected '::'
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
| ::
a.cc:1:1: error: 'C' does not name a type
1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
| ^
|
s609572835 | p03676 | C++ |
#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
auto& in = std::cin;
auto& out = std::cout;
int32_t N;
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in >> N;
using BS_INT = int64_t;
BS_INT beg = 0, end = N + 1;
while (beg + 1 != end) {
BS_INT mid = (beg + end) / 2;
bool ok = false;
//ここに書く
if (ok) {
beg = mid;
}
else {
end = mid;
}
}
return 0;
}
#endif
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
auto& in = std::cin;
auto& out = std::cout;
template<typename Arithmetic, typename Integral>
std::enable_if_t< std::is_unsigned<Integral>::value, Arithmetic>
ipow(Arithmetic bace, Integral n)
{
//繰り返し二条法
auto res = (Arithmetic)(1);
while (n > 0) {
if (n & 1) res *= bace;
bace *= bace;
n >>= 1;
}
return res;
}
constexpr bool is_prime(uint32_t N)
{
if (N <= 1) {
return false;
}
for (size_t i = 2; i*i <= N; ++i)
{
if (N%i == 0) {
return false;
}
}
return true;
}
template <uint64_t MOD> class mint_base;
//mint_base_base型用の累乗関数
template <uint64_t MOD> constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept;
//mod計算を自動で行う整数テンプレートクラス
template <uint64_t MOD_ = 1000000007>
class mint_base
{
public:
static constexpr auto MOD = MOD_;
static_assert(!(MOD <= 2), "MOD cannot be below 2.");
static_assert(MOD <= (0xFFFFFFFFFFFFFFFF / 2), "MOD is too big");//加算してオーバーフローしない
static_assert(MOD <= 0xFFFFFFFF, "MOD is too big");//乗算してオーバーフローしない
constexpr mint_base<MOD> operator+(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v += other;
}
constexpr mint_base<MOD> operator-(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v -= other;
}
constexpr mint_base<MOD> operator*(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v *= other;
}
constexpr auto operator/(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v /= other;
}
constexpr mint_base<MOD>& operator+=(const mint_base<MOD> &other) noexcept
{
a += other.a;
if (MOD <= a) { a -= MOD; };
return *this;
}
constexpr mint_base<MOD>& operator-=(const mint_base<MOD> &other) noexcept
{
if (a >= other.a) {
a -= other.a;
}
else {
a = (a + MOD) - other.a;
}
return *this;
}
constexpr mint_base<MOD>& operator*=(const mint_base<MOD> &other) noexcept
{
#if 1
a *= other.a;
a %= MOD;
#else
//MOD <= (MAXUINT64 / 2)条件下
uint64_t b = other.a, v = 0;
while (b > 0) {
if (b & 1) {
v += a;
if (v >= MOD)v -= MOD;
}
a += a;
if (MOD <= a)a -= MOD;
b >>= 1;
}
a = v;
#endif
return *this;
}
constexpr std::enable_if_t<is_prime(MOD), mint_base<MOD>&>
operator/=(const mint_base<MOD> &other) noexcept
{
return *this *= ipow(other, MOD - 2);
}
constexpr mint_base<MOD> operator+()const noexcept { return *this; }
constexpr mint_base<MOD> operator-()const noexcept
{
return{ MOD - a, mod_value_tag{} };
}
constexpr mint_base<MOD>& operator++() noexcept
{
if (MOD <= ++a) { a = 0; };
return *this;
}
constexpr mint_base<MOD>& operator--() noexcept
{
if (a <= 0) { a = MOD; };
--a;
return *this;
}
constexpr mint_base<MOD> operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
constexpr mint_base<MOD> operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
constexpr mint_base<MOD> operator~()const noexcept
{
return ipow(*this, e_phi - 1);
}
constexpr mint_base<MOD>& operator=(const mint_base<MOD> &other) noexcept
{
a = other.a;
return *this;
}
constexpr explicit operator uint64_t()const noexcept
{
return a;
}
constexpr explicit operator unsigned()const noexcept
{
return (unsigned)a;
}
static constexpr uint64_t getmod() noexcept
{
return MOD;
}
constexpr mint_base(uint64_t a_) noexcept :a(a_ % MOD) {}
constexpr mint_base()noexcept : a(0) {}
struct mod_value_tag {};
constexpr mint_base(uint64_t a_, mod_value_tag) :a(a_) {}
private:
static constexpr uint64_t get_e_phi()noexcept {
//オイラー値の導出
uint64_t temp = MOD;
uint64_t m_ = MOD;
for (uint64_t i = 2; i * i <= m_; ++i)
{
if (m_ % i == 0)
{
temp = temp / i * (i - 1);
for (; m_ % i == 0; m_ /= i);
}
}
if (m_ != 1)temp = temp / m_ * (m_ - 1);
return temp;
}
static constexpr uint64_t e_phi = get_e_phi();//オイラー値
uint64_t a;
};
//mint_base型用の累乗関数
template<uint64_t MOD>constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept
{
mint_base<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint_baseの階乗計算
//O(x)時間が必要のため、fact_set関数を推奨する。
template<uint64_t MOD>constexpr mint_base<MOD> fact(mint_base<MOD> x)noexcept
{
mint_base<MOD> res(1);
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
}
return res;
}
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(x)時間が必要
template<uint64_t MOD>std::vector<mint_base<MOD>> fact_set(mint_base<MOD> x = mint_base<MOD>(-1))
{
mint_base<MOD> res(1);
std::vector<mint_base<MOD>> set((uint64_t)(x)+1);
set[0] = 1;
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
set[i] = res;
}
return res;
}
//mint_base型のstreamへの出力
template<uint64_t MOD> std::ostream& operator<<(std::ostream& os, mint_base<MOD> i)
{
os << (uint64_t)i;
return os;
}
//mint_base型のstreamからの入力
template<uint64_t MOD> std::istream& operator >> (std::istream& is, mint_base<MOD>& i)
{
uint64_t tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint_base<1000000007> mint;
namespace mint_literal {
constexpr mint operator""_mi(unsigned long long x)noexcept {
return mint(x);
}
}
using namespace mint_literal;
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(N) //O(1)
template<uint64_t X, uint64_t MOD = mint::MOD>
/*constexpr*/ std::array<mint_base<MOD>, X + 1> fact_set_c()
{
mint_base<MOD> res(1);
std::array<mint_base<MOD>, X + 1> set;
set[0] = 1;
for (uint64_t i = 1; i <= X; ++i)
{
res *= i;
set[i] = res;
}
return set;
}
template<typename RET = uint64_t, typename Integral>
RET combination(Integral all, Integral get)
{
//assert(all >= get);
if (!(all >= get)) { return 0; }
get = std::min(all - get, get);
#if 0
constexpr int32_t ALL_MAX = 100'000;
static std::vector<RET> DP_comb[ALL_MAX + 1];
if (!DP_comb[all].empty())
{
return DP_comb[all][get];
}
if (DP_comb[0].empty())
{
DP_comb[0].resize(1);
DP_comb[0][0] = (RET)1;
DP_comb[1].resize(1);
DP_comb[1][0] = (RET)1;
}
for (int32_t i = 2; i <= all; i++)
{
if (DP_comb[i].empty())
{
int32_t size = i / 2 + 1;
DP_comb[i].resize(size);
DP_comb[i][0] = (RET)1;
for (int32_t j = 1; j < size - 1; j++)
{
DP_comb[i][j] = DP_comb[i - 1][j - 1] + DP_comb[i - 1][j];
}
DP_comb[i][size - 1] = DP_comb[i - 1][size - 2] + DP_comb[i - 1][(i & 1) ? (size - 1) : (size - 2)];
}
}
return DP_comb[all][get];
#else
constexpr int32_t ALL_MAX = 100'000;
static bool ok = false;
if(ok){
return DP_comb[get];
}
static RET DP_comb[ALL_MAX + 1];
RET ret = (RET)1;
DP_comb[0] = ret;
for (Integral i = 1; i <= ALL_MAX; ++i)
{
ret *= all + 1 - i;
ret /= i;
DP_comb[i] = ret;
}
ok = true;
return DP_comb[get];
#endif
}
int32_t N;
int32_t exist[100000] = {};
int32_t dob_f = -1;
int32_t dob_s = -1;
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in.tie(nullptr);
out.tie(nullptr);
in >> N;
for (int32_t i = 0; i < N+1; ++i)
{
int a;
in >> a; --a;
if (exist[a]) {
dob_f = exist[a];
dob_s = i+1;
}
else {
exist[a] = i + 1;
}
}
int32_t mid = dob_s - dob_f - 1;
out << N<<'\n';
for (int32_t i = 2; i <= N; ++i)
{
///何も考えずに取る
auto total = combination<mint>(N + 1, i);
out<< total - combination<mint>(N + 1 - (mid+2), i-1)<<'\n';
}
out << 1 <<endl;
return 0;
}
#endif
| a.cc: In function 'RET combination(Integral, Integral)':
a.cc:369:24: error: 'DP_comb' was not declared in this scope
369 | return DP_comb[get];
| ^~~~~~~
|
s563181646 | p03676 | C++ | #include <stdio.h>
#define MOD 1000000007
long long fac[100005];
long long invfac[100005];
long long powmod(long long a,int b)
{
if (b==1) return a;
if (b&1) return (powmod((a*a)%MOD,b/2)*a)%MOD;
return powmod((a*a)%MOD,b/2);
}
long long inv(long long a)
{
return powmod(a,MOD-2);
}
long long choose(long long a,long long b)
{
if (b<0 || b>a) return 0;
return (((fac[a]*invfac[b])%MOD)*invfac[a-b])%MOD;
}
int t1,t2;
int n;
int use[100005];
int i1,i2;
int mid;
long long ans;
int main()
{
#ifdef NOT_DMOJ
freopen("data.txt","r",stdin);
#endif // NOT_DMOJ
scanf("%d%d",&n,&t1);
use[t1]=1;
fac[0]=invfac[0]=1;
for (int i=1; i<=n; i++) {
fac[i]=(i*fac[i-1])%MOD;
invfac[i]=(inv(i)*invfac[i-1])%MOD;
scanf("%d",&t1);
if (use[t1]) {
i1=use[t1];
i2=i+1;
}
use[t1]=i+1;
}
// do the counting
mid=i2-i1-1;
printf("%d\n",n);
n++;
for (int i=2; i<=n; i++) {
//printf("i %d\n",i);
// order is BACAD
// some part of BCD
ans=choose(n-2,i);
//printf("BCD %lld\n",ans);
// some part of BACD or BCAD, A mandatory
ans+=choose(n-2,i-1);
ans+=choose(n-2,i-1);
//printf("BACD BCAD %lld\n",ans);
// some part of BAD, A mandatory
ans+=MOD-choose(n-mid-2,i-1);
//printf("BAD %lld\n",ans);
// some part of BACAD, both A mandatory
ans+=choose(n-2,i-2);
//printf("BACAD %lld\n",ans);
printf("%lld\n",ans%MOD;
}
}
| a.cc: In function 'int main()':
a.cc:71:32: error: expected ')' before ';' token
71 | printf("%lld\n",ans%MOD;
| ~ ^
|
s370473686 | p03676 | C++ | #include <type_traits>
#include <utility>
#include <cassert>
#include <iostream>
#include <functional>
#include <vector>
#include <string>
#include <algorithm>
namespace loquat {
template <typename T>
static std::pair<T, T> extended_gcd(T a, T b){
if(b == 0){ return std::pair<T, T>(1, 0); }
const auto p = extended_gcd(b, a % b);
return std::pair<T, T>(p.second, p.first - a / b * p.second);
}
}
namespace loquat {
template <int MOD>
class modulus_integer {
public:
typedef modulus_integer<MOD> self_type;
private:
int m_value;
static self_type unsafe_construct(int x) noexcept {
self_type y;
y.m_value = x;
return y;
}
public:
modulus_integer() noexcept
: m_value(0)
{ }
modulus_integer(int x) noexcept
: m_value(x % MOD)
{
if(m_value < 0){ m_value += MOD; }
}
int operator*() const noexcept { return m_value; }
self_type operator-(const self_type& x) const noexcept {
const int y = m_value - x.m_value;
return unsafe_construct(y < 0 ? y + MOD : y);
}
self_type operator*(const self_type& x) const noexcept {
return unsafe_construct(
static_cast<long long>(m_value) * x.m_value % MOD);
}
self_type operator/(const self_type& x) const {
return (*this) * self_type(extended_gcd(x.m_value, MOD).first);
}
};
template <int MOD>
inline std::ostream& operator<<(
std::ostream& os, const modulus_integer<MOD>& x)
{
os << *x;
return os;
}
template <int MOD>
struct identity<std::plus<modulus_integer<MOD>>> {
static modulus_integer<MOD> value() noexcept {
return modulus_integer<MOD>(0);
}
};
template <int MOD>
struct identity<std::multiplies<modulus_integer<MOD>>> {
static modulus_integer<MOD> value() noexcept {
return modulus_integer<MOD>(1);
}
};
}
namespace loquat {
template <int MOD>
inline modulus_integer<MOD> modulus_factorial(int x){
using mint = modulus_integer<MOD>;
static std::vector<mint> table(1, mint(1));
assert(x >= 0);
while(static_cast<int>(table.size()) <= x){
const int t = static_cast<int>(table.size());
table.push_back(table.back() * mint(t));
}
return table[x];
}
template <int MOD>
inline modulus_integer<MOD> modulus_inv_factorial(int x){
using mint = modulus_integer<MOD>;
static std::vector<mint> table(1, mint(1));
assert(x >= 0);
while(static_cast<int>(table.size()) <= x){
const int t = static_cast<int>(table.size());
table.push_back(table.back() / mint(t));
}
return table[x];
}
template <int MOD>
inline modulus_integer<MOD> modulus_combination(int n, int k){
if(k < 0 || n < k){ return 0; }
const auto a = modulus_factorial<MOD>(n);
const auto b = modulus_inv_factorial<MOD>(n - k);
const auto c = modulus_inv_factorial<MOD>(k);
return a * b * c;
}
template <int MOD>
inline modulus_integer<MOD> modulus_multichoose(int n, int k){
return modulus_combination<MOD>(n + k - 1, k);
}
}
using namespace std;
static const int MOD = 1000000007;
using mint = loquat::modulus_integer<MOD>;
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n + 1), h(n);
for(int i = 0; i <= n; ++i){
cin >> a[i];
--a[i];
++h[a[i]];
}
int dup = 0;
for(int i = 0; i < n; ++i){
if(h[i] == 2){ dup = i; }
}
int left = n, right = 0;
for(int i = 0; i <= n; ++i){
if(a[i] == dup){
left = min(left, i);
right = max(right, i);
}
}
const int mid = n - (left + 1) - (n - right - 1);
for(int i = 1; i <= n + 1; ++i){
const mint x =
loquat::modulus_combination<MOD>(n + 1, i) -
loquat::modulus_combination<MOD>(n - mid, i - 1);
cout << x << endl;
}
return 0;
}
| a.cc:59:8: error: 'identity' is not a class template
59 | struct identity<std::plus<modulus_integer<MOD>>> {
| ^~~~~~~~
a.cc:65:54: error: type/value mismatch at argument 1 in template parameter list for 'template<int MOD> struct loquat::identity'
65 | struct identity<std::multiplies<modulus_integer<MOD>>> {
| ^
a.cc:65:54: note: expected a constant of type 'int', got 'std::multiplies<loquat::modulus_integer<MOD> >'
|
s921162138 | p03677 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
class Parser {
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static final Iterator<String> stringIterator = br.lines().iterator();
private static final Deque<String> inputs = new ArrayDeque<>();
void fill() throws IOException {
if(inputs.isEmpty()){
if(!stringIterator.hasNext()) throw new IOException();
inputs.addAll(Arrays.asList(stringIterator.next().split(" ")));
}
}
Integer parseInt() throws IOException {
fill();
if(!inputs.isEmpty()) {
return Integer.parseInt(inputs.pollFirst());
}
throw new IOException();
}
Double parseDouble() throws IOException {
fill();
if(!inputs.isEmpty()) {
return Double.parseDouble(inputs.pollFirst());
}
throw new IOException();
}
String parseString() throws IOException {
fill();
return inputs.pollFirst();
}
}
public class Main {
public static void main(String[] args) throws IOException {
FastScanner fastScanner = new FastScanner();
int N = fastScanner.nextInt();
int M = fastScanner.nextInt();
int[] a = new int[N];
for(int i = 0; i < N; i++){
a[i] = fastScanner.nextInt();
}
long[] costs = new long[M + 1];
long[] cnts = new long[M + 1];
long costSum = 0;
for(int i = 1; i < N; i++){
if(a[i - 1] < a[i]){
long v = a[i] - a[i - 1];
costs[a[i]] += v;
cnts[a[i - 1]] -= 1;
cnts[a[i]] += 1;
costSum += v;
}else if(a[i - 1] > a[i]){
long v = (M - a[i - 1]) + a[i];
costs[a[i]] += v;
cnts[a[i]] += 1;
costSum += v;
}
}
long answer = costSum;
long cntSum = 0;
long cntAcc = 0;
long currCostSum = 0;
for(int i = M; i >= 1; i--){
cntSum += cnts[i];
cntAcc += cntSum;
currCostSum += costs[i];
long v = costSum + cntAcc - currCostSum;
System.out.printf("%d %d\n", i, v);
answer = Math.min(answer, v);
}
System.out.print(answer);
}
}
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 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;
}
public boolean hasNext() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
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();
}
public 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();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() {
return Double.parseDouble(next());
}
public void close() {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}l | Main.java:190: error: reached end of file while parsing
}l
^
1 error
|
s560300095 | p03677 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 100005;
int n,m,A[MAX_N];
map<int, pair<ll, ll>> sum;
// x[a..b]++ und add[a..b] += c
void magic(int a, int b, int c)
{
if (a > b)
return;
sum[a].first++;
sum[b+1].second--;
sum[a].second += c;
sum[b+1].second -= c;
}
int main()
{
scanf("%d %d",&n,&m);
for (int i=1; i<=n; i++)
scanf("%d",A+i);
ll cost = 0;
for (int i=1; i<n; i++)
{
int a = A[i], b = A[i+1];
cost += (b-a+m)%m;
if (a <= b)
magic(a+1, b, -a-1); // a < x <= b: x - a - 1
else
{
magic(a+1, m, -a-1); // a < x <= m: x - a - 1
magic(1, b, m-a-1); // 1 <= x <= b: m - a + x - 1
}
}
ll sub = 0, px = 0, padd = 0;
for (auto it : sum)
{
sub = max(sub, (it->first-1)*px + padd);
px += it->second.first;
padd += it->second.second;
}
printf("%lld\n", cost - sub);
return 0;
} | a.cc: In function 'int main()':
a.cc:43:35: error: base operand of '->' has non-pointer type 'std::pair<const int, std::pair<long long int, long long int> >'
43 | sub = max(sub, (it->first-1)*px + padd);
| ^~
a.cc:44:25: error: base operand of '->' has non-pointer type 'std::pair<const int, std::pair<long long int, long long int> >'
44 | px += it->second.first;
| ^~
a.cc:45:27: error: base operand of '->' has non-pointer type 'std::pair<const int, std::pair<long long int, long long int> >'
45 | padd += it->second.second;
| ^~
|
s456220463 | p03677 | C++ | #pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define int long long
#define ll long long
//#define int unsigned long long
#define pb push_back
//#define double long double
using namespace std;
using namespace __gnu_pbds;
typedef tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200005;
const int K = 50;
set < int > g1[N], g2[N];
int s1[N], s2[N], a[N], b[N], x[N];
main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++){
cin >> a[i]--;
}
x[1] = a[1];
for (int i = 2; i <= n; i++){
int y;
if (a[i] > a[i - 1]) y = a[i] - a[i - 1]; else
y = m - (a[i - 1] - a[i]);
x[i] = x[i - 1] + y;
}
for (int i = 2; i <= n; i++){
if (x[i - 1] - x[i] == 1) continue;
int l, r;
if (x[i] % m > x[i - 1] % m){
l = x[i - 1] % m + 2;
r = x[i] % m;
} else{
l = x[i - 1] % m + 2;
r = x[i] % m + m;
}
s1[l]++;
s1[r + 1]--;
int d = r - l + 1;
s1[r + 1] += (-d);
s1[r + 2] += d;
}
int xx = 0;
for (int i = 0; i <= m + m + m; i++){
xx += s1[i];
s2[i] = xx;
}
xx = 0;
int ans = 0;
for (int i = 0; i <= m + m + m; i++){
xx += s2[i];
b[i] = xx;
}
for (int i = 0; i < m; i++){
ans = max(ans, b[i] + b[i + m] + b[i + m + m]);
}
// cout << ans << endl;
cout << x[n] - x[1] - ans;
}
| a.cc:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:28:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'long long int')
28 | cin >> a[i]--;
| ~~~ ^~ ~~~~~~
| | |
| | long long int
| std::istream {aka std::basic_istream<char>}
In file included 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:2:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'long long int'
28 | cin >> a[i]--;
| ~~~~^~
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: invalid conversion from 'long long int' to 'void*' [-fpermissive]
28 | cin >> a[i]--;
| ~~~~^~
| |
| long long int
a.cc:28:20: error: cannot bind rvalue '(void*)(a[i]--)' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: invalid conversion from 'long long int' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
28 | cin >> a[i]--;
| ~~~~^~
| |
| long long int
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:28:20: error: invalid conversion from 'long long int' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
28 | cin >> a[i]--;
|
s315258682 | p03677 | C++ | #ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
# include <intrin.h>
# define __builtin_popcount __popcnt
#endif
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
int main()
{
#if defined(_DEBUG)
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cout.tie(NULL);
int n, m;
cin >> n >> m;
vector<int> x(n);
for (int k = 0; k < n; k++)
cin >> x[k];
vector<pair<int, int>> to_right, center;
long long resp = 0;
map<int, long long> residue;
map<int, long long> end_left;
vector<long long> res_best(m + 1);
vector<long long> res_cnt(m + 1);
for (int j = 0; j < n - 1; j++)
{
if (x[j] > x[j + 1])
{
resp += m - x[j] + 1;
residue[x[j + 1]] += m - x[j] + 1;
res_best[x[j + 1]] += m - x[j] + 1;;
res_cnt[x[j + 1]]++;
x[j] = 1;
if (x[j + 1] == 1)
continue;
}
end_left[x[j + 1]] += x[j + 1] - x[j];
to_right.push_back({ x[j], x[j + 1] });
center.push_back({ x[j] + 1, x[j + 1] });
}
sort(center.begin(), center.end(), [&](pair<int, int>& a, pair<int, int>& b) {
return a.first < b.first;
});
vector<long long> sum_right(m + 1);
for (auto x : to_right)
{
sum_right[x.first] += (x.second - x.first);
}
for (int i = sum_right.size() - 1; i > 0; i--)
{
sum_right[i - 1] += sum_right[i];
}
vector<long long> center_balance(m + 2);
map<int, long long> center_sum_left;
for (auto x : center)
{
center_sum_left[x.first] += x.second - x.first + 1;
center_balance[x.first] += 1;
center_balance[x.second + 1] -= 1;
}
for (int j = 1; j <= m; j++)
{
center_balance[j] += center_balance[j - 1];
}
for (int j = m; j > 0; j--)
{
res_best[j - 1] += res_best[j];
res_cnt[j - 1] += res_cnt[j];
}
long long sum_left = 0, sum_center = 0;
long long max_res = 0;
long long best_sum = LLONG_MAX;
for (int f = 1; f <= m; f++)
{
long long curr_sum = resp - res_best[f] + res_cnt[f];
curr_sum += sum_left + sum_right[f];
sum_center += center_sum_left[f];
curr_sum += sum_center;
best_sum = min(best_sum, curr_sum);
sum_center -= center_balance[f];
sum_left += end_left[f];
}
cout << best_sum;
return 0;
} | a.cc: In function 'int main()':
a.cc:113:30: error: 'LLONG_MAX' was not declared in this scope
113 | long long best_sum = LLONG_MAX;
| ^~~~~~~~~
a.cc:23:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
22 | #include <set>
+++ |+#include <climits>
23 |
|
s650523860 | p03677 | C++ | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int arr[MAXN];
int pref[MAXN];
int pref2[MAXN];
int ans;
int res= 1e9;
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
for(int i=1;i<n;i++){
int x = arr[i];
int y = arr[i+1];
if(y<x){
y+=m;
pref[x+2]++;
pref[y+1]--;
pref2[y+1]+=y-x-1;
}else{
pref[x+2]++;
pref[y+1]--;
pref2[y+1]+=y-x-1;
pref[m+x+2]++;
pref[m+y+1]--;
pref2[m+y+1]+=y-x-1;
}
ans+=(y-x);
}
for(int i=1;i<=2*m;i++){
pref[i] += pref[i-1];
pref2[i] += tot[i-1];
pref2[i]-=pref[i];
res = min(res,ans+pref2[i]);
}
cout<<res<<endl;
}
| a.cc: In function 'int main()':
a.cc:38:21: error: 'tot' was not declared in this scope
38 | pref2[i] += tot[i-1];
| ^~~
|
s593243313 | p03677 | C++ | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int arr[MAXN];
int pref[MAXN];
int pref2[MAXN];
int ans;
int res= 1e9;
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
for(int i=1;i<n;i++){
int x = arr[i];
int y = arr[i+1];
if(y<x){
y+=m;
pref[x+2]++;
pref[y+1]--;
pref2[y+1]+=y-x-1;
}else{
pref[x+2]++;
pref[y+1]--;
pref2[y+1]+=y-x-1;
pref[m+x+2]++;
pref[m+y+1]--;
pref2[m+y+1]+=y-x-1;
}
ans+=(y-x);
}
for(int i=1;i<=2*m;i++){
pref[i] += pref[i-1];
tot[i] += tot[i-1];
pref2[i]-=pref[i];
res = min(res,ans+pref2[i]);
}
cout<<res<<endl;
}
| a.cc: In function 'int main()':
a.cc:38:9: error: 'tot' was not declared in this scope
38 | tot[i] += tot[i-1];
| ^~~
|
s113120807 | p03677 | C++ | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int arr[MAXN];
int pref[MAXN];
int tot[MAXN];
int ans;
int res= 1e9;
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
for(int i=1;i<n;i++){
int x = arr[i];
int y = arr[i+1];
if(y<x){
y+=m;
pref[x+2]++;
pref[y+1]--;
tot[y+1]+=y-x-1;
}else{
pref[x+2]++;
pref[y+1]--;
tot[y+1]+=y-x-1;
pref[m+x+2]++;
pref[m+y+1]--;
tot[m+y+1]+=y-x-1;
}
ans+=(y-x);
}
for(int i=1;i<=2*m;i++){
pref[i] += pref[i-1];
tot[i] += tot[i-1];
pref2[i]-=pref[i];
res = min(res,ans+pref2[i]);
}
cout<<res<<endl;
}
| a.cc: In function 'int main()':
a.cc:39:9: error: 'pref2' was not declared in this scope; did you mean 'pref'?
39 | pref2[i]-=pref[i];
| ^~~~~
| pref
|
s387751857 | p03677 | C++ | #include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'
#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */
#include <sstream>
#define debug(args...) { std::string _s = #args; std::replace(_s.begin(), _s.end(), ',', ' '); std::stringstream _ss(_s); std::istream_iterator<std::string> _it(_ss); _err(std::cerr, _it, args); }
#define WHATIS(x) std::cerr << #x << " is " << x << '\n'
template<typename T>
std::ostream& operator<<(std::ostream&o,const std::vector<T>&v) {
o<<'['; for(int i=0;i<v.size();i++) o<<v[i]<<","[i==v.size()-1]; o<<']'; return o;
}
void _err(std::ostream& cerr,std::istream_iterator<std::string> it) { cerr << '\n'; }
template<typename T, typename... Args>
void _err(std::ostream& cerr, std::istream_iterator<std::string> it, T a, Args... args) {
cerr << *it << " = " << a << " ";
_err(cerr,++it, args...);
}
signed main() {
int n,m;
std::cin >> n >> m;
std::vector<int> a(n);
rep(i,n) std::cin >> a[i];
rep(i,n) a[i]--;
std::vector<int> cycle(m,0);
rep(i,n-1) {
int dist = ((a[i+1]-a[i])%m+m)%m;
if(dist<=1) continue;
if((a[i+1]+1)%m>(a[i]+2)%m) {
cycle[(a[i]+2)%m] += 1;
cycle[(a[i+1]+1)%m] -= dist;
if((a[i+1]+2)%m!=0) cycle[(a[i+1]+2)%m] += dist-1;
} else {
cycle[(a[i]+2)%m] += 1;
cycle[0] += m-1-a[i];
cycle[1] -= m-2-a[i];
cycle[(a[i+1]+1)%m] -= dist;
if((a[i+1]+2)%m!=0) cycle[(a[i+1]+2)%m] += dist-1;
}
}
rep(i,m-1) cycle[i+1] += cycle[i];
rep(i,m-1) cycle[i+1] += cycle[i];
int max = 0;
rep(i,m) max = std::max(max,cycle[i]);
int cycles = 0;
rep(i,n-1) {
if(((a[i+1]-a[0])%m+m)%m<((a[i]-a[0])%m+m)%m) cycles++;
}
int count = cycles*m+((a[n-1]-a[0])%m+m)%m;
print(count-max);
return 0;
}
| a.cc:37:30: error: 'std::istream_iterator' has not been declared
37 | void _err(std::ostream& cerr,std::istream_iterator<std::string> it) { cerr << '\n'; }
| ^~~
a.cc:37:51: error: expected ',' or '...' before '<' token
37 | void _err(std::ostream& cerr,std::istream_iterator<std::string> it) { cerr << '\n'; }
| ^
a.cc:39:31: error: 'std::istream_iterator' has not been declared
39 | void _err(std::ostream& cerr, std::istream_iterator<std::string> it, T a, Args... args) {
| ^~~
a.cc:39:52: error: expected ',' or '...' before '<' token
39 | void _err(std::ostream& cerr, std::istream_iterator<std::string> it, T a, Args... args) {
| ^
a.cc: In function 'void _err(std::ostream&, int)':
a.cc:40:14: error: 'it' was not declared in this scope; did you mean 'int'?
40 | cerr << *it << " = " << a << " ";
| ^~
| int
a.cc:40:29: error: 'a' was not declared in this scope
40 | cerr << *it << " = " << a << " ";
| ^
a.cc:41:21: error: 'args' was not declared in this scope; did you mean 'Args'?
41 | _err(cerr,++it, args...);
| ^~~~
| Args
|
s189757535 | p03677 | C++ | #include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}
template<class T> class SegmentTreePointAddRangeSum {
size_t nodeNum; //セグメント木のノードの数
size_t length; //セグメント木にのせるvectorの要素の数
T init; //各ノードの初期値
vector<T> node; //ノード
public:
//vectorで初期化
SegmentTreePointAddRangeSum(const vector<T> & ar, const T init) : length(ar.size()), init(init) {
for (nodeNum = 1; nodeNum < length; nodeNum *= 2);
node.resize(2 * nodeNum - 1, init);
for (int i = 0; i < length; ++i) node[i + nodeNum - 1] = ar[i];
for (int i = nodeNum - 2; i >= 0; --i) node[i] = node[2 * i + 1]+node[2 * i + 2];
}
//lengthだけで初期化
SegmentTreePointAddRangeSum(const size_t length, const T init) : length(length), init(init) {
for (nodeNum = 1; nodeNum < length; nodeNum *= 2);
node.resize(2 * nodeNum - 1, init);
}
void update(size_t idx, const T var) {
idx += (nodeNum - 1);
node[idx] += var;
while (idx > 0) {
idx = (idx - 1) / 2;
node[idx] = node[2 * idx + 1]+node[2 * idx + 2];
}
}
T getvar(const int a, const int b, int k = 0, int l = 0, int r = nodeNum) {
if (r <= a || b <= l) return init;
if (a <= l && r <= b) return node[k];
T vl = getvar(a, b, 2 * k + 1, l, (l + r) / 2);
T vr = getvar(a, b, 2 * k + 2, (l + r) / 2, r);
return vl+vr;
}
void print(){
cout << "{ " << getvar(0,1);
for(int i = 1; i < length; ++i) cout << ", " << getvar(i,i+1);
cout << " }" << endl;
}
};
int main() {
ll n,m; cin >> n >> m;
V<ll> a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
SegmentTreePointAddRangeSum<ll> Seg1(2*m+2,0),Seg2(2*m+2,0),Seg3(2*m+2,0),Seg4(2*m+2,0);
for(int i = 0; i < n-1; ++i) Seg1.update(a[i] - (a[i+1]>a[i]?0:m) + m,1);
for(int i = 0; i < n-1; ++i) Seg2.update(a[i] - (a[i+1]>a[i]?0:m) + m,a[i] - (a[i+1]>a[i]?0:m));
ll sum = 0;
for(int i = 1; i < n; ++i) sum += a[i];
ll ans = sum;
for(int i = 0; i < n-1; ++i) ans -= (a[i] - (a[i+1]>a[i]?0:m) );
V<P<ll,int>> ord;
for(int i = 1; i < n; ++i) ord.push_back({a[i],i});
sort(ALL(ord));
for(auto e:ord){
ll key = e.first;
int idx = e.second;
ll x = Seg1.getvar(0,key+m);
ll y = Seg3.getvar(0,key);
ll cnt = sum - (Seg2.getvar(key+m,2*m+2)+(key-1)*x + Seg4.getvar(key-m + m,2*m+2)+(key-m -1)*y);
chmin(ans,cnt);
ll z = a[idx-1] - (a[idx]>a[idx-1]?0:m);
Seg1.update(z + m,-1);
Seg2.update(z + m,-z);
Seg3.update(z + m, 1);
Seg4.update(z + m, z);
}
cout << ans << endl;
return 0;
}
| a.cc:82:74: error: invalid use of non-static data member 'SegmentTreePointAddRangeSum<T>::nodeNum'
82 | T getvar(const int a, const int b, int k = 0, int l = 0, int r = nodeNum) {
| ^~~~~~~
a.cc:53:16: note: declared here
53 | size_t nodeNum; //セグメント木のノードの数
| ^~~~~~~
|
s567201139 | p03677 | C | #include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
int main(void){
ll n,m;
cin>>n>>m;
ll a;
vector<ll> A;
rep(i,n){
cin>>a;
A.push_back(a);
}
vector<pair<ll,ll>> kukan;//pair<ll,ll> 左端, 右端
rep(i,n-1){
if(A[i] < A[i+1]){
kukan.push_back(pair<ll,ll>{A[i]+m,A[i+1]+m});
kukan.push_back(pair<ll,ll>{A[i],A[i+1]});
}else{
kukan.push_back(pair<ll,ll>{A[i],A[i+1]+m});
kukan.push_back(pair<ll,ll>{A[i]+m,A[i+1]+m*2});
}
}
sort(all(kukan));
//pair<ll,ll> : 右端,左端
priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
ll val = 0;//現在の明るさtを挟む区間の個数
int ki = 0;
ll toku = 0;//お気に入りによって得した量
ll max_toku = 0;
rep(t,2*m+3){
toku += val;
chmax(max_toku, toku);//明るさtをお気に入りにした時に得した量(手数圧縮量) = toku になってる.
while(que.size() > 0 && que.top().first == t){
pair<ll,ll> top = que.top();
val--;
toku -= top.first - top.second - 1;//お気に入りがその区間から外れることで, 今まで得とカウントしてた量は無効
que.pop();
}
while(ki < kukan.size() && kukan[ki].first == t){
que.push(pair<ll,ll>{kukan[ki].second, kukan[ki].first});
val++;
ki++;
toku -= 1;//t+1をお気に入りにしても, まだ得はしないので.
}
//cout<<toku<<" ";
//cout<<que.size()<<" ";
}
//cout<<endl;
ll ans = 0;
rep(i,A.size()-1){//手数圧縮しなかった場合にかかる手数
if(A[i] < A[i+1]) ans += A[i+1] - A[i];
else ans += A[i+1] - A[i] + m;
}
ans -= max_toku;
cout<<ans<<endl;
//cout<<toku<<endl;
//cout<<max_toku<<endl;
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s823402445 | p03677 | C++ |
#include <bits/stdc++.h>
#define null ""
#define endl '\n'
#define all(dat) dat.begin(), dat.end()
#define loop(i, to) for (num i = 0; i < to; ++i)
#define cont(i, to) for (num i = 1; i <= to; ++i)
#define circ(i, fr, to) for (num i = fr; i <= to; ++i)
#define foreach(i, dat) for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
typedef long long num;
using namespace std;
const num nsz = 1e5, inf = 0x3f3f3f3f;
num n, m, ans = inf;
struct segment_tree {
num tr[4 * nsz + 5], fi[4 * nsz + 5], del[4 * nsz + 5];
void inline up(num u) {
tr[u] = tr[u << 1] + tr[u << 1 | 1];
}
void inline down(num u, num l, num r) {
if (!fi[u] && !del[u]) return;
num ls = u << 1, rs = u << 1 | 1, mid = (l + r) >> 1;
num fl = fi[u], fr = fi[u] + (mid - l + 1) * del[u], el = fl + (mid - l) * del[u], er = fr + (r - mid - 1) * del[u];
tr[ls] += (fl + el) * (mid - l + 1) / 2;
tr[rs] += (fr + er) * (r - mid) / 2;
fi[ls] += fi[u];
fi[rs] += fi[u] + (mid - l + 1) * del[u];
del[ls] += del[u];
del[rs] += del[u];
fi[u] = del[u] = 0;
}
void upd(num el, num er, num f, num de, num u = 1, num l = 1, num r = m) {
if (l >= el && r <= er) {
tr[u] += (f + f + (r - l) * de) * (r - l + 1) / 2;
fi[u] += f;
del[u] += de;
return;
}
down(u, l, r);
num mid = (l + r) >> 1;
if (el <= mid) {
upd(el, er, f, de, u << 1, l, mid);
}
if (er >= mid + 1) {
upd(el, er, f + (mid - l + 1) * de, de, u << 1 | 1, mid + 1, r);
}
up(u);
}
num qry(num el, num er, num u = 1, num l = 1, num r = m) {
if (l >= el && r <= er) return tr[u];
down(u, l, r);
num mid = (l + r) >> 1, res = 0;
if (el <= mid) {
res += qry(el, er, u << 1, l, mid);
}
if (er >= mid + 1) {
res += qry(el, er, u << 1 | 1, mid + 1, r);
}
return res;
}
};
segment_tree tr;
num inline read() {
num f = 1, res = 0;
char c = getchar();
for (; !isdigit(c); f = c == '-' ? -1 : 1, c = getchar());
for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar());
return f * res;
}
num inline calc(num l, num r) {
return l > r ? r + m - l : r - l;
}
bool inline chk(num pos) {
return pos >= 1 && pos <= m;
}
int main() {
n = read();
m = read();
num pre = read(), cur;
cont (i, n - 1) {
cur = read();
num mx = calc(pre, cur), pos = cur, l = 1, r = pos - mx + 1, f;
// cout << "mx: " << mx << endl;
// cout << 1 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, mx, 0);
}
l = pos + 1;
r = min(m, pos + m - mx + 1);
// cout << 2 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, mx, 0);
}
l = max(1, pos - mx + 2);
r = pos;
f = 1 + (pos - l);
// cout << 3 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, f + (l - 1), -1);
}
l = pos + m - mx + 2;
r = m;
f = m;
// cout << 4 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, f + (l - 1), -1);
}
// cont (i, m) {
// cout << tr.qry(i, i) << ' ';
// }
// cout << endl;
pre = cur;
}
cont (i, m) {
ans = min(ans, tr.qry(i, i));
}
cout << ans << endl;
}
//4 6
//1 5 1 4
| a.cc: In function 'int main()':
a.cc:106:16: error: no matching function for call to 'max(int, num)'
106 | l = max(1, pos - mx + 2);
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:106:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'num' {aka 'long long int'})
106 | l = max(1, pos - mx + 2);
| ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:106:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
106 | l = max(1, pos - mx + 2);
| ~~~^~~~~~~~~~~~~~~~~
|
s116131694 | p03677 | C++ |
#include <bits/stdc++.h>
#define null ""
#define endl '\n'
#define all(dat) dat.begin(), dat.end()
#define loop(i, to) for (num i = 0; i < to; ++i)
#define cont(i, to) for (num i = 1; i <= to; ++i)
#define circ(i, fr, to) for (num i = fr; i <= to; ++i)
#define foreach(i, dat) for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)
typedef long long num;
using namespace std;
const num nsz = 1e5, inf = 0x3f3f3f3f;
num n, m, ans = inf;
struct segment_tree {
num tr[4 * nsz + 5], fi[4 * nsz + 5], del[4 * nsz + 5];
void inline up(num u) {
tr[u] = tr[u << 1] + tr[u << 1 | 1];
}
void inline down(num u, num l, num r) {
if (!fi[u] && !del[u]) return;
num ls = u << 1, rs = u << 1 | 1, mid = (l + r) >> 1;
num fl = fi[u], fr = fi[u] + (mid - l + 1) * del[u], el = fl + (mid - l) * del[u], er = fr + (r - mid - 1) * del[u];
tr[ls] += (fl + el) * (mid - l + 1) / 2;
tr[rs] += (fr + er) * (r - mid) / 2;
fi[ls] += fi[u];
fi[rs] += fi[u] + (mid - l + 1) * del[u];
del[ls] += del[u];
del[rs] += del[u];
fi[u] = del[u] = 0;
}
void upd(num el, num er, num f, num de, num u = 1, num l = 1, num r = m) {
if (l >= el && r <= er) {
tr[u] += (f + f + (r - l) * de) * (r - l + 1) / 2;
fi[u] += f;
del[u] += de;
return;
}
down(u, l, r);
num mid = (l + r) >> 1;
if (el <= mid) {
upd(el, er, f, de, u << 1, l, mid);
}
if (er >= mid + 1) {
upd(el, er, f + (mid - l + 1) * de, de, u << 1 | 1, mid + 1, r);
}
up(u);
}
num qry(num el, num er, num u = 1, num l = 1, num r = m) {
if (l >= el && r <= er) return tr[u];
down(u, l, r);
num mid = (l + r) >> 1, res = 0;
if (el <= mid) {
res += qry(el, er, u << 1, l, mid);
}
if (er >= mid + 1) {
res += qry(el, er, u << 1 | 1, mid + 1, r);
}
return res;
}
};
segment_tree tr;
num inline read() {
num f = 1, res = 0;
char c = getchar();
for (; !isdigit(c); f = c == '-' ? -1 : 1, c = getchar());
for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar());
return f * res;
}
num inline calc(num l, num r) {
return l > r ? r + m - l : r - l;
}
bool inline chk(num pos) {
return pos >= 1 && pos <= m;
}
int main() {
n = read();
m = read();
num pre = read(), cur;
cont (i, n - 1) {
cur = read();
num mx = calc(pre, cur), pos = cur, l = 1, r = pos - mx + 1, f;
// cout << "mx: " << mx << endl;
// cout << 1 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, mx, 0);
}
l = pos + 1;
r = min(m, pos + m - mx + 1);
// cout << 2 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, mx, 0);
}
l = max(1, pos - mx + 2);
r = pos;
f = 1 + (pos - l);
// cout << 3 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, f + (l - 1), -1);
}
l = pos + m - mx + 2;
r = m;
f = m;
// cout << 4 << ' ' << l << ' ' << r << endl;
if (l <= r && chk(l) && chk(r)) {
tr.upd(l, r, f + (l - 1), -1);
}
// cont (i, m) {
// cout << tr.qry(i, i) << ' ';
// }
// cout << endl;
pre = cur;
}
cont (i, m) {
ans = min(ans, tr.qry(i, i));
}
cout << ans << endl;
}
//4 6
//1 5 1 4
| a.cc: In function 'int main()':
a.cc:106:16: error: no matching function for call to 'max(int, num)'
106 | l = max(1, pos - mx + 2);
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:106:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'num' {aka 'long long int'})
106 | l = max(1, pos - mx + 2);
| ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:106:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
106 | l = max(1, pos - mx + 2);
| ~~~^~~~~~~~~~~~~~~~~
|
s676097461 | p03677 | C++ | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;cin>>n>>m;
vector<ll> a(n),imos(m+10,0);
map<ll,ll> mp;
for(int i=0;i<n;i++){
cin>>a[i];
a[i]--;
}
ll cnt=0; // x=0 の時のコスト
for(int i=1;i<n;i++){
cnt += min((a[i]+m-a[i-1])%m, 1+a[i]);
if(a[i-1]<a[i]){
if(a[i]-a[i-1]>=3){
imos[a[i-1]+2]++;
imos[a[i]+1]--;
}
}
else{
imos[a[i-1]+2]++;
imos[0]++;
imos[a[i]+1]--;
}
mp[a[i]+1] += (a[i]+m-a[i-1])%m -1;
}
for(int i=1;i<=m;i++){
imos[i] += imos[i-1];
}
for(int i=1;i<m;i++){
cnt -= imos[i];
cnt += mp[i];
res=min(res,cnt);
}
cout<<res<<endl;
}
| a.cc: In function 'int main()':
a.cc:40:9: error: 'res' was not declared in this scope
40 | res=min(res,cnt);
| ^~~
a.cc:42:11: error: 'res' was not declared in this scope
42 | cout<<res<<endl;
| ^~~
|
s302995735 | p03677 | C++ | #include <iostream>
#include <algorithm>
#include <array>
#include <numeric>
using namespace std;
const int maxn = 3e5 + 1e2;
using ll = long long;
array<int, maxn> a;
array<ll, maxn> p;
int n, m;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll tot = 0;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 1; i < n; ++i) {
int l = a[i - 1], r = a[i];
r += (l > r) * m;
tot += r - l;
if (r - l > 1) {
++p[l + 2];
p[r + 1] -= (r - (l + 2) + 1) + 1;
p[r + 2] += (r - (l + 2) + 1);
}
}
partial_sum(p.begin() + 1, p.begin() + 2 * m + 1, p);
partial_sum(p.begin() + 1, p.begin() + 2 * m + 1, p);
ll ans = 0;
for (int i = 1; i <= m; ++i) ans = max(ans, p[i] + p[i + m]);
cout << tot - ans << endl;
} | In file included from /usr/include/c++/14/numeric:62,
from a.cc:4:
/usr/include/c++/14/bits/stl_numeric.h: In instantiation of '_OutputIterator std::partial_sum(_InputIterator, _InputIterator, _OutputIterator) [with _InputIterator = long long int*; _OutputIterator = array<long long int, 300100>]':
a.cc:31:16: required from here
31 | partial_sum(p.begin() + 1, p.begin() + 2 * m + 1, p);
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:270:7: error: no match for 'operator*' (operand type is 'std::array<long long int, 300100>')
270 | *__result = __value;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:274:12: error: no match for 'operator++' (operand type is 'std::array<long long int, 300100>')
274 | *++__result = __value;
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:276:14: error: no match for 'operator++' (operand type is 'std::array<long long int, 300100>')
276 | return ++__result;
| ^~~~~~~~~~
|
s870101693 | p03677 | C++ | #include<iostream>
using namespace std;
const int N=100100;
long long n,m,t3,t4,a[N*2],sum;
long long ans;
int main()
{
ios::sync_with_stdio(false);
cin>>n>>m>>t3;
for(int i=2;i<=n;++i)
{
int d,t1,t2;
cin>>t4;
t1=t3;t2=t4;
if(t2<t1) t2+=m;
d=t2-t1;
ans+=d;
if(d>1)
{
a[t1+2]++;
a[t2+1]-=d;
a[t2+2]+=d-1;
}
t3=t4;
}
sum=0;
for(int i=1;i<=2*m;++i)
{
sum+=a[i];
a[i]=sum;
}
sum=0;
int maxx=0;
for(int i=1;i<=2*m;++i)
{
sum+=a[i];
a[i]=sum;
}
for(int i=m+1;i<=2*m;++i)
{
a[i-m]+=a[i];
maxx=max(a[i-m],maxx);
}
cout<<ans-maxx<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:42:17: error: no matching function for call to 'max(long long int&, int&)'
42 | maxx=max(a[i-m],maxx);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:42:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
42 | maxx=max(a[i-m],maxx);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
|
s172723609 | p03677 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll
#define int ll;
int m,n;
int a[100010];
struct LazySegmentTree {
private:
int n;
vector<ll> node, lazy;
public:
LazySegmentTree(const vector<ll>& v) {
int sz = (int)v.size();
n = 1; while(n < sz) n *= 2;
node.resize(2*n-1);
lazy.resize(2*n-1, 0);
for(int i=0; i<sz; i++) node[i+n-1] = v[i];
for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
}
void eval(int k, int l, int r) {
if(lazy[k] != 0) {
node[k] += lazy[k];
if(r - l > 1) {
lazy[2*k+1] += lazy[k] / 2;
lazy[2*k+2] += lazy[k] / 2;
}
lazy[k] = 0;
}
}
void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
if(r < 0) r = n;
eval(k, l, r);
if(b <= l || r <= a) return;
if(a <= l && r <= b) {
lazy[k] += (r - l) * x;
eval(k, l, r);
}
else {
add_inter(a, b, x, 2*k+1, l, (l+r)/2);
add_inter(a, b, x, 2*k+2, (l+r)/2, r);
node[k] = node[2*k+1] + node[2*k+2];
}
}
ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
if(r < 0) r = n;
eval(k, l, r);
if(b <= l || r <= a) return 0;
if(a <= l && r <= b) return node[k];
ll vl = get_inter(a, b, 2*k+1, l, (l+r)/2);
ll vr = get_inter(a, b, 2*k+2, (l+r)/2, r);
return vl + vr;
}
};
signed main()
{
cin >> n >> m;
for(int i = 0;i < n;i++)
{
cin >> a[i];
a[i]--;
}
int sum = 0;
LazySegmentTree seg(vector<ll>(3 * m,0LL));
for(int i = 1;i < n;i++)
{
int from = a[i - 1];
int to = a[i];
if(from > to) to += m;
//from < to
int dist = (to - from)% m;
sum += dist;
to = a[i] + 1;
from = a[i] - (dist - 1) + 1;
if(from < 0)
{
}
else
{
seg.add_inter(from , to,1);
seg.add_inter(to,to + 1,-(dist - 1));
}
from += m;
to += m;
seg.add_inter(from , to,1);
seg.add_inter(to,to + 1,-(dist - 1));
}
ll minus = 0;
for(int i = 0;i < 2 * m;i++)
{
minus = max(minus , seg.get_inter(0,i));
}
cout << sum - minus << endl;
}
| a.cc:8:13: error: expected initializer before 'll'
8 | #define int ll;
| ^~
a.cc:11:1: note: in expansion of macro 'int'
11 | int m,n;
| ^~~
a.cc:11:5: error: 'm' does not name a type; did you mean 'tm'?
11 | int m,n;
| ^
| tm
a.cc:8:13: error: 'll' does not name a type
8 | #define int ll;
| ^~
a.cc:12:1: note: in expansion of macro 'int'
12 | int a[100010];
| ^~~
a.cc:12:5: error: 'a' does not name a type
12 | int a[100010];
| ^
a.cc:8:13: error: 'll' does not name a type
8 | #define int ll;
| ^~
a.cc:18:5: note: in expansion of macro 'int'
18 | int n;
| ^~~
a.cc:18:9: error: 'n' does not name a type
18 | int n;
| ^
a.cc:19:12: error: 'll' was not declared in this scope
19 | vector<ll> node, lazy;
| ^~
a.cc:19:14: error: template argument 1 is invalid
19 | vector<ll> node, lazy;
| ^
a.cc:19:14: error: template argument 2 is invalid
a.cc:22:34: error: 'll' was not declared in this scope
22 | LazySegmentTree(const vector<ll>& v) {
| ^~
a.cc:22:36: error: template argument 1 is invalid
22 | LazySegmentTree(const vector<ll>& v) {
| ^
a.cc:22:36: error: template argument 2 is invalid
a.cc:8:13: error: 'll' has not been declared
8 | #define int ll;
| ^~
a.cc:32:15: note: in expansion of macro 'int'
32 | void eval(int k, int l, int r) {
| ^~~
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:32:15: note: in expansion of macro 'int'
32 | void eval(int k, int l, int r) {
| ^~~
a.cc:32:14: note: to match this '('
32 | void eval(int k, int l, int r) {
| ^
a.cc:32:19: error: 'k' does not name a type
32 | void eval(int k, int l, int r) {
| ^
a.cc:32:26: error: 'l' does not name a type
32 | void eval(int k, int l, int r) {
| ^
a.cc:32:33: error: 'r' does not name a type
32 | void eval(int k, int l, int r) {
| ^
a.cc:8:13: error: 'll' has not been declared
8 | #define int ll;
| ^~
a.cc:43:20: note: in expansion of macro 'int'
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^~~
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:43:20: note: in expansion of macro 'int'
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^~~
a.cc:43:19: note: to match this '('
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:24: error: 'a' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:31: error: 'b' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:44: error: 'k' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:53: error: 'l' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:62: error: 'r' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:5: error: 'll' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^~
a.cc:58:22: error: 'a' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:29: error: 'b' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:36: error: 'k' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:45: error: 'l' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:54: error: 'r' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc: In constructor 'LazySegmentTree::LazySegmentTree(const int&)':
a.cc:8:13: error: 'll' was not declared in this scope
8 | #define int ll;
| ^~
a.cc:23:9: note: in expansion of macro 'int'
23 | int sz = (int)v.size();
| ^~~
a.cc:23:13: error: 'sz' was not declared in this scope
23 | int sz = (int)v.size();
| ^~
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:23:19: note: in expansion of macro 'int'
23 | int sz = (int)v.size();
| ^~~
a.cc:23:18: note: to match this '('
23 | int sz = (int)v.size();
| ^
a.cc:23:22: error: expected primary-expression before ')' token
23 | int sz = (int)v.size();
| ^
a.cc:24:9: error: 'n' was not declared in this scope
24 | n = 1; while(n < sz) n *= 2;
| ^
a.cc:25:14: error: request for member 'resize' in '((LazySegmentTree*)this)->LazySegmentTree::node', which is of non-class type 'int'
25 | node.resize(2*n-1);
| ^~~~~~
a.cc:26:14: error: request for member 'resize' in '((LazySegmentTree*)this)->LazySegmentTree::lazy', which is of non-class type 'int'
26 | lazy.resize(2*n-1, 0);
| ^~~~~~
a.cc:28:17: error: 'i' was not declared in this scope
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:28:26: error: expected ')' before ';' token
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:28:12: note: to match this '('
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:28:28: error: 'i' was not declared in this scope
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:29:28: error: expected ')' before ';' token
29 | for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
| ^
a.cc:29:12: note: to match this '('
29 | for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
| ^
a.cc: In function 'int main()':
a.cc:71:16: error: 'n' was not declared in this scope
71 | cin >> n >> m;
| ^
a.cc:71:21: error: 'm' was not declared in this scope; did you mean 'tm'?
71 | cin >> n >> m;
| ^
| tm
a.cc:8:13: error: 'll' was not declared in this scope
8 | #define int ll;
| ^~
a.cc:73:13: note: in expansion of macro 'int'
73 | for(int i = 0;i < n;i++)
| ^~~
a.cc:73:17: error: 'i' was not declared in this scope
73 | for(int i = 0;i < n;i++)
| ^
a.cc:73:28: error: expected ')' before ';' token
73 | for(int i = 0;i < n;i++)
| ~ ^
| )
a.cc:73:29: error: 'i' was not declared in this scope
73 | for(int i = 0;i < n;i++)
| ^
a.cc:8:13: error: 'll' was not declared in this scope
8 | #define int ll;
| ^~
a.cc:79:9: note: in expansion of macro 'int'
79 | int sum = 0;
| ^~~
a.cc:79:13: error: 'sum' was not declared in this scope
79 | int sum = 0;
| ^~~
a.cc:81:38: error: template argument 2 is invalid
81 | LazySegmentTree seg(vector<ll>(3 * m,0LL));
| ^
a.cc:83:28: error: expected ')' before ';' token
83 | for(int i = 1;i < n;i++)
| ~ ^
| )
a.cc:117:11: error: expected ';' before 'minus'
117 | ll minus = 0;
| ^~~~~~
| ;
a.cc:119:32: error: expected ')' before ';' token
119 | for(int i = 0;i < 2 * m;i++)
| ~ ^
| )
a.cc:124:29: error: missing template arguments before '<<' token
124 | cout << sum - minus << endl;
| ^~
|
s651524870 | p03677 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define int ll;
int m,n;
int a[100010];
struct LazySegmentTree {
private:
int n;
vector<ll> node, lazy;
public:
LazySegmentTree(const vector<ll>& v) {
int sz = (int)v.size();
n = 1; while(n < sz) n *= 2;
node.resize(2*n-1);
lazy.resize(2*n-1, 0);
for(int i=0; i<sz; i++) node[i+n-1] = v[i];
for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
}
void eval(int k, int l, int r) {
if(lazy[k] != 0) {
node[k] += lazy[k];
if(r - l > 1) {
lazy[2*k+1] += lazy[k] / 2;
lazy[2*k+2] += lazy[k] / 2;
}
lazy[k] = 0;
}
}
void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
if(r < 0) r = n;
eval(k, l, r);
if(b <= l || r <= a) return;
if(a <= l && r <= b) {
lazy[k] += (r - l) * x;
eval(k, l, r);
}
else {
add_inter(a, b, x, 2*k+1, l, (l+r)/2);
add_inter(a, b, x, 2*k+2, (l+r)/2, r);
node[k] = node[2*k+1] + node[2*k+2];
}
}
ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
if(r < 0) r = n;
eval(k, l, r);
if(b <= l || r <= a) return 0;
if(a <= l && r <= b) return node[k];
ll vl = get_inter(a, b, 2*k+1, l, (l+r)/2);
ll vr = get_inter(a, b, 2*k+2, (l+r)/2, r);
return vl + vr;
}
};
signed main()
{
cin >> n >> m;
for(int i = 0;i < n;i++)
{
cin >> a[i];
a[i]--;
}
int sum = 0;
LazySegmentTree seg(vector<ll>(3 * m,0LL));
for(int i = 1;i < n;i++)
{
int from = a[i - 1];
int to = a[i];
if(from > to) to += m;
//from < to
int dist = (to - from)% m;
sum += dist;
to = a[i] + 1;
from = a[i] - (dist - 1) + 1;
if(from < 0)
{
}
else
{
seg.add_inter(from , to,1);
seg.add_inter(to,to + 1,-(dist - 1));
}
from += m;
to += m;
seg.add_inter(from , to,1);
seg.add_inter(to,to + 1,-(dist - 1));
}
ll minus = 0;
for(int i = 0;i < 2 * m;i++)
{
minus = max(minus , seg.get_inter(0,i));
}
cout << sum - minus << endl;
}
| a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:11:1: note: in expansion of macro 'int'
11 | int m,n;
| ^~~
a.cc:11:5: error: 'm' does not name a type; did you mean 'tm'?
11 | int m,n;
| ^
| tm
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:12:1: note: in expansion of macro 'int'
12 | int a[100010];
| ^~~
a.cc:12:5: error: 'a' does not name a type
12 | int a[100010];
| ^
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:18:5: note: in expansion of macro 'int'
18 | int n;
| ^~~
a.cc:18:9: error: 'n' does not name a type
18 | int n;
| ^
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:32:15: note: in expansion of macro 'int'
32 | void eval(int k, int l, int r) {
| ^~~
a.cc:32:14: note: to match this '('
32 | void eval(int k, int l, int r) {
| ^
a.cc:32:19: error: 'k' does not name a type
32 | void eval(int k, int l, int r) {
| ^
a.cc:32:26: error: 'l' does not name a type; did you mean 'll'?
32 | void eval(int k, int l, int r) {
| ^
| ll
a.cc:32:33: error: 'r' does not name a type
32 | void eval(int k, int l, int r) {
| ^
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:43:20: note: in expansion of macro 'int'
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^~~
a.cc:43:19: note: to match this '('
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:24: error: 'a' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:31: error: 'b' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:44: error: 'k' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:43:53: error: 'l' does not name a type; did you mean 'll'?
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
| ll
a.cc:43:62: error: 'r' does not name a type
43 | void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
| ^
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:58:18: note: in expansion of macro 'int'
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^~~
a.cc:58:17: note: to match this '('
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:22: error: 'a' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:29: error: 'b' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:36: error: 'k' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc:58:45: error: 'l' does not name a type; did you mean 'll'?
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
| ll
a.cc:58:54: error: 'r' does not name a type
58 | ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
| ^
a.cc: In constructor 'LazySegmentTree::LazySegmentTree(const std::vector<long long int>&)':
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:23:9: note: in expansion of macro 'int'
23 | int sz = (int)v.size();
| ^~~
a.cc:23:13: error: 'sz' was not declared in this scope
23 | int sz = (int)v.size();
| ^~
a.cc:8:15: error: expected primary-expression before ';' token
8 | #define int ll;
| ^
a.cc:23:19: note: in expansion of macro 'int'
23 | int sz = (int)v.size();
| ^~~
a.cc:8:15: error: expected ')' before ';' token
8 | #define int ll;
| ^
a.cc:23:19: note: in expansion of macro 'int'
23 | int sz = (int)v.size();
| ^~~
a.cc:23:18: note: to match this '('
23 | int sz = (int)v.size();
| ^
a.cc:23:22: error: expected primary-expression before ')' token
23 | int sz = (int)v.size();
| ^
a.cc:24:9: error: 'n' was not declared in this scope
24 | n = 1; while(n < sz) n *= 2;
| ^
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:28:13: note: in expansion of macro 'int'
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^~~
a.cc:28:17: error: 'i' was not declared in this scope
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:28:26: error: expected ')' before ';' token
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:28:12: note: to match this '('
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:28:28: error: 'i' was not declared in this scope
28 | for(int i=0; i<sz; i++) node[i+n-1] = v[i];
| ^
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:29:13: note: in expansion of macro 'int'
29 | for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
| ^~~
a.cc:29:28: error: expected ')' before ';' token
29 | for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
| ^
a.cc:29:12: note: to match this '('
29 | for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
| ^
a.cc: In function 'int main()':
a.cc:71:16: error: 'n' was not declared in this scope
71 | cin >> n >> m;
| ^
a.cc:71:21: error: 'm' was not declared in this scope; did you mean 'tm'?
71 | cin >> n >> m;
| ^
| tm
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:73:13: note: in expansion of macro 'int'
73 | for(int i = 0;i < n;i++)
| ^~~
a.cc:73:17: error: 'i' was not declared in this scope
73 | for(int i = 0;i < n;i++)
| ^
a.cc:73:28: error: expected ')' before ';' token
73 | for(int i = 0;i < n;i++)
| ~ ^
| )
a.cc:73:29: error: 'i' was not declared in this scope
73 | for(int i = 0;i < n;i++)
| ^
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:79:9: note: in expansion of macro 'int'
79 | int sum = 0;
| ^~~
a.cc:79:13: error: 'sum' was not declared in this scope
79 | int sum = 0;
| ^~~
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:83:13: note: in expansion of macro 'int'
83 | for(int i = 1;i < n;i++)
| ^~~
a.cc:83:28: error: expected ')' before ';' token
83 | for(int i = 1;i < n;i++)
| ~ ^
| )
a.cc:8:13: error: declaration does not declare anything [-fpermissive]
8 | #define int ll;
| ^~
a.cc:119:13: note: in expansion of macro 'int'
119 | for(int i = 0;i < 2 * m;i++)
| ^~~
a.cc:119:32: error: expected ')' before ';' token
119 | for(int i = 0;i < 2 * m;i++)
| ~ ^
| )
|
s585845001 | p03677 | C++ | #include <bits/stdc++.h>
using namespace std;
//#define FILE_IO
int \, M;
int v[100005];
class BinaryIndexedTree
{
public:
int aib[100005];
void U(int pos, int val)
{
for(; pos <= M; pos += (pos & (-pos)))
aib[pos] += val;
}
void update(int st, int dr, int val)
{
if(st > dr) return;
U(st, val);
U(dr + 1, -val);
}
int Q(int pos)
{
int ans = 0;
for(; pos > 0; pos -= (pos &(-pos)))
ans += aib[pos];
return ans;
}
}A, B;
int main()
{
#ifdef FILE_IO
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
scanf("%d%d", &N, &M);
for(int i = 1; i <= N; i++)
scanf("%d", &v[i]);
for(int u = 1; u < N; u++)
{
int p1 = v[u];
int p2 = v[u + 1];
if(p1 < p2)
{
B.update(1, p1, p2 - p1);
A.update(p1 + 1, p2, -1);
B.update(p1 + 1, p2, p2 + 1);
B.update(p2 + 1, M, p2 - p1);
}
else
{
A.update(1, p2, -1);
B.update(1, p2, p2 + 1);
B.update(p2 + 1, p1, M - p1 + p2);
A.update(p1 + 1, M, -1);
B.update(p1 + 1, M, M + p2);
}
}
int mn = 1 << 30;
for(int i = 1; i <= M; i++)
{
int x = A.Q(i) * i + B.Q(i);
mn = min(mn, x);
}
printf("%d\n", mn);
return 0;
}
| a.cc:7:5: error: stray '\' in program
7 | int \, M;
| ^
a.cc:7:6: error: expected unqualified-id before ',' token
7 | int \, M;
| ^
a.cc: In function 'int main()':
a.cc:44:20: error: 'N' was not declared in this scope
44 | scanf("%d%d", &N, &M);
| ^
|
s619408963 | p03677 | C++ | 10 10
10 9 8 7 6 5 4 3 2 1 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10 10
| ^~
|
s880392321 | p03677 | C++ | 10 10
10 9 8 7 6 5 4 3 2 1 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10 10
| ^~
|
s389472028 | p03677 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
int main(){
// freopen("test.txt", "r", stdin);
LL n, m, pre, now;
scanf("%lld%lld%lld", &n, &m, &pre);
vector<LL> a(m+2, 0);
vector<LL> b(m+2, 0);
for (int i = 1; i < n; i++) {
scanf("%lld", &now);
if (now > pre) {
b[1] += now - pre;
b[pre + 1] -= now - pre;
b[now + 1] += now - pre;
a[pre+1] -= 1;
a[now+1] += 1;
b[pre + 1] += now + 1;
b[now + 1] -= now - 1;
}
else { // now < pre
b[now + 1] += now - pre + m;
b[pre + 1] -= now - pre + m;
a[1] -= 1;
a[now + 1] += 1;
b[1] += now + 1;
b[now + 1] -= now + 1;
a[pre + 1] -= 1;
b[pre + 1] += now + m + 1;
}
pre = now;
}
LL ret = INT_MAX;
for (int i = 1; i <= m; i++) {
a[i] += a[i-1];
b[i] += b[i-1];
ret = min(a[i]*(LL)i + b[i], ret);
}
cout << ret << endl;
} | a.cc: In function 'int main()':
a.cc:38:14: error: 'INT_MAX' was not declared in this scope
38 | LL ret = INT_MAX;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <algorithm>
+++ |+#include <climits>
4 |
|
s448783025 | p03677 | C++ | #include <iostream>
using namespace std;
const int MAXM=100010;
int m,n;
int segment[MAXM*2];
int segexit[MAXM*2];
int gensum[MAXM*2];
int main() {
memset(segment,0,sizeof(segment));
memset(segexit,0,sizeof(segexit));
int result = 0;
cin>>n>>m;
int last; cin>>last;
for (int i=1,now;i<n;i++,last=(now-1)%6+1) {
cin>>now;
if (now<last) now+=6;
result += now-last;
segment[last+2]++;
segment[now+1]--;
segexit[now] += now-last-1;
}
memset(gensum,0,sizeof(gensum));
for (int i=0,step=0,last=0;i<=m*2;i++) {
step += segment[i];
last += step;
gensum[i] += last;
last -= segexit[i];
}
int mmax=0;
for (int i=1;i<=m;i++) {
int tt = gensum[i]+gensum[i+m];
if (tt>mmax)
mmax = tt;
}
cout<<result-mmax<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:10:9: error: 'memset' was not declared in this scope
10 | memset(segment,0,sizeof(segment));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s457538634 | p03677 | C++ | #include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[100005];
long long s[200005];
int main(){
scanf("%d%d", &n, &m);
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
a[i]--;
}
long long tot = 0;
for(i = 1; i < n; i++){
int l = a[i - 1];
int r = a[i];
if(l <= r){
s[l + 2]++;
s[r + 1]--;
s[r + 1] -= r - l - 1;
s[r + 2] += r - l - 1;
}
else{
r += m;
s[l + 2]++;
s[r + 1]--;
s[r + 1] -= r - l - 1;
s[r + 2] += r - l - 1;
}
tot += r - l;
}
for(i = 1; i < 2 * m; i++)
s[i] = s[i - 1] + s[i];
for(i = 1; i < 2 * m; i++)
s[i] = s[i - 1] + s[i];
long long res = 1e18;
for(i = 0; i < m; i++)
res = min(res, tmp - (s[i] + s[i + m]));
printf("%lld\n", res);
}
| a.cc: In function 'int main()':
a.cc:47:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
47 | res = min(res, tmp - (s[i] + s[i + m]));
| ^~~
| tm
|
s466189341 | p03677 | C++ | #include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>
using namespace std;
#define MP make_pair
#define PB push_back
#define INF (1000000007)
#define eps 1e-8
typedef pair<int,int> pii ;
typedef long long ll ;
int n,m;
int l[100005];
pair<ll,ll> p[100005],p2[100005]; //<?x,?>
inline void update(ll a,l b)
{
if(b>a)
{
p[b+1].second+=b-a;
p[a+1].first--;
p[a+1].second+=b+1;
p[b+1].first++;
p[b+1].second-=b+1;
p[1].second+=b-a;
p[a+1].second-=b-a;
}
else
{
p[a+1].first--;
p[a+1].second+=b+1+m;
p[b+1].second+=m-a+b;
p[a+1].second-=m-a+b;
p[1].first--;
p[1].second+=b+1;
p[b+1].first++;
p[b+1].second-=b+1;
}
}
int main()
{
ll ans=1e18+7;
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>l[i];
for(int i=2;i<=n;i++)
{
update((ll)l[i-1],(ll)l[i]);
// memset(p2,0,sizeof(p2));
// p2[1]=p[1];
// for(int j=2;j<=m;j++)
// {
// p2[j].first=p2[j-1].first+p[j].first;
// p2[j].second=p2[j-1].second+p[j].second;
// }
// for(int j=1;j<=m;j++) cout<<p2[j].first<<" "<<p2[j].second<<endl;
// system("pause");
}
for(int i=2;i<=m;i++)
{
p[i].first+=p[i-1].first;
p[i].second+=p[i-1].second;
}
for(int i=1;i<=m;i++) ans=min(ans,p[i].first*(ll)i+p[i].second);
cout<<ans;
return 0;
} | a.cc:31:25: error: 'l' is not a type
31 | inline void update(ll a,l b)
| ^
|
s063542025 | p03677 | C++ | #include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>
using namespace std;
#define MP make_pair
#define PB push_back
#define INF (1000000007)
#define eps 1e-8
typedef pair<int,int> pii ;
typedef long long ll ;
int n,m;
int l[100005];
pii p[100005]; //<?x,?>
inline void update(int a,int b)
{
if(b>a)
{
p[b+1].second+=b-a;
p[a+1].first--;
p[a+1].second+=b+1;
p[b+1].first++;
p[b+1].second-=b+1;
p[1].second+=b-a;
p[a+1].second-=b-a;
}
else
{
p[a+1].first--;
p[a+1].second+=b+1+m;
p[b+1].second+=m-a+b;
p[a+1].second-=m-a+b;
p[1].first--;
p[1].second+=b;
p[b+1].first++;
p[b+1].second-=b;
}
}
int main()
{
int ans=INF;
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>l[i];
for(int i=2;i<=n;i++) update(l[i-1],l[i]);
for(int i=2;i<=m;i++)
{
p[i].first+=p[i-1].first;
p[i].second+=p[i-1].second;
// }for(int i=1;i<=m;i++) cout<<p[i].first<<" "<<p[i].second<<endl;
for(int i=1;i<=m;i++) ans=min(ans,p[i].first*i+p[i].second);
cout<<ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:71:2: error: expected '}' at end of input
71 | }
| ^
a.cc:57:1: note: to match this '{'
57 | {
| ^
|
s754472002 | p03677 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
typedef long long LL;
using namespace std;
int main(){
LL n,m;
cin>>n>>m;
LL sum[m];
LL ad[m];
fill_n(sum,m,0);
fill_n(ad,m,0);
LL a[n];
REP(i,n){
cin>>a[i];
a[i]--;
}
REP(i,n-1){
sum[(a[i]+1)%m]--;
sum[a[i+1]]++;
}
LL maxn=max(sum[0],0L);
REP(i,m-1){
sum[i+1]+=sum[i];
maxn =max(maxn,sum[i+1]);
}
REP(i,m){
sum[i]-=maxn;
}
REP(i,n-1){
ad[a[i+1]]+=(a[i+1]-a[i]+m)%m-1;
}
LL cnt[m];
fill_n(cnt,m,0);
REP(i,n-1){
if(a[i]>a[i+1]){
cnt[0]+=a[i+1]+1;
}else{
cnt[0]+=a[i+1]-a[i];
}
}
LL minn = cnt[0];
for(int i=1;i<m;i++){
cnt[i]=cnt[i-1]+ad[i-1]+sum[i-1];
minn = min(minn,cnt[i]);
}
cout<<minn<<endl;
// REP(i,m){
// cout<<ad[i]<<" "<<sum[i]<<endl;
// }
return 0;
} | a.cc: In function 'int main()':
a.cc:28:16: error: no matching function for call to 'max(LL&, long int)'
28 | LL maxn=max(sum[0],0L);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:28:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
28 | LL maxn=max(sum[0],0L);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:28:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
28 | LL maxn=max(sum[0],0L);
| ~~~^~~~~~~~~~~
|
s473295116 | p03677 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
typedef LL long long;
using namespace std;
int main(){
LL n,m;
cin>>n>>m;
LL sum[m];
LL ad[m];
fill_n(sum,m,0);
fill_n(ad,m,0);
LL a[n];
REP(i,n){
cin>>a[i];
a[i]--;
}
REP(i,n-1){
sum[(a[i]+1)%m]--;
sum[a[i+1]]++;
}
LL maxn=sum[0];
REP(i,m-1){
sum[i+1]+=sum[i];
maxn =max(maxn,sum[i+1]);
}
REP(i,m){
sum[i]-=maxn;
}
REP(i,n-1){
ad[a[i+1]]+=(a[i+1]-a[i]+m)%m-1;
}
LL cnt[m];
fill_n(cnt,m,0);
REP(i,n-1){
if(a[i]>a[i+1]){
cnt[0]+=a[i+1]+1;
}else{
cnt[0]+=a[i+1]-a[i];
}
}
LL minn = cnt[0];
for(int i=1;i<m;i++){
cnt[i]=cnt[i-1]+ad[i-1]+sum[i-1];
minn = min(minn,cnt[i]);
}
cout<<minn<<endl;
// REP(i,m){
// cout<<ad[i]<<" "<<sum[i]<<endl;
// }
return 0;
} | a.cc:4:9: error: 'LL' does not name a type; did you mean 'ALL'?
4 | typedef LL long long;
| ^~
| ALL
a.cc: In function 'int main()':
a.cc:10:5: error: 'LL' was not declared in this scope; did you mean 'ALL'?
10 | LL n,m;
| ^~
| ALL
a.cc:11:10: error: 'n' was not declared in this scope; did you mean 'yn'?
11 | cin>>n>>m;
| ^
| yn
a.cc:11:13: error: 'm' was not declared in this scope; did you mean 'tm'?
11 | cin>>n>>m;
| ^
| tm
a.cc:12:7: error: expected ';' before 'sum'
12 | LL sum[m];
| ^~~~
| ;
a.cc:13:7: error: expected ';' before 'ad'
13 | LL ad[m];
| ^~~
| ;
a.cc:15:12: error: 'sum' was not declared in this scope
15 | fill_n(sum,m,0);
| ^~~
a.cc:16:12: error: 'ad' was not declared in this scope
16 | fill_n(ad,m,0);
| ^~
a.cc:17:7: error: expected ';' before 'a'
17 | LL a[n];
| ^~
| ;
a.cc:19:14: error: 'a' was not declared in this scope
19 | cin>>a[i];
| ^
a.cc:23:14: error: 'a' was not declared in this scope
23 | sum[(a[i]+1)%m]--;
| ^
a.cc:28:7: error: expected ';' before 'maxn'
28 | LL maxn=sum[0];
| ^~~~~
| ;
a.cc:31:9: error: 'maxn' was not declared in this scope; did you mean 'main'?
31 | maxn =max(maxn,sum[i+1]);
| ^~~~
| main
a.cc:34:17: error: 'maxn' was not declared in this scope; did you mean 'main'?
34 | sum[i]-=maxn;
| ^~~~
| main
a.cc:39:12: error: 'a' was not declared in this scope
39 | ad[a[i+1]]+=(a[i+1]-a[i]+m)%m-1;
| ^
a.cc:42:7: error: expected ';' before 'cnt'
42 | LL cnt[m];
| ^~~~
| ;
a.cc:43:12: error: 'cnt' was not declared in this scope; did you mean 'int'?
43 | fill_n(cnt,m,0);
| ^~~
| int
a.cc:45:12: error: 'a' was not declared in this scope
45 | if(a[i]>a[i+1]){
| ^
a.cc:51:7: error: expected ';' before 'minn'
51 | LL minn = cnt[0];
| ^~~~~
| ;
a.cc:54:9: error: 'minn' was not declared in this scope
54 | minn = min(minn,cnt[i]);
| ^~~~
a.cc:56:11: error: 'minn' was not declared in this scope
56 | cout<<minn<<endl;
| ^~~~
|
s453773296 | p03677 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
using namespace std;
int main(){
int n,m;
cin>>n>>m;
LL sum[m];
LL ad[m];
fill_n(sum,m,0);
fill_n(ad,m,0);
LL a[n];
REP(i,n){
cin>>a[i];
a[i]--;
}
REP(i,n-1){
sum[(a[i]+1)%m]--;
sum[a[i+1]]++;
}
LL maxn=sum[0];
REP(i,m-1){
sum[i+1]+=sum[i];
maxn =max(maxn,sum[i+1]);
}
maxn=max(0,maxn);
REP(i,m){
sum[i]-=maxn;
}
REP(i,n-1){
ad[a[i+1]]+=(a[i+1]-a[i]+m)%m-1;
}
LL cnt[m];
fill_n(cnt,m,0);
REP(i,n-1){
if(a[i]>a[i+1]){
cnt[0]+=a[i+1]+1;
}else{
cnt[0]+=a[i+1]-a[i];
}
}
LL minn = cnt[0];
for(int i=1;i<m;i++){
cnt[i]=cnt[i-1]+ad[i-1]+sum[i-1];
minn = min(minn,cnt[i]);
}
cout<<minn<<endl;
// REP(i,m){
// cout<<ad[i]<<" "<<sum[i]<<endl;
// }
return 0;
} | a.cc: In function 'int main()':
a.cc:33:13: error: no matching function for call to 'max(int, long long int&)'
33 | maxn=max(0,maxn);
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:33:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
33 | maxn=max(0,maxn);
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:33:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
33 | maxn=max(0,maxn);
| ~~~^~~~~~~~
|
s530398893 | p03677 | C++ |
Spylft:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int M=100005;
typedef long long LL;
template<class T>void Min(T &x,T y){
if(x>y)x=y;
}
LL val[M],cnt[M];
int n,m,beg,x;
int main(){
scanf("%d %d",&n,&m),n--;
scanf("%d",&x);
for(int i=1;i<=n;i++){
scanf("%d",&beg);
if(beg>x){
val[1]+=beg-x,val[x+1]-=beg-x;
if(beg<m)val[beg+1]+=beg-x;
if(x+1<=beg)val[x+1]+=1+beg,val[beg+1]-=1+beg,cnt[x+1]++,cnt[beg+1]--;
}else {
val[beg+1]+=m-x+beg,val[x+1]-=m-x+beg;
if(x<m)val[x+1]+=1+m+beg,cnt[x+1]++;
val[1]+=1+beg,val[beg+1]-=1+beg,cnt[1]++,cnt[beg+1]--;
}x=beg;
}
LL ans=val[1]+cnt[1]*1;
for(int i=2;i<=m;i++)Min(ans,val[i]+i*cnt[i]);
cout<<ans<<endl;
return 0;
} | a.cc:2:1: error: 'Spylft' does not name a type
2 | Spylft:
| ^~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:5:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from a.cc:3:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
179 | _GLIBCXX_NODISCARD inline void* operator new(std::siz |
s721485647 | p03677 | C++ | #include <cstdio>
using namespace std;
int rd() {
int x = 0; char c = getchar();
while (c > '9' || c < '0') c = getchar();
while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
return x;
}
const int N = 2e5 + 5;
long long n, m, sum, ans = 1e18, a[N], b[N], c[N];
int main() {
n = rd(), m = rd();
for (int i = 1; i <= n; i ++) a[i] = rd();
for (int i = 2; i <= n; i ++) {
int l = a[i - 1], r = a[i];
if (l == r) continue;
if (l < r) b[l + 1] ++, b[r + 1] --, c[r + 1] -= r - l;
else b[l + 1] ++, b[r + m + 1] --, c[r + m + 1] -= r + m - l;
}
for (int i = 1; i <= 2 * m; i ++) b[i] += b[i - 1];
for (int i = 1; i <= 2 * m; i ++) c[i] += c[i - 1] + b[i];
for (int i = 1; i <= m; i ++) b[i] += b[i + m], c[i] += c[i + m], sum += b[i];
for (int i = 1; i <= m; i ++) ans = min(ans, sum - c[i] + b[i]);
printf("%lld\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:28:45: error: 'min' was not declared in this scope; did you mean 'main'?
28 | for (int i = 1; i <= m; i ++) ans = min(ans, sum - c[i] + b[i]);
| ^~~
| main
|
s059050716 | p03677 | C++ | #include <bits/stdc++.h>
#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
long long int n,m;
cin >> n >> m;
long long int a[n];
long long int ans = INF;
REP(i, n){
cin >> a[i];
a[i]--;
}
REP(i, m){
long long int po = 0;
long long int now = a[0];
REP(j, n-1){
po + = MIN((now<a[j+1]?(a[j+1]-now):(m-now+a[j+1])), 1+(i<=a[j+1]?(a[j+1]-i):(m-i+a[j+1])));
now = a[j+1];
}
ans = MIN(ans, po);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:25:12: error: expected primary-expression before '=' token
25 | po + = MIN((now<a[j+1]?(a[j+1]-now):(m-now+a[j+1])), 1+(i<=a[j+1]?(a[j+1]-i):(m-i+a[j+1])));
| ^
|
s108921370 | p03677 | C++ | //Artie WANG
//io
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <sstream>
//data structure
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
#include <utility>
#include <bitset>
#include <complex>
#include <cassert>
using namespace std;
const char newline = '\n';
typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
/*
const int maxn = 1e5+1;
ll tree[maxn<<2], lazy[maxn<<2];
ll d[maxn<<2];
void update(int cur, int tl, int tr, int ql, int qr, ll v, ll dif)
{
if (ql > qr)
{
return;
}
if (ql <= tl && tr <= qr)
{
tree[cur] += v;
lazy[cur] += v;
d[cur] += dif;
return;
}
int tm = (tl+tr)>>1;
if (lazy[cur])
{
lazy[cur<<1] += lazy[cur], lazy[(cur<<1)|1] += lazy[cur]
tree[cur<<1] += lazy[cur], tree[(cur<<1)|1] += lazy[cur];
lazy[cur] = 0;
}
update(cur<<1, tl, tm, ql, min(qr, tm), v);
update((cur<<1)|1, tm+1, tr, max(tm+1, ql), qr, v);
tree[cur] = min(tree[cur<<1], tree[(cur<<1)|1]);
}
ll query(int cur, int tl, int tr, int ql, int qr)
{
if (ql > qr)
{
return 1e18;
}
if (ql <= tl && tr <= qr)
{
return tree[cur];
}
int tm = (tl+tr)>>1;
if (lazy[cur])
{
lazy[cur<<1] += lazy[cur], lazy[(cur<<1)|1] += lazy[cur];
tree[cur<<1] += lazy[cur], tree[(cur<<1)|1] += lazy[cur];
lazy[cur] = 0;
}
ll ret = min(query(cur<<1, tl, tm, ql, min(qr, tm)), query((cur<<1)|1, tm+1, tr, max(ql, tm+1), qr));
tree[cur] = min(tree[cur<<1], tree[(cur<<1)|1]);
return ret;
}
*/
const int maxn = 1e5+10;
ll n, m, a[maxn], b[maxn];
ll base[maxn<<2], dif[maxn<<2];
int main()
{
//memset(tree, 0, sizeof(tree));
// memset(lazy, 0, sizeof(lazy));
scanf("%d %d", &n, &m);
for (int i = 0; i < n; ++i)
{
scanf("%d", a+i);
// a[i] %= m;
}
for (int i = 0; i < n-1; ++i)
{
int cur = a[i], nxt = a[i+1];
if (cur == nxt) continue;
if (cur < nxt)
{
base[1] += nxt-cur;
dif[cur+1] += 1;
dif[nxt] -= 1;
base[nxt+1] -= 1;
base[nxt+1] += nxt-cur;
}
else
{
base[1] += nxt;
base[nxt+1] -= 1;
base[nxt+1] += nxt+m-cur;
dif[1] += 1;
dif[nxt] -= 1;
dif[cur+1] += 1;
}
}
ll cur = 0, diff = 0;
for (int i = 1; i <= m; ++i)
{
cur += base[i]-diff;
b[i] = cur;
diff += dif[i];
// cerr << i << " " << cur << " " << diff << endl;
}
/*
for (int i = 1; i <= n; ++i)
{
b[i] += b[i+n];
}*/
printf("%lld\n", *min_element(b+1, b+1+n));
}
| a.cc: In function 'int main()':
a.cc:137:21: error: 'min_element' was not declared in this scope
137 | printf("%lld\n", *min_element(b+1, b+1+n));
| ^~~~~~~~~~~
|
s438525220 | p03677 | C++ | #include <bits/stdc++.h>
using namespace std;
#define N 100005
int n, m, arr[N];
int f(int);
inline int dis(int, int);
int main(){
srand(time(NULL));
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
for(int i=0;i<n;i++) cin>>arr[i];
int x=rand()%m + 1, y=f(x);
for(int i=0;i<400;i++){
int newX = max(0, int(x+((rand()&1)?1:-1)*rand()/(3*step))%m), newY=f(newX);
if(newY < y){
x = newX;
y = newY;
}
step*=tt;
}
cout<<y<<'\n';
return 0;
}
inline int dis(int p, int q){
return q>=p? q - p : q + m - p;
}
int f(int b){
int r=0;
for(int i=1;i<n;i++)
r += min(dis(arr[i-1], arr[i]), dis(b, arr[i])+1);
return r;
} | a.cc: In function 'int main()':
a.cc:16:69: error: 'step' was not declared in this scope; did you mean 'strsep'?
16 | int newX = max(0, int(x+((rand()&1)?1:-1)*rand()/(3*step))%m), newY=f(newX);
| ^~~~
| strsep
a.cc:17:20: error: 'newY' was not declared in this scope; did you mean 'newX'?
17 | if(newY < y){
| ^~~~
| newX
a.cc:21:23: error: 'tt' was not declared in this scope; did you mean 'tm'?
21 | step*=tt;
| ^~
| tm
|
s238472461 | p03677 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
scanf("%d%d", &n, &m);
vector<int> a(n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
vector<pair<int, pair<int, int>>> evs;
long long tot = 0;
for (int i = 0; i + 1 < n; i++) {
if (a[i] < a[i + 1]) {
evs.push_back({a[i], {1, 0}});
evs.push_back({a[i + 1], {-1, a[i + 1] - a[i]}});
} else {
evs.push_back({a[i], {1, 0}});
evs.push_back({m + 1, {-1, m + 1 - a[i]}});
evs.push_back({1, {1, 0}});
evs.push_back({a[i + 1], {-1, a[i + 1] - 1}});
}
tot += (a[i + 1] - a[i] + m) % m;
}
sort(evs.begin(), evs.end());
int cnt = 0;
long long dst = 0;
long long mx = 0;
for (int i = 0; i < evs.size(); i++) {
if (i > 0) {
dst += cnt * (evs[i].first - evs[i - 1].first);
}
mx = max(mx, dst - cnt);
cnt += evs[i].second.first;
if (evs[i].second.first == -1) {
dst -= evs[i].second.second;
}
}
cout << tot - mx << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:27:5: error: 'sort' was not declared in this scope; did you mean 'short'?
27 | sort(evs.begin(), evs.end());
| ^~~~
| short
|
s137432477 | p03677 | C++ | #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
template<typename Type> class StarrySkyTree {
private:
unsigned size_; std::vector<Type> dat1, dat2;
inline void update_(unsigned a, unsigned b, Type x, unsigned k, unsigned l, unsigned r) {
if (r <= a || b <= l) return;
if (a <= l && r <= b) {
dat2[k] += x; return;
}
update_(a, b, x, (k << 1), l, (l + r) >> 1);
update_(a, b, x, (k << 1) + 1, (l + r) >> 1, r);
dat1[k] = std::min(dat1[k << 1] + dat2[k << 1], dat1[(k << 1) + 1] + dat2[(k << 1) + 1]);
}
inline Type query_(unsigned a, unsigned b, unsigned k, unsigned l, unsigned r) {
if (r <= a || b <= l) return std::numeric_limits<Type>::max();
if (a <= l && r <= b) return dat1[k] + dat2[k];
Type lc = query_(a, b, (k << 1), l, (l + r) >> 1);
Type rc = query_(a, b, (k << 1) + 1, (l + r) >> 1, r);
return std::min(lc, rc) + dat2[k];
}
public:
StarrySkyTree() : size_(0), dat(std::vector<Type>()) {};
StarrySkyTree(int size__) {
for (size_ = 1; size_ < size__; ) size_ <<= 1;
dat1.resize(size_ << 1, 0);
dat2.resize(size_ << 1, 0);
}
template<class T>
StarrySkyTree(T begin_, T end_) {
unsigned n = (end_ - begin_);
for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
for (unsigned i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
for (unsigned i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
}
inline unsigned size() { return size_; }
inline void add(unsigned i, Type x) {
update_(i, i + 1, x, 1, 0, size_);
}
inline void add(unsigned l, unsigned r, Type x) {
update_(l, r, x, 1, 0, size_);
}
inline Type query(unsigned l, unsigned r) {
return query_(l, r, 1, 0, size_);
}
};
long long n, m, a[100009], c, p[300009];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++)cin >> a[i];
for (int i = 1; i <= n - 1; i++) { c += (a[i + 1] - a[i] + m) % m; }
StarrySkyTree<long long> E(300005);
for (int i = 1; i <= n - 1; i++) {
long long L = a[i] + 2, R = a[i + 1];
if (L > R)R += m;
E.add(L, R + 1, 1);
E.add(R + 1, R + 2, -(R + 1 - L));
}
for (int i = 1; i <= 300000; i++)p[i] = E.query(i, i + 1);
for (int i = 1; i <= 300000; i++)p[i] += p[i - 1];
long long maxn = 0;
for (int i = 1; i <= m; i++)maxn = max(maxn, p[i] + p[i + m] + p[i + m + m]);
cout << c - maxn << endl;
return 0;
} | a.cc: In constructor 'StarrySkyTree<Type>::StarrySkyTree()':
a.cc:29:37: error: class 'StarrySkyTree<Type>' does not have any field named 'dat'
29 | StarrySkyTree() : size_(0), dat(std::vector<Type>()) {};
| ^~~
a.cc: In constructor 'StarrySkyTree<Type>::StarrySkyTree(T, T)':
a.cc:38:58: error: 'dat' was not declared in this scope; did you mean 'dat1'?
38 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
| ^~~
| dat1
|
s049513317 | p03678 | C++ | #include<bits/stdc++.h>
#define N 200010
#define ll long long
using namespace std;
struct data
{
ll len,a[30];
data()
{
len=0;
memset(a,0,sizeof(a));
}
}f[100];
data operator + (data a,data b)
{
data c;
c.len=a.len+b.len;
for(int i=0;i<26;i++)
c.a[i]=a.a[i]+b.a[i];
return c;
}
data operator - (data a,data b)
{
data c;
c.len=a.len-b.len;
for(int i=0;i<26;i++)
c.a[i]=a.a[i]-b.a[i];
return c;
}
int n,maxn;
int cut,kmp[N];
char s[N],ss[N];
ll ql,qr;
data query(int k,ll x)
{
if(x==f[k].len) return f[k];
if(!k)
{
data c;
c.len=x;
for(int i=cut+1;i<=cut+x;i++)
c.a[s[i]-'a']++;
return c;
}
if(k==1)
{
data c;
c.len=x;
for(int i=1;i<=x;i++)
c.a[s[i]-'a']++;
return c;
}
if(x<=f[k-1].len) return query(k-1,x);
return f[k-1]+query(k-2,x-f[k-1].len);
}
int main()
{
scanf("%s%lld%lld",s+1,&ql,&qr);
n=strlen(s+1);
for(int i=1;i<=n/2;i++)
ss[n/2-i+1]=s[i];
for(int i=2,j=0;i<=n/2;i++)
{
while(j&&ss[j+1]!=ss[i]) j=kmp[j];
if(ss[j+1]==ss[i]) j++;
kmp[i]=j;
}
int cut=n/2-kmp[n/2];
for(int i=cut+1;i<=n/2;i++)
{
f[0].len++;
f[0].a[s[i]-'a']++;
}
for(int i=1;i<=cut;i++)
{
f[1].len++;
f[1].a[s[i]-'a']++;
}
for(int i=2;;i++)
{
f[i].len=f[i-1].len+f[i-2].len;
for(int j=0;j<26;j++)
f[i].a[j]=f[i-1].a[j]+f[i-2].a[j];
if(f[i].len>qr)
{
maxn=i;
break;
}
}
data ans=query(maxn,qr)-query(maxn,ql-1);
for(int i=0;i<26;i++)
printf("%lld ",ans.a[i]);
return 0;
}
/*
87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887912905 0 0
87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887912905 0 0
*/ | a.cc:18:1: error: reference to 'data' is ambiguous
18 | data operator + (data a,data b)
| ^~~~
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:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:8:8: note: 'struct data'
8 | struct data
| ^~~~
a.cc:27:1: error: reference to 'data' is ambiguous
27 | data operator - (data a,data b)
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:8:8: note: 'struct data'
8 | struct data
| ^~~~
a.cc:41:1: error: reference to 'data' is ambiguous
41 | data query(int k,ll x)
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:8:8: note: 'struct data'
8 | struct data
| ^~~~
a.cc: In function 'int main()':
a.cc:98:9: error: reference to 'data' is ambiguous
98 | data ans=query(maxn,qr)-query(maxn,ql-1);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:8:8: note: 'struct data'
8 | struct data
| ^~~~
a.cc:100:32: error: 'ans' was not declared in this scope; did you mean 'abs'?
100 | printf("%lld ",ans.a[i]);
| ^~~
| abs
|
s702465258 | p03678 | C++ | #include <iostream>
#include<vector>
using namespace std;
typedef long long lint;
const int MAXN = 200005;
char str[MAXN];
int fail[MAXN];
lint dp[222];
lint cnt[222][26];
vector<lint> solve(lint p, int s, int t){
memset(dp, 0, sizeof(dp));
memset(cnt, 0, sizeof(cnt));
vector<lint> dap(26);
dp[0] = s;
dp[1] = s+t;
vector<int> v;
for(int i=0; i<s; i++){
cnt[0][str[i] - 'a']++;
}
for(int i=0; i<s+t; i++){
cnt[1][str[i] - 'a']++;
}
for(int i=2; i<100; i++){
for(int j=0; j<26; j++){
cnt[i][j] = cnt[i-1][j] + cnt[i-2][j];
}
dp[i] = (dp[i-1] + dp[i-2]);
if(dp[i] >= p){
for(int j=i; j>=0; j--){
while(p >= dp[j]){
p -= dp[j];
v.push_back(j);
}
}
break;
}
}
for(int i=0; i<p; i++){
dap[str[i] - 'a']++;
}
for(auto &i : v){
for(int j=0; j<26; j++){
dap[j] += cnt[i][j];
}
}
return dap;
}
int main(){
scanf("%s", str);
int p = 0;
for(int i=1; str[i]; i++){
while(p && str[i] != str[p]) p = fail[p];
if(str[i] == str[p]) p++;
fail[i + 1] = p;
}
int n = strlen(str);
int s = n / 2 - fail[n / 2];
int t = fail[n / 2];
lint l, r; cin >> l >> r;
auto x = solve(r, s, t);
auto y = solve(l - 1, s, t);
for(int i=0; i<26; i++){
printf("%lld ", x[i] - y[i]);
}
} | a.cc: In function 'std::vector<long long int> solve(lint, int, int)':
a.cc:14:9: error: 'memset' was not declared in this scope
14 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<vector>
+++ |+#include <cstring>
3 | using namespace std;
a.cc: In function 'int main()':
a.cc:60:17: error: 'strlen' was not declared in this scope
60 | int n = strlen(str);
| ^~~~~~
a.cc:60:17: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s441476676 | p03678 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1e6 + 10;
const int M = 26;
char s[maxn];
int next[maxn];
struct Node
{
LL cnt[M];
Node() { memset(cnt, 0, sizeof cnt); }
void operator += (const Node &a)
{
for (int i = 0; i < M; ++ i)
cnt[i] += a.cnt[i];
}
Node operator + (const Node &a) const
{
Node res;
for (int i = 0; i < M; ++ i)
res.cnt[i] = cnt[i] + a.cnt[i];
return res;
}
Node operator - (const Node &a) const
{
Node res;
for (int i = 0; i < M; ++ i)
res.cnt[i] = cnt[i] - a.cnt[i];
return res;
}
void Putout()
{
for (int i = 0; i < M - 1; ++ i) printf("%lld ", cnt[i]);
printf("%lld\n", cnt[M - 1]);
}
} sum[maxn];
Node Calc(int len, LL n)
{
LL x = len, y = len + (len - next[len]);
if (n <= x) return sum[n];
if (n <= y) return sum[len] + sum[n - len];
Node a = sum[len], b = sum[len] + sum[len - next[len]];
while (n >= x + y)
{
b += a;
a = b - a;
y += x;
x = y - x;
}
return b + Calc(len, n - y);
}
int main()
{
scanf("%s", s + 1);
int n = strlen(s + 1) / 2;
next[1] = 0;
sum[1].cnt[s[1] - 'a'] = 1;
for (int i = 2; i <= n; ++ i)
{
int j = next[i - 1];
while (j && s[j + 1] != s[i]) j = next[j];
next[i] = j + (s[j + 1] == s[i]);
sum[i].cnt[s[i] - 'a'] = 1;
sum[i] += sum[i - 1];
}
LL l, r;
scanf("%lld%lld", &l, &r);
Node res = Calc(n, r) - Calc(n, l - 1);
res.Putout();
return 0;
}
| a.cc: In function 'Node Calc(int, LL)':
a.cc:47:38: error: reference to 'next' is ambiguous
47 | LL x = len, y = len + (len - next[len]);
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:5: note: 'int next [1000010]'
13 | int next[maxn];
| ^~~~
a.cc:50:53: error: reference to 'next' is ambiguous
50 | Node a = sum[len], b = sum[len] + sum[len - next[len]];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:5: note: 'int next [1000010]'
13 | int next[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:65:9: error: reference to 'next' is ambiguous
65 | next[1] = 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:5: note: 'int next [1000010]'
13 | int next[maxn];
| ^~~~
a.cc:69:25: error: reference to 'next' is ambiguous
69 | int j = next[i - 1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:5: note: 'int next [1000010]'
13 | int next[maxn];
| ^~~~
a.cc:70:51: error: reference to 'next' is ambiguous
70 | while (j && s[j + 1] != s[i]) j = next[j];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:5: note: 'int next [1000010]'
13 | int next[maxn];
| ^~~~
a.cc:71:17: error: reference to 'next' is ambiguous
71 | next[i] = j + (s[j + 1] == s[i]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:5: note: 'int next [1000010]'
13 | int next[maxn];
| ^~~~
|
s978288778 | p03678 | C++ | #include <bits/stdc++.h>
#define b 31ll
#define mod 1004535809ll
#define ll long long
using namespace std;
char s[400005];
ll l[1005],fib[1005][27],ans[27];
ll has[400005],m[400005],lo,hi;
int len,t;
inline ll get(int l,int r)
{if (l>r) return 0;
ll ret=(has[r]-has[l-1]*m[r-l+1])%mod;
return (ret<0?ret+mod:ret);
}
inline void add(ll p,int pos)
{if (pos<=1)
{for (int i=1;i<=p;i++)
{ans[s[(i-1)%len+1]-'a']++;}
return;
}
if (p>=l[pos-1])
{for (int i=0;i<26;i++) ans[i]+=fib[pos-1][i];
add(p-l[pos-1],pos-2);
return;
}
add(p,pos-1);
}
inline void del(ll p,int pos)
{if (pos<=1)
{for (int i=1;i<=p;i++)
{ans[s[(i-1)%len+1]-'a']--;}
return;
}
if (p>=l[pos-1])
{for (int i=0;i<26;i++) ans[i]-=fib[pos-1][i];
del(p-l[pos-1],pos-2);
return;
}
del(p,pos-1);
}
int main (){
int i,j,las;
gets(s+1);len=strlen(s+1);
scanf ("%lld%lld",&lo,&hi);
m[0]=1ll;len>>=1;
for (i=1;i<=len;i++)
{m[i]=m[i-1]*b%mod;
has[i]=has[i-1]*b+(s[i]-'0');
has[i]%=mod;
}
for (i=1;i<=len;i++)
{if (get(1,len-i)==get(i+1,len))
{t=i;break;}
}
l[0]=len;l[1]=len+t;
for (i=1;i<=len;i++)
{fib[0][s[i]-'a']++;
fib[1][s[i]-'a']++;
}
for (i=1;i<=t;i++)
{fib[1][s[i]-'a']++;}
for (i=2;l[i-2]+l[i-1]<=2ll*hi;i++)
{for (j=0;j<26;j++)
{fib[i][j]=fib[i-1][j]+fib[i-2][j];}
l[i]=l[i-1]+l[i-2];
las=i;
}
add(hi,las);del(lo-1,las);
for (i=0;i<26;i++)
{printf ("%lld ",ans[i]);}
return 0;
} | a.cc: In function 'int main()':
a.cc:43:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
43 | gets(s+1);len=strlen(s+1);
| ^~~~
| getw
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.