submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s370457408
p03848
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<int> a(N); int zero = 0; for(int i=0;i<N;i++){ cin>>a[i]; if(a[i]==0) zero++; } sort(a.begin(),a.end(),greater<int>()); if(N%2==0&&zero>0||N%2==1&&zero>1){ cout<<"0"; return 0; } const int mod 1e9+7; int ans = 1; for(int i=0;i<N;i+=2){ if(a[i]!=a[i+1]){ cout<<"0"; return 0; } ans+=ans*2%mod; } cout<<ans; }
a.cc: In function 'int main()': a.cc:21:19: error: expected initializer before numeric constant 21 | const int mod 1e9+7; | ^~~ a.cc:28:20: error: 'mod' was not declared in this scope; did you mean 'modf'? 28 | ans+=ans*2%mod; | ^~~ | modf
s233297460
p03848
C++
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 100005; const int mod = 1e9+7; int a[N]; int num[N]; ll qpow(ll a,ll b,ll p) { ll ans=1%p; while(b) { if(b&1) ans=(ans*a)%p; b>>=1; a=(a*a)%p; } return ans; } int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); num[a[i]]++; } if(n%2==1) { int flag=1; for(int i=n-1;i>=0;i-=2) { if(i==0) { if(num[i]!=1) { flag=0; break; } } else { if(num[i]!=2) { flag=0; break; } } } if(flag==0) printf("0\n"); else { ll ans=qpow(2,n/2)%mod; printf("%lld\n",ans); } } else { int flag=1; for(int i=n-1;i>=1;i-=2) { if(num[i]!=2) { flag=0; break; } } if(flag==0) printf("0\n"); else { ll ans=qpow(2,n/2)%mod; printf("%lld\n",ans); } } return 0; }
a.cc: In function 'int main()': a.cc:54:36: error: too few arguments to function 'long long int qpow(long long int, long long int, long long int)' 54 | ll ans=qpow(2,n/2)%mod; | ~~~~^~~~~~~ a.cc:8:4: note: declared here 8 | ll qpow(ll a,ll b,ll p) | ^~~~ a.cc:73:36: error: too few arguments to function 'long long int qpow(long long int, long long int, long long int)' 73 | ll ans=qpow(2,n/2)%mod; | ~~~~^~~~~~~ a.cc:8:4: note: declared here 8 | ll qpow(ll a,ll b,ll p) | ^~~~
s545513526
p03848
C++
#include <iostream> using namespace std; typedef long long ll; ll mod=1e9+7; int main(){ ll n; cin >> n; ll a[n]; for(ll i=0;i<n;i++) cin >> a[i]; ll check[n]={0}; if(n%2==0){ for(ll i=1;i<n;i++) check[i]=2; } else{ check[0]=1; for(ll i=2;i<n;i++) check[i]=2; } for(ll i=0;i<n;i++){ check[a[i]]--; } bool res=true; for(ll i=0;i<n;i++) if(check[i]) res=false; if(!res) cout << 0 << endl; else{ ll ans=1; for(ll i=0;i<n/2;i++){ ans=(ans*2)%mod; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:33:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 33 | cout << ans << endl; | ^~~ | abs
s757099468
p03848
C++
#include<iostream> #include<vector> #include<algorithm> #include<stack> #include<queue> #include<string> #include<cmath> using namespace std; #define ll long long #define INF 99999999 #define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化 #define all(x) (x).begin(),(x).end() #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define vint vector<int> #define vvint vector<vector<int>> template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } int gcd(int a,int b){return b?gcd(b,a%b):a;} int n; vint a,t; bool judge(){ VSORT(a); if(n%2!=0){ t.push_back(0); rep(i,(n-1)/2){ t.push_back((i+1)*2); t.push_back((i+1)*2); } } else{ rep(i,n/2){ t.push_back(2*(i+1)-1); t.push_back(2*(i+1)-1); } } // for(auto x: t) cout << x; return a == t; } int main(){ cin >> n; a.resize(n); rep(i,n) cin >> a[i]; ll ans=0; if(judge()){ ans=1; rep(i,n/2){ ans = ans*2 % 1e9; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:54:19: error: invalid operands of types 'long long int' and 'double' to binary 'operator%' 54 | ans = ans*2 % 1e9; | ~~~~~ ^ ~~~ | | | | | double | long long int
s700221154
p03848
C++
import sys n = int(input()) a = list(map(int, input().split())) a.sort() ra = a.copy() a = a[0::2] ra = ra[1::2] ra.reverse() a = ra + a for i in range(n): if a[i] != abs(n - 1 - i * 2): print(0) sys.exit(0) print(2 ** (n // 2) % 1000000007)
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s993404219
p03848
C++
#include <iostream> #include <vector> #include <algorithm> #define MOD 1000000007 using namespace std; int main() { ll n, ans = 1; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; ++i) cin >> a.at(i); sort(a.begin(), a.end()); for (ll i = n - 1; i >= 0; --i) { if (a.at(i) != (i + n % 2) / 2 * 2 + (n - 1) % 2) { cout << 0 << endl; return 0; } } for (ll i = 0; i < n / 2; ++i) ans = ans * 2 % MOD; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:5: error: 'll' was not declared in this scope 10 | ll n, ans = 1; | ^~ a.cc:11:12: error: 'n' was not declared in this scope 11 | cin >> n; | ^ a.cc:12:14: error: template argument 2 is invalid 12 | vector<ll> a(n); | ^ a.cc:13:12: error: expected ';' before 'i' 13 | for (ll i = 0; i < n; ++i) cin >> a.at(i); | ^~ | ; a.cc:13:20: error: 'i' was not declared in this scope 13 | for (ll i = 0; i < n; ++i) cin >> a.at(i); | ^ a.cc:13:41: error: request for member 'at' in 'a', which is of non-class type 'int' 13 | for (ll i = 0; i < n; ++i) cin >> a.at(i); | ^~ a.cc:14:12: error: request for member 'begin' in 'a', which is of non-class type 'int' 14 | sort(a.begin(), a.end()); | ^~~~~ a.cc:14:23: error: request for member 'end' in 'a', which is of non-class type 'int' 14 | sort(a.begin(), a.end()); | ^~~ a.cc:15:12: error: expected ';' before 'i' 15 | for (ll i = n - 1; i >= 0; --i) { | ^~ | ; a.cc:15:24: error: 'i' was not declared in this scope 15 | for (ll i = n - 1; i >= 0; --i) { | ^ a.cc:16:15: error: request for member 'at' in 'a', which is of non-class type 'int' 16 | if (a.at(i) != (i + n % 2) / 2 * 2 + (n - 1) % 2) { | ^~ a.cc:21:12: error: expected ';' before 'i' 21 | for (ll i = 0; i < n / 2; ++i) ans = ans * 2 % MOD; | ^~ | ; a.cc:21:20: error: 'i' was not declared in this scope 21 | for (ll i = 0; i < n / 2; ++i) ans = ans * 2 % MOD; | ^ a.cc:21:36: error: 'ans' was not declared in this scope; did you mean 'abs'? 21 | for (ll i = 0; i < n / 2; ++i) ans = ans * 2 % MOD; | ^~~ | abs a.cc:22:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 22 | cout << ans << endl; | ^~~ | abs
s098155413
p03848
C++
#include<vector> using namespace std; int main() { int n;cin>>n; vector<int> a(n); vector<int> v(10000,0); for(int i=0;i<n;i++){ cin>>a[i]; v[a[i]]++; } int flag=1; for(int i=0;i<n/2;i++){ if(v[2*i+1+n%2]!=2){ flag=0; break; } } if(n%2){ if(v[0]!=1){ flag=0; } } if(flag){ int ans=1; for(int i=0;i<n/2;i++){ ans*=2; } cout<<ans<<endl; }else{ cout<<0<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:5:15: error: 'cin' was not declared in this scope 5 | int n;cin>>n; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<vector> +++ |+#include <iostream> 2 | using namespace std; a.cc:29:17: error: 'cout' was not declared in this scope 29 | cout<<ans<<endl; | ^~~~ a.cc:29:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:29:28: error: 'endl' was not declared in this scope 29 | cout<<ans<<endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<vector> +++ |+#include <ostream> 2 | using namespace std; a.cc:31:17: error: 'cout' was not declared in this scope 31 | cout<<0<<endl; | ^~~~ a.cc:31:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:26: error: 'endl' was not declared in this scope 31 | cout<<0<<endl; | ^~~~ a.cc:31:26: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s771415595
p03848
C++
n = int(input()) cnt = [0] * n for i in input().split(): cnt[int(i)] += 1 for i in range(1 + n % 2, n, 2): if cnt[i] != 2: print(0) exit(0) print(pow(2, n // 2, int(1e9 + 7)))
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s333621458
p03848
C++
#include<stdio.h> #include <algorithm> #include <boost/foreach.hpp> using namespace std; int main(){ int i,a[100000],box[100000]={},n,b; long long int flag=1; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&a[i]); } sort(a,a+n,greater<int>()); b=n-1; for(i=0;i<n;i++){ if(a[i]!=b) flag=0; if(i%2==1) b-=2; } for(i=0;i<n/2;i++){ flag*=2; flag%=1000000007 printf("%lld\n",flag); }
a.cc:3:10: fatal error: boost/foreach.hpp: No such file or directory 3 | #include <boost/foreach.hpp> | ^~~~~~~~~~~~~~~~~~~ compilation terminated.
s716629829
p03848
C++
#include <bits/stdc++.h> #define int long long int mpow(int k,int n,const int MOD){ int res = 1; for(int i=0;i<n;i++) res=res*k%MOD; return res; using namespace std; signed main() { int N; int ans; cin>>N; int out=0; int k; std::vector<int> v(N,0); for(int i=0;i<N;i++){ cin>>k; v[k]++; } if(N%2){ for(int i=0;i<N;i++){ if(i==0)if(v[i]!=1)out++; if(i%2)if(v[i]!=0)out++; if(i%2==0&&i!=0)if(v[i]!=2)out++; } if(out)cout<<0<<endl; else{ ans=mpow(2,N/2,1e9+7); while(ans>=1000000007)ans-=1000000007; cout<<ans<<endl; } } else{ for(int i=0;i<N;i++){ if(i%2)if(v[i]!=2)out++; if(i%2==0)if(v[i]!=0)out++; } if(out)cout<<0<<endl; else{ ans=mpow(2,N/2,1e9+7); while(ans>=1000000007)ans-=1000000007; cout<<ans<<endl; } } }
a.cc: In function 'long long int mpow(long long int, long long int, long long int)': a.cc:9:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 9 | signed main() { | ^~ a.cc:9:12: note: remove parentheses to default-initialize a variable 9 | signed main() { | ^~ | -- a.cc:9:12: note: or replace parentheses with braces to value-initialize a variable a.cc:9:15: error: a function-definition is not allowed here before '{' token 9 | signed main() { | ^ a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:3:36: note: to match this '{' 3 | int mpow(int k,int n,const int MOD){ | ^
s349176055
p03848
C++
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int N; int ans; cin>>N; int out=0; int k; std::vector<int> v(N,0); for(int i=0;i<N;i++){ cin>>k; v[k]++; } if(N%2){ for(int i=0;i<N;i++){ if(i==0)if(v[i]!=1)out++; if(i%2)if(v[i]!=0)out++; if(i%2==0&&i!=0)if(v[i]!=2)out++; } if(out)cout<<0<<endl; else{ ans=mpow(2,N/2,1e9+7); while(ans>=1000000007)ans-=1000000007; cout<<ans<<endl; } } else{ for(int i=0;i<N;i++){ if(i%2)if(v[i]!=2)out++; if(i%2==0)if(v[i]!=0)out++; } if(out)cout<<0<<endl; else{ ans=mpow(2,N/2,1e9+7); while(ans>=1000000007)ans-=1000000007; cout<<ans<<endl; } } }
a.cc: In function 'int main()': a.cc:24:11: error: 'mpow' was not declared in this scope; did you mean 'pow'? 24 | ans=mpow(2,N/2,1e9+7); | ^~~~ | pow a.cc:36:11: error: 'mpow' was not declared in this scope; did you mean 'pow'? 36 | ans=mpow(2,N/2,1e9+7); | ^~~~ | pow
s249355045
p03848
C++
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int N; cin>>N; int out=0; int k; std::vector<int> v(N,0); for(int i=0;i<N;i++){ cin>>k; v[k]++; } if(N%2){ for(int i=0;i<N;i++){ if(i==0)if(v[i]!=1)out++; if(i%2)if(v[i]!=0)out++; if(i%2==0&&i!=0)if(v[i]!=2)out++; } if(out)cout<<0<<endl; else cout<<pow(2,N/2)%1000000007<<endl; } else{ for(int i=0;i<N;i++){ if(i%2)if(v[i]!=2)out++; if(i%2==0)if(v[i]!=0)out++; } if(out)cout<<0<<endl; else cout<<pow(2,N/2)%1000000007<<endl; } }
a.cc: In function 'int main()': a.cc:22:26: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'int' to binary 'operator%' 22 | else cout<<pow(2,N/2)%1000000007<<endl; | ~~~~~~~~~~^~~~~~~~~~~ | | | | | int | __gnu_cxx::__promote<double>::__type {aka double} a.cc:30:26: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'int' to binary 'operator%' 30 | else cout<<pow(2,N/2)%1000000007<<endl; | ~~~~~~~~~~^~~~~~~~~~~ | | | | | int | __gnu_cxx::__promote<double>::__type {aka double}
s269320809
p03848
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; int out=0; int k; std::vector<int> v(N,0); for(int i=0;i<N;i++){ cin>>k; v[k]++; } if(N%2){ for(int i=0;i<N;i++){ if(i==0)if(v[i]!=1)out++; if(i%2)if(v[i]!=0)out++; if(i%2==0&&i!=0)if(v[i]!=2)out++; } if(out)cout<<0<<endl; else cout<<pow(2,N/2)%1000000007<<endl; } else{ for(int i=0;i<N;i++){ if(i%2)if(v[i]!=2)out++; if(i%2==0)if(v[i]!=0)out++; } if(out)cout<<0<<endl; else cout<<pow(2,N/2)%1000000007<<endl; } }
a.cc: In function 'int main()': a.cc:21:26: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'int' to binary 'operator%' 21 | else cout<<pow(2,N/2)%1000000007<<endl; | ~~~~~~~~~~^~~~~~~~~~~ | | | | | int | __gnu_cxx::__promote<double>::__type {aka double} a.cc:29:26: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'int' to binary 'operator%' 29 | else cout<<pow(2,N/2)%1000000007<<endl; | ~~~~~~~~~~^~~~~~~~~~~ | | | | | int | __gnu_cxx::__promote<double>::__type {aka double}
s458472095
p03848
C++
using System; using System.Linq; using System.Diagnostics; using System.Collections.Generic; using static System.Math; class P { static void Main() { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray(); for (int i = 0; i < a.Length; i++) { if (a[i] != (n - 1) - ((i / 2) * 2)) { Console.WriteLine(0); return; } } Console.WriteLine(power(2, n / 2)); } static int power(int n, int m) { const int mod = 1000000007; long pow = n; long res = 1; while (m > 0) { if ((m & 1) == 1) res = (res * pow) % mod; pow = (pow * pow) % mod; m >>= 1; } return (int)res; } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Linq; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Diagnostics; | ^~~~~~ a.cc:4:7: error: expected nested-name-specifier before 'System' 4 | using System.Collections.Generic; | ^~~~~~ a.cc:5:7: error: expected nested-name-specifier before 'static' 5 | using static System.Math; | ^~~~~~ a.cc:39:2: error: expected ';' after class definition 39 | } | ^ | ; a.cc: In static member function 'static void P::Main()': a.cc:11:17: error: expected primary-expression before 'int' 11 | int n = int.Parse(Console.ReadLine()); | ^~~ a.cc:12:12: error: structured binding declaration cannot have type 'int' 12 | int[] a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray(); | ^~ a.cc:12:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:12:12: error: empty structured binding declaration a.cc:12:15: error: expected initializer before 'a' 12 | int[] a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray(); | ^ a.cc:13:29: error: 'a' was not declared in this scope 13 | for (int i = 0; i < a.Length; i++) | ^ a.cc:17:17: error: 'Console' was not declared in this scope 17 | Console.WriteLine(0); | ^~~~~~~ a.cc:22:9: error: 'Console' was not declared in this scope 22 | Console.WriteLine(power(2, n / 2)); | ^~~~~~~
s118151000
p03848
C++
//include //------------------------------------------ #include <map> #include <iostream> using namespace std; //conversion //------------------------------------------ inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //math //------------------------------------------- template<class T> inline T sqr(T x) {return x*x;} //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const LL MOD = 1000000007; //clear memory #define CLR(a) memset((a), 0 ,sizeof(a)) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; int main() { LL ans = 1; int N; cin >> N; map<int,int> mp; for (int i = 0; i < N; i++) { int tmp; cin >> tmp; mp[tmp]++; } bool flag = true; int i = 0; if(N % 2 == 1) { mp[0]++; for (auto&& var : mp) { if(var.first != i || var.second != 2 || var.first > N) { flag = false; break; } i += 2; } } else { i = 1; for (auto&& var : mp) { if (var.first != i || var.second != 2 || var.first > N) { flag = false; break; } i += 2; } } if (flag) { for (int i = 0; i < N/2; i++) { ans = ans*2; ans = ans % MOD; } cout << ans << endl; } else { cout << 0 << endl; } return 0; }
a.cc: In function 'int toInt(std::string)': a.cc:10:55: error: variable 'std::istringstream sin' has initializer but incomplete type 10 | inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} | ^ a.cc: In function 'std::string toString(T)': a.cc:11:62: error: 'sout' has incomplete type 11 | template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} | ^~~~ In file included from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:4: /usr/include/c++/14/iosfwd:106:11: note: declaration of 'std::ostringstream' {aka 'class std::__cxx11::basic_ostringstream<char>'} 106 | class basic_ostringstream; | ^~~~~~~~~~~~~~~~~~~ a.cc: At global scope: a.cc:19:9: error: 'vector' does not name a type 19 | typedef vector<int> VI; | ^~~~~~ a.cc:20:9: error: 'vector' does not name a type 20 | typedef vector<VI> VVI; | ^~~~~~ a.cc:21:9: error: 'vector' does not name a type 21 | typedef vector<string> VS; | ^~~~~~ a.cc:44:20: error: 'acos' was not declared in this scope 44 | const double PI = acos(-1.0); | ^~~~
s089759022
p03848
C++
#include <iostream> #include <algorithm> #include <cmath> using namespace std; long a,cnt[100000]; int main(void){ cin>>q; for(long i=-1;++i-q;){ cin>>a; ++cnt[a]; } for(long i=-1;++i-q;){ if(cnt[i]=!((i+a)&1)*2-!i&&a&1)break; } if(i==q){ cnt[0]=1; for(long i=-1;++i-(a/2);)cnt[0]=(cnt[0]*2)%1000000007; cout<<cnt[0]<<endl; } else cout<<0<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:10: error: 'q' was not declared in this scope 7 | cin>>q; | ^ a.cc:15:8: error: 'i' was not declared in this scope 15 | if(i==q){ | ^
s869039429
p03848
C++
#include<iostream> #include<bits/stdc++.h> #include<cmath> using namespace std; #define ll long long int ll num[500000],cnt[500000]= {0}; long long int bigmod(long long int a,long long int b,long long int p) { long long int val,ret; //printf("b=%lld\n",b); if(b==0) { return 1; } if(b%2==1) { ret= ((a*bigmod(a,b-1,p))%p); //printf("ret1=%lld\n",ret); } else { val=bigmod(a,b/2,p); ret= ((val *val)%p); //printf("ret2=%lld\n",ret); } return ret; } int main() { ll n,i,j,k,flag=1,cnt1=1,res,res1; scanf("%lld",&n); for(i=0; i<n; i++) { scanf("%lld",&num[i]); } if(n%2==0) { for(i=1; i<n; i+=2) cnt[i]=2; } else { cnt[0]=1; for(i=2; i<n; i+=2) cnt[i]=2; } sort(num,num+n); flag=1; if(n%2==0) { for(i=1; i<n; i++) { if(num[i]==num[i-1]) { cnt1++; if(cnt[num[i]]!=cnt1) { flag=0; break; } } else(cnt1=1;) } } else { for(i=1; i<n; i++) { if(num[0]!=0) { flag=0; //printf("f1 %lld\n",flag); break; } if(num[i]==0) { flag=0; //printf("f2 %lld\n",flag); break; } if(num[i]==num[i-1]) { cnt1++; //printf("cnt %lld\n",cnt1); //printf("num %lld\n",num[i]); //printf("arr %lld\n",cnt[num[i]]); if(cnt[num[i]]!=cnt1) { flag=0; //printf("f3 %lld\n",flag); break; } } else{cnt1=1;} } } if(flag==1) { k=n/2; res=bigmod(2,k,1000000007); printf("%lld\n",res); } else { printf("0\n"); } return 0; }
a.cc: In function 'int main()': a.cc:73:24: error: expected ')' before ';' token 73 | else(cnt1=1;) | ~ ^ | ) a.cc:73:25: error: expected primary-expression before ')' token 73 | else(cnt1=1;) | ^
s783174318
p03848
C++
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int mod=1e9+7; int a[100001]; int n; int pow1(int a,int n) { if(n==0) return 1; int x=pow1(a,n/2); long long ans=(long long)x*x%mod; if(n%2==1) ans=ans*a%mod; return ans; } bool check() { sort(a+1,a+n+1); if(a[1]==0) for(int i=2;i<=n;) { if(a[i]!=a[i+1]) return false; i+=2; } else { for(int i=1;i<=n;) if(a[i]!=a[i+1]) return false; i+=2; } return true; } int main() { scanf("%d",&n); int flag=0; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); if(a[i]==0) flag++; } if(flag==2||n%2==0&&flag>0||!check()) printf("0\n"); else { if(flag==1) { n=n-1; n/=2; } else n/=2; int ans=pow1(2,n); printf("%d\n",ans); } return 0; }
a.cc: In function 'bool check()': a.cc:31:17: error: 'i' was not declared in this scope 31 | i+=2; | ^
s525690767
p03848
C
#include <stdio.h> #include <stdlib.h> int compare_int(const void *a, const void *b) { return *(int*)a - *(int*)b; } int main(void) {int N,A,M,B,X,C,x,i,a,b,c,l,r,g,flag,m,tmp; long long int sum; scanf("%d",&N); sum=1; flag=0; int A[100000]; for(i=0;i<N;i++){ scanf("%d",A[i]);} qsort(A, N, sizeof(int), compare_int); if(N%2==0){ for(i=0;2*i+1<N;i++){ if(A[2*i]!=2*i+1||A[2*i+1]!=2*i+1){ flag=1; break;}} if(flag==0){ x=N/2; for(a=1;a<=x;a++){ sum*=2; if(sum>=1000000007){ sum%=1000000007;}}} } else{ for(i=0;2*i+1<N-1;i++){ if(A[2*i]!=2*i||A[2*i+1]!=2*i+2||A[N-1]!=N-1){ flag=1; break;}} if(flag==0){ x=N/2; for(a=1;a<=x;a++){ sum*=2; if(sum>=1000000007){ sum%=1000000007;}}}} if(flag==0){ printf("%lld",sum);} else printf("0"); return 0; }
main.c: In function 'main': main.c:15:13: error: conflicting types for 'A'; have 'int[100000]' 15 | int A[100000]; | ^ main.c:10:8: note: previous declaration of 'A' with type 'int' 10 | {int N,A,M,B,X,C,x,i,a,b,c,l,r,g,flag,m,tmp; | ^
s032968652
p03848
C++
#include "bits/stdc++.h" using namespace std; int main(){ long long int n; cin>>n; vector<long long int> a(n); for(int i=0;i<n;i++){ int b; cin>>b; a[b]++; } int f=1; if(n%2==0){ for(int i=1;i<n;i+=2){ if(a[i]!=2)f=0; } }else{ for(int i=2;i<n;i+=2){ if(a[i]!=2)f=0; } if(a[0]!=1)f=0; } if(f==0){ cout<<0<<endl; }else{ long long int ans=1; for(int i=0;i<n/2;i++){ ans*=2; ans%=1e9+7; } cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:32:28: error: invalid operands of types 'long long int' and 'double' to binary 'operator%' 32 | ans%=1e9+7; | ~~~^~~~~~~ a.cc:32:28: note: in evaluation of 'operator%=(long long int, double)'
s035347216
p03848
C++
// g++ macro.cpp -std=c++14 #include <bits/stdc++.h> //STL include typedef long long ll;// long long int const ll INF = 10000000000;//INFinity using namespace std;//namespace inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //#define int long long // yabai #define dump(x) cout << #x << " = " << (x) << endl;// debug cout #define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define ALL(obj) (obj).begin(),(obj).end()// iterator #define pb(a) push_back(a)//push_back #define mp make_pair// make_pair int main(){ int n; cin>>n; map<int,int> map_; REP(i,n){ int t; cin>>t; map_[t]++; } ll x=-1; for(auto t:map_)if(t.first%2==n%2||(t.first==0&&t.second!=1)||(t.first&&t.second!=2))x=0; if(x!=0)x=(n%2==1?pow(2,map_.size()-1)%(pow(10,9)+7):pow(2,map_.size())%(pow(10,9)+7)); cout<<x%((ll)pow(10,9)+7)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:36:43: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%' 36 | if(x!=0)x=(n%2==1?pow(2,map_.size()-1)%(pow(10,9)+7):pow(2,map_.size())%(pow(10,9)+7)); | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ | | | | | __gnu_cxx::__promote<double>::__type {aka double} | __gnu_cxx::__promote<double>::__type {aka double} a.cc:36:76: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%' 36 | if(x!=0)x=(n%2==1?pow(2,map_.size()-1)%(pow(10,9)+7):pow(2,map_.size())%(pow(10,9)+7)); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ | | | | | __gnu_cxx::__promote<double>::__type {aka double} | __gnu_cxx::__promote<double>::__type {aka double}
s928740554
p03848
C++
// g++ macro.cpp -std=c++14 #include <bits/stdc++.h> //STL include typedef long long ll;// long long int const ll INF = 10000000000;//INFinity using namespace std;//namespace inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //#define int long long // yabai #define dump(x) cout << #x << " = " << (x) << endl;// debug cout #define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define ALL(obj) (obj).begin(),(obj).end()// iterator #define pb(a) push_back(a)//push_back #define mp make_pair// make_pair int main(){ int n; cin>>n; map<int,int> map_; REP(i,n){ int t; cin>>t; map_[t]++; } ll x=-1; for(auto t:map_)if(t.first%2==n%2||(t.first==0&&t.second!=1)||(t.first&&t.second!=2))x=0; if(x!=0)x=(n%2==1?pow(2,map_.size()-1):pow(2,map_.size())); cout<<x%(pow(10,9)+7)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:37:12: error: invalid operands of types 'll' {aka 'long long int'} and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%' 37 | cout<<x%(pow(10,9)+7)<<endl; | ~^~~~~~~~~~~~~~ | | | | | __gnu_cxx::__promote<double>::__type {aka double} | ll {aka long long int}
s699357253
p03848
C++
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int cnt[n]; memset(cnt, 0, sizeof(cnt)); if (n % 2 != 0) { for (int i = 0; i < n; i++) { cnt[a[i]]++; } if (cnt[0] == 1) { bool flag = true; for (int i = 2; i < n; i += 2) { if (cnt[i] != 2) { flag = false; } } if (flag) { cout << pow(2.0, (n - 1) / 2) << endl; } else { cout << 0 << endl; } } else { cout << 0 << endl; } } else { for (int i = 0; i < n; i++) { cnt[a[i]]++; } bool flag = true; for (int i = 1; i < n; i += 2) { if (cnt[i] != 2) { flag = false; } } if (flag) { cout << pow(2.0, n / 2) << endl; } else { cout << 0 << endl; } } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:14:3: error: 'memset' was not declared in this scope 14 | memset(cnt, 0, sizeof(cnt)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <iostream> +++ |+#include <cstring> 4 | using namespace std;
s824253733
p03848
C++
#include <iostream> #include <string> #include <algorithm> #include <map> #include <set> #include <vector> #include <queue> #include <cmath> #define MOD 1000000007; #define PI 3.14159265358979323846; using namespace std; typedef long long ll; ll mod = 1000000007; ll pow(int a, int n) { if (n == 0) { return 1; } if (n % 2 == 0) { return (pow(a, n / 2)* pow(a, n / 2) % mod); } else { return ((pow(a, n / 2)* pow(a, n / 2) % mod) * a % mod); } } int main() { int N; cin >> N; ll A[10000]; map<ll, int>mp; for (int i = 0; i < N; i++) { cin >> A[i]; mp[A[i]]++; } int P = N / 2; bool isValid = true; if (N % 2 == 0) { if (mp.size() != P) { isValid = false; } for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) { if (it->second != 2) { isValid = false; } } } else { if (mp.size() != P + 1) { isValid = false; } for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) { if (it->first == 0) { if (it->second != 1) { isValid = false; } } else { if (it->second != 2) { isValid = false; } } } } if (!isValid) { cout << 0 << endl; } else { cout << pow(2, P) % mod << endl; } return 0; }
a.cc: In function 'int main()': a.cc:52:59: error: conversion from '_Rb_tree_iterator<pair<const long long int,[...]>>' to non-scalar type '_Rb_tree_iterator<pair<const int,[...]>>' requested 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ~~~~~~~~^~ a.cc:52:66: error: no match for 'operator!=' (operand types are 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'}) 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ~~ ^~ ~~~~~~~~ | | | | | _Rb_tree_iterator<pair<const long long int,[...]>> | _Rb_tree_iterator<pair<const int,[...]>> 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:1: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::fpos<_StateT>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ In file included from /usr/include/c++/14/string:43, 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: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::allocator<_CharT>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::_Rb_tree_iterator<std::pair<const int, int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::_Rb_tree_iterator<std::pair<const int, int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ /usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:52:76: note: 'std::_Rb_tree_iterator<std::pair<const long long int, int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>' 52 | for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) | ^ /usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::opera
s545105939
p03848
C++
#include <bits\stdc++.h> using namespace std; int n,cnt[1000005],i,x; long long ans; int main() { cin>>n; for (i=1;i<=n;i++) { cin>>x; cnt[x]++; } if (n&1) { for (i=2;i<=n;i+=2) { if (cnt[i]!=2) { cout<<0; return 0; } } if (cnt[0]!=1) { cout<<0; return 0; } } else { for (i=1;i<=n;i+=2) { if (cnt[i]!=2) { cout<<0; return 0; } } } ans=1; for (i=1;i<=n/2;i++) (ans*=2)%=((long long)1e9+7); cout<<ans; return 0; }
a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory 1 | #include <bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s180677345
p03848
C++
#include <bits\stdc++.h> using namespace std; int n,cnt[1000005],i,x; long long ans; int main() { cin>>n; for (i=1;i<=n;i++) { cin>>x; cnt[x]++; } if (n&1) { for (i=2;i<=n;i+=2) { if (cnt[i]!=2) { cout<<0; return 0; } } if (cnt[0]!=1) { cout<<0; return 0; } } else { for (i=1;i<=n;i+=2) { if (cnt[i]!=2) { cout<<0; return 0; } } } ans=1; for (i=1;i<=n/2;i++) (ans*=2)%=((long long)1e9+7); cout<<ans; return 0; }
a.cc:1:10: fatal error: bits\stdc++.h: No such file or directory 1 | #include <bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s681364908
p03848
C++
#include<bits/stdc++.h> using namespace std; const int MAXN=100010; int x[MAXN],c[2*MAXN]; int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>x[i]; c[x[i]]++; } bool nemoguce=false; if(n%2==0){ for(int i=1;i<=n;i+=2){ if(c[i]!=2){ nemoguce=true; break; } } } if(n%2==1){ if(c[0]>1) nemoguce=true; if(!nemoguce){ for(int i=2;i<=n;i+=2){ if(c[i]!=2){ nemoguce=true; break; } } } } long long int r; if(nemoguce) r=0; else{ r=1; for(int i=0;i<n/2;i++){ r*=2; r%=pow(10,9)+7; } } cout<<r; return 0; }
a.cc: In function 'int main()': a.cc:38:26: error: invalid operands of types 'long long int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%' 38 | r%=pow(10,9)+7; | ~^~~~~~~~~~~~~ a.cc:38:26: note: in evaluation of 'operator%=(long long int, __gnu_cxx::__promote<double>::__type {aka double})'
s187733576
p03848
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <numeric> #include <stack> #include <queue> #include <map> #include <set> #include <utility> #include <sstream> #include <complex> #include <fstream> #include <bitset> using namespace std; #define FOR(i,a,b) for(long long i=(a);i<(b);i++) #define REP(i,N) for(long long i=0;i<(N);i++) #define ALL(s) (s).begin(),(s).end() #define fi first #define se second typedef long long ll; typedef pair<ll, ll> P; typedef vector<ll> V; #define PI acos(-1.0) #define EPS 1e-10 const ll INF = 1e9 + 7; const ll MOD = 1e9 + 7; ll n; ll a[100100]; ll sq(ll num){ return num*num; } ll mod_pow(ll num, ll k){ if (k == 0)return 1; if (k == 1)return num; ll res = sq(mod_pow(num, k / 2)); res %= INF; if (k % 2 == 1){ res *= num; res %= INF; } return res; } int main(){ cin >> n; REP(i, n)cin >> a[i]; sort(a, a + n); //bool f = 1; //int cnt; //if (n % 2 == 0)cnt = 1; //else cnt = 0; //REP(i, n){ // if (cnt != a[i])f = 0; // if (n % 2 == 0){ // if (i % 2 == 1)cnt += 2; // } // else{ // if (i % 2 == 0)cnt += 2; // } //} ll ans = mod_pow(2, n / 2); if (f)cout << ans << endl; else cout << 0 << endl; }
a.cc: In function 'int main()': a.cc:73:13: error: 'f' was not declared in this scope 73 | if (f)cout << ans << endl; | ^
s562615984
p03848
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long int n; cin >> n; vector <int> a,b ; for(int i =0; i < n; i++){ int tmp; cin >> tmp; b.push_back (tmp); a.push_back(abs (n-2*i-1)); } sort(a.begin(), a.end ()); bool flag = true; for(int i = 0; i <n; i++){ if(a[i]!=b[i]) flag = false; } if(!flag) ans=0; if(n%2!=0) n--; n/=2; long long int ans = 1; for(int i = 0; i <n; i++){ ans *= 2; ans %= 1000000007; } cout << ans << endl ; }
a.cc: In function 'int main()': a.cc:20:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 20 | if(!flag) ans=0; | ^~~ | abs
s933871393
p03848
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long int n; cin >> n; if(n%2!=0) n--; n/=2; long long int ans = 1; for(int i = 0; i <n i++;){ ans *= 2; ans %= 1000000009; } cout << ans << endl ; }
a.cc: In function 'int main()': a.cc:10:20: error: expected ';' before 'i' 10 | for(int i = 0; i <n i++;){ | ^~ | ; a.cc:10:24: error: expected ')' before ';' token 10 | for(int i = 0; i <n i++;){ | ~ ^ | ) a.cc:10:25: error: expected primary-expression before ')' token 10 | for(int i = 0; i <n i++;){ | ^
s894669716
p03848
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long int n; cin >> n; if(n%2!=0) n--; n/=2; long long int ans = 1; for(i = 0; i <n i++;){ ans *= 2; ans %= 1000000009; } cout << ans << endl ; }
a.cc: In function 'int main()': a.cc:10:5: error: 'i' was not declared in this scope 10 | for(i = 0; i <n i++;){ | ^ a.cc:10:16: error: expected ';' before 'i' 10 | for(i = 0; i <n i++;){ | ^~ | ; a.cc:10:20: error: expected ')' before ';' token 10 | for(i = 0; i <n i++;){ | ~ ^ | ) a.cc:10:21: error: expected primary-expression before ')' token 10 | for(i = 0; i <n i++;){ | ^
s058247601
p03848
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long int n; cin >> n; if(n%2!=0) n--; n/=2; ans = 1; for(i = 0; i <n i++;){ ans *= 2; ans %= 1000000009; } cout << ans << endl ; }
a.cc: In function 'int main()': a.cc:9:1: error: 'ans' was not declared in this scope; did you mean 'abs'? 9 | ans = 1; | ^~~ | abs a.cc:10:5: error: 'i' was not declared in this scope 10 | for(i = 0; i <n i++;){ | ^ a.cc:10:16: error: expected ';' before 'i' 10 | for(i = 0; i <n i++;){ | ^~ | ; a.cc:10:20: error: expected ')' before ';' token 10 | for(i = 0; i <n i++;){ | ~ ^ | ) a.cc:10:21: error: expected primary-expression before ')' token 10 | for(i = 0; i <n i++;){ | ^
s331934821
p03848
C++
#include <iostream> #include <vector> using namespace std; typedef long long lli; lli n; vector<lli> a; int error(){ cout << 0 << endl; return 0; } int main(int argc, char const *argv[]) { cin >> n; a = vector<lli> (n); for(lli i = 0;i < n;i++) cin >> a[i]; sort(a.begin(),a.end()); if(n%2 == 0){ for(lli i = 1,j = 0;j < n;i+=2){ if(a[j++] != i) return error(); if(a[j++] != i) return error(); } }else{ if(a[0] != 0) return error(); for(lli i = 2,j = 1;j < n;i += 2){ if(a[j++] != i) return error(); if(a[j++] != i) return error(); } } cout << (n/2)*(n/2) << endl; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:16:5: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(a.begin(),a.end()); | ^~~~ | short
s545121600
p03848
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 1e9 int main(){ int i = 0,N,A[N-1]; cin>>N; while (i < N) { cin>>A[i]; i++; } if (N%2 = 0) { cout<<pow(2,N-1); } else { cout<<pow(2,(N-1)/2); } return 0; }
a.cc: In function 'int main()': a.cc:17:8: error: lvalue required as left operand of assignment 17 | if (N%2 = 0) { | ~^~
s801388794
p03848
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 1e9 int main(){ int i = 0,N,A[N-1]; cin>>N; while (i < N) { cin>>A[i]; i++; } if (N%2 = 0) { cout<<2**(N/2); } else { cout<<2**((N-1)/2); } return 0; }
a.cc: In function 'int main()': a.cc:17:8: error: lvalue required as left operand of assignment 17 | if (N%2 = 0) { | ~^~ a.cc:18:13: error: invalid type argument of unary '*' (have 'int') 18 | cout<<2**(N/2); | ^~~~~~ a.cc:20:13: error: invalid type argument of unary '*' (have 'int') 20 | cout<<2**((N-1)/2); | ^~~~~~~~~~
s899573703
p03848
C++
#include <iostream> #include <vector> #include <queue> using namespace std; long long pow(int a, int b, int mod) { int ret = 1; for(int i = 0 ; i < b ; i ++){ ret = ret * a % mod; } return ret; } int main(void){ long long n; cin>>n; vector<int> v(n); for(int i = 0 ; i < n ; i ++){ cin>>v[i]; } int s = n-1; sort(v.begin(),v.end()); reverse(v.begin(),v.end()); if (n % 2 == 1) v.push_back(0); bool flag = true; for(int i = 0 ; i < n ; i ++){ int a = v[i++]; int b = v[i]; if (a == s && b == s && a == b){ flag = false; break; } s -= 2; } if (flag) cout<<pow(2, n/2, 1000000007)<<endl; else cout<<0<<endl; }
a.cc: In function 'int main()': a.cc:24:9: error: 'sort' was not declared in this scope; did you mean 'short'? 24 | sort(v.begin(),v.end()); | ^~~~ | short a.cc:25:9: error: 'reverse' was not declared in this scope 25 | reverse(v.begin(),v.end()); | ^~~~~~~
s288019629
p03848
C++
//I_F_A #include "bits/stdc++.h" using namespace std; bool func(long long *arr,long long n){ if(n%2 == 0){ for(long long i=1;i<=n;i+=2){ if(arr[i] != i || arr[i+1] != i){ return 0; } } } else{ if(arr[1] != 0){ return 0; } for(long long i=2;i<=n;i=i+2){ if(arr[i] != i || arr[i+1] != i){ return 0; } } } return 1; } long long power(long long a,long long n,long long mod){ if(n == 0) return 1; if(n == 1) return a; long long x = power(a,n>>1); x = ((x%mod)*(a%mod))%mod; if(n & 1) x = ((x%mod)*(a%mod))%mod; return x; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long arr[n+1]; for(long long i=1;i<=n;i++) cin >> arr[i]; if(!func(arr,n)){ cout << 0 << endl; } else{ cout << power(2LL,n>>1,1000000007LL); } }
a.cc: In function 'long long int power(long long int, long long int, long long int)': a.cc:41:28: error: too few arguments to function 'long long int power(long long int, long long int, long long int)' 41 | long long x = power(a,n>>1); | ~~~~~^~~~~~~~ a.cc:34:11: note: declared here 34 | long long power(long long a,long long n,long long mod){ | ^~~~~
s535574472
p03848
C++
//I_F_A #include "bits/stdc++.h" using namespace std; bool func(long long *arr,long long n){ if(n%2 == 0){ for(long long i=1;i<=n;i+=2){ if(arr[i] != i || arr[i+1] != i){ return 0; } } } else{ if(arr[1] != 0){ return 0; } for(long long i=2;i<=n;i=i+2){ if(arr[i] != i || arr[i+1] != i){ return 0; } } } return 1; } long long func(long long a,long long n,long long mod){ if(n == 0) return 1; if(n == 1) return a; long long x = power(a,n>>1); x = ((x%mod)*(a%mod))%mod; if(n & 1) x = ((x%mod)*(a%mod))%mod; return x; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long arr[n+1]; for(long long i=1;i<=n;i++) cin >> arr[i]; if(!func(arr,n)){ cout << 0 << endl; } else{ cout << power(2LL,n>>1,1000000007LL); } }
a.cc: In function 'long long int func(long long int, long long int, long long int)': a.cc:41:23: error: 'power' was not declared in this scope 41 | long long x = power(a,n>>1); | ^~~~~ a.cc: In function 'int main()': a.cc:69:25: error: 'power' was not declared in this scope 69 | cout << power(2LL,n>>1,1000000007LL); | ^~~~~
s823936430
p03848
C++
de <iostream> #include <vector> #include <cmath> #define MOD 1000000007 using namespace std; int main() { int n; int a[n]; cin >> n; int num[n]; for (int i = 0; i < n; i++) { num[i] = 0; } for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j <= n; j++) { if (j == a[i]) { num[j]++; } } } long long int ans = 0; bool is_correct = true; if (n % 2 == 1) { if (num[0] != 1) { is_correct = false; } for (int i = 2; i <= n - 1; i += 2) { if (num[i] != 2) { is_correct = false; break; } } if (is_correct) { int tmp = (n - 1) / 2; ans = 1; for (int i = 0; i < tmp; i++) { ans *= 2; } } else { ans = 0; } } else { if (num[0] != 0) { is_correct = false; } for (int i = 1; i <= n - 1; i += 2) { if (num[i] != 2) { is_correct = false; break; } } if (is_correct) { int tmp = n / 2; ans = 1; for (int i = 0; i < tmp; i++) { ans *= 2; } } else { ans = 0; } } ans = ans % MOD; cout << ans << endl; return 0; }
a.cc:1:1: error: 'de' does not name a type 1 | de <iostream> | ^~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
s472951278
p03848
C++
test
a.cc:1:1: error: 'test' does not name a type 1 | test | ^~~~
s587794011
p03848
C++
#include <map> #include <set> #include <queue> #include <stack> #include <cmath> #include <vector> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include<functional> #include<fstream> #include<iomanip> #include<windows.h> using namespace std; typedef long long ll; #define for1(x,y,z) for(int z=x;z<=y;z++) #define for2(x,y,z) for(int z=x;z>=y;z--) #define pd(x) printf("%d\n",x) #define plld(x) printf("%lld\n",x) #define pI64d(x) printf("%I64d\n",x) #define pi 3.141592653 const int INF=0x3f3f3f3f; const int N=1e6; const int MOD=1e9+7; int a[N],v[N]; int main() { int n; while(~scanf("%d",&n)) { int ans=1,f=0; memset(v,0,sizeof(v)); for(int i=0;i<n;i++) { scanf("%d",&a[i]); v[a[i]]++; if((a[i]==0&&v[0]>1)||(v[a[i]])>2) f=1; if(v[a[i]]==2) ans=ans*2%MOD; } if(f) printf("0\n"); else printf("%d\n",ans); } return 0; } /***************************************** ***************** LYQ *************** ***************** YES *************** *UserID: secrecy * *RunOJ: * *RunID: * *Submit time: * *Language: G++ * *Result: Accepted * *time: * *Memory: * *Length: * *School: NYIST * *Blog: http://blog.csdn.net/nyist_tc_lyq * *QQ: * *Tel: * *****************************************/
a.cc:14:9: fatal error: windows.h: No such file or directory 14 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s230120239
p03848
C++
#include <iostream> #include <string> #include <vector> constexpr static int MAXN = 1e6; constexpr static int MOD = 1e9 + 7; using namespace std; int n; int a[MAXN]; int64_t solve() { int64_t r = 1; int val = n - 1; for (int i = 0; i < n; i++) { if (a[i] != val) return 0; if (i % 2 == 1) { r = (r * 2) % MOD; val -= 2; } } return r; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); reverse(a, a + n); printf("%lld\n", solve()); }
a.cc: In function 'int main()': a.cc:32:5: error: 'sort' was not declared in this scope; did you mean 'short'? 32 | sort(a, a + n); | ^~~~ | short a.cc:33:5: error: 'reverse' was not declared in this scope 33 | reverse(a, a + n); | ^~~~~~~
s267310615
p03848
Java
import java.io.*; import java.util.*; public class Main static long mod; static long modpow(int a,int b){ if(b == 0)return 1; long temp = modpow(a,b/2); temp = temp*1L*temp % mod; if((b & 1) == 1) temp = temp*a % mod; return temp; } public static void main(String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine()); int array[] = new int[n + 1]; mod = (long)1E9 + 7; int cnt[] = new int[n]; for(int i = 1;i <= n;i++) { array[i] = Integer.parseInt(st.nextToken()); cnt[array[i]]++; } if((n & 1) == 1){ for(int i = 2;i < array.length;i+=2){ if(cnt[i] != 2 || cnt[0] != 1){ System.out.println("0"); return; } } long ways = modpow(2,n/2); System.out.println(ways); } if((n & 1) == 0){ //System.out.println((n & 1) == 0); for(int i = 1;i < array.length;i+=2){ if(cnt[i] != 2){ System.out.print("0"); return; } } long ways = modpow(2,n/2); System.out.print(ways); } } }
Main.java:3: error: '{' expected public class Main ^ Main.java:5: error: unnamed classes are a preview feature and are disabled by default. static long modpow(int a,int b){ ^ (use --enable-preview to enable unnamed classes) Main.java:46: error: class, interface, enum, or record expected } ^ 3 errors
s643248599
p03848
C++
#include <iostream> #include <vector> #include <cmath> #include <cstdio> #include <string> #include <algorithm> #include <queue> #define ll long long using namespace std; #define MOD 1000000007 class AdditionAndSubtractionHard { public: int n; vector<ll> a; vector<string> op; vector<vector<ll > > dp; AdditionAndSubtractionHard(){ cin >> n; op.push_back("+"); for (int i = 0; i < 2*n-1; ++i) { if(i % 2 == 0){ ll tmp; cin >> tmp; a.push_back(tmp); }else{ string tmpOp; cin >> tmpOp; op.push_back(tmpOp); } } } void exec(){ dp.resize(n+1); for (int i = 0; i < n; ++i) { dp[i].resize(2); // dp[i][0].resize(2); // dp[i][1].resize(2); } dp[0][0] = a[0]; dp[0][1] = -1 * MOD; // dp[n][1]の時は、符号が反対になっている。 dp[0][2] = -1 * MOD; int flag = 0; for (int i = 1; i < n; ++i) { // if(flag >= 2){ // dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] + a[i]); // dp[i][1] = max(dp[i-1][0] + a[i], dp[i-1][1] + a[i]); // continue; // } if(op[i] == "+"){ dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i], dp[i-1][2] + a[i]); dp[i][1] = dp[i-1][1] - a[i]; dp[i][2] = dp[i-1][2] + a[i]; }else{ dp[i][0] = max(dp[i-1][1] + a[i], max(dp[i-1][0] - a[i], dp[i-1][2] - a[i]) ); dp[i][1] = max(dp[i-1][1] + a[i], max(dp[i-1][0] - a[i], dp[i-1][2] - a[i]) ); dp[i][2] = dp[i-1][2] - a[i]; flag++; } // cout << dp[i][0] << " " << dp[i][1] << endl; } cout << max(dp[n-1][0], dp[n-1][1]) << endl; } }; int main(){ AdditionAndSubtractionHard aash = AdditionAndSubtractionHard(); aash.exec(); }
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: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:59:19: required from here 59 | dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i], dp[i-1][2] + a[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~
s294035829
p03848
C++
#include <iostream> #include <vector> #include <cmath> #include <cstdio> #include <string> #include <algorithm> #include <queue> #define ll long long using namespace std; #define MOD 1000000007 class AdditionAndSubtractionHard { public: int n; vector<ll> a; vector<string> op; vector<vector<ll > > dp; AdditionAndSubtractionHard(){ cin >> n; op.push_back("+"); for (int i = 0; i < 2*n-1; ++i) { if(i % 2 == 0){ ll tmp; cin >> tmp; a.push_back(tmp); }else{ string tmpOp; cin >> tmpOp; op.push_back(tmpOp); } } } void exec(){ dp.resize(n+1); for (int i = 0; i < n; ++i) { dp[i].resize(2); // dp[i][0].resize(2); // dp[i][1].resize(2); } dp[0][0] = a[0]; dp[0][1] = -1 * MOD; // dp[n][1]の時は、符号が反対になっている。 dp[0][2] = -1 * MOD; int flag = 0; for (int i = 1; i < n; ++i) { if(flag >= 2){ dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] + a[i]); dp[i][1] = max(dp[i-1][0] + a[i], dp[i-1][1] + a[i]); continue; } if(op[i] == "+"){ dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i], dp[i-1][2] + a[i]); dp[i][1] = dp[i-1][1] - a[i]; dp[i][2] = dp[i-1][2] + a[i]; }else{ dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][0] - a[i], dp[i-1][2] - a[i]); dp[i][1] = max(dp[i-1][1] + a[i], dp[i-1][0] - a[i], dp[i-1][2] - a[i]); dp[i][2] = dp[i-1][2] - a[i]; flag++; } // cout << dp[i][0] << " " << dp[i][1] << endl; } cout << max(dp[n-1][0], dp[n-1][1]) << endl; } }; int main(){ AdditionAndSubtractionHard aash = AdditionAndSubtractionHard(); aash.exec(); }
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: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:59:19: required from here 59 | dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i], dp[i-1][2] + a[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~
s008582246
p03848
C++
using namespace std; const int MOD=1000000007; int row[10010],N; int main(){ scanf("%d",&N); int tmp,index; for(int i=0;i<N;i++){ scanf("%d",&tmp); index=((N+tmp-1)/2)+1; tmp=index; row[index]++; index=N-index+1; if(index!=tmp){ row[index]++; } } int ans=1; /* for(int i=0;i<=N;i++){ printf("%d\n",row[i]); } */ for(int i=1;i<=(N+1)/2;i++){ if(row[i]%2==1 && i!=(N+1)/2){ ans=0; } ans=(ans*row[i])%MOD; } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: 'scanf' was not declared in this scope 5 | scanf("%d",&N); | ^~~~~ a.cc:30:9: error: 'printf' was not declared in this scope 30 | printf("%d\n",ans); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | using namespace std;
s013035775
p03848
C++
/* ____________ ______________ __ / _________ /\ /_____ _____/\ / /\ / /\ / / \\ / /\ \ \ / / \ / / \_____/ / / \__/ / \____\/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /___/____/ / / / / / / /___/________ /____________/ / /__/ / /______________/\ \ \ / \ \ / \ \ \ \____________\/ \__\/ \______________\/ ___ ___ ___ __________ / /\ / /\ / /\ /_______ /\ / /__\___/ / \ / / \ \ / / \ /____ ____/ / / / / \____/ / / \ / /\ \ / / / / / / / \_/ / \___\/ ___ / / / / / / / / / / /\ / / / / / / / / / / /__\__/ / / / /___/____ /___/ / /___________/ / /___________/\ \ \ / \ \ / \ \ \ \___\/ \___________\/ \___________\/ A FAN OF FIZZYDAVID */ #include<bits/stdc++.h> #define HEAP priority_queue #define rep(i,n) for(int i=0;i<(n);i++) #define per(i,n) for(int i=(n)-1;i>=0;i--) #define forn(i,l,r) for(int i=(l);i<=(r);i++) #define nrof(i,r,l) for(int i=(r);i>=(l);i--) #define mp make_pair #define mt make_tuple #define pb push_back #define X first #define Y second #define eps 1e-6 #define pi 3.1415926535897932384626433832795 #define orz int #define yjz main #define fizzydavid return #define ak 0 #define la ; #define SZ(x) (int)x.size() #define ALL(x) x.begin(),x.end() #define FILL(a,b) memset((a),(b),sizeof((a))) using namespace std; typedef long long LL; typedef double flt; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<LL> vl; typedef pair<int,LL> pil; typedef pair<LL,int> pli; typedef pair<LL,LL> pll; typedef vector<pil> vil; typedef vector<pii> vii; const int iinf=1e9+7; const LL linf=1ll<<60; const flt dinf=1e10; template <typename T> inline void scf(T &x) { bool f=0; x=0; char c=getchar(); while((c<'0' || c>'9') && c!='-') c=getchar(); if(c=='-') { f=1; c=getchar(); } while(c>='0' && c<='9') { x=x*10+c-'0'; c=getchar(); } if(f) x=-x; return; } template <typename T1,typename T2> void scf(T1 &x,T2 &y) { scf(x); return scf(y); } template <typename T1,typename T2,typename T3> void scf(T1 &x,T2 &y,T3 &z) { scf(x); scf(y); return scf(z); } template <typename T1,typename T2,typename T3,typename T4> void scf(T1 &x,T2 &y,T3 &z,T4 &w) { scf(x); scf(y); scf(z); return scf(w); } #ifdef ONLINE_JUDGE #define debug(x) ; #else #define DEBUG #define debug(x) cerr<<#x<<"="<<x<<endl; #endif //---------------------------head---------------------------- const int N=1e5+100; const int mod=1e9+7; int n; int a[N],cnt[N]; void zero() { puts("0"); exit(0); } orz yjz() { scf(n); forn(i,1,n) scf(a[i]), cnt[a[i]]++; if(n&1) { if(cnt[0]!=1) { zero(); } for(int i=2;i<=n;i+=2) if(cnt[i]!=2) zero(); int ans=1; for(int i=2;i<=n;i+=2) { ans<<=1; ans%=mod; } printf("%d\n",ans); } else { int ans=1; for(int i=1;i<=n;i+=2) { if(cnt[i]!=2) zero(); ans<<=1; ans%=mod } printf("%d\n",ans); } fizzydavid ak la }
a.cc: In function 'int main()': a.cc:136:21: error: expected ';' before '}' token 136 | ans%=mod | ^ | ; 137 | } | ~
s102733593
p03848
C++
#include<iostream> #include<cmath> #include<algorithm> using namespace std; const int MAX = 1e+5, M = 1e+9 + 7; int N; int C[MAX]; //C[i]:i番目の出現回数 void input() { memset(C, 0, sizeof(C)); cin >> N; for (int i = 0; i < N; i++) { int j; //scanf("%d", &j); cin >> j; C[j]++; } } void solve() { double coun = 0; //偶数人並んでいる場合 if (N % 2 == 0) { int i = N - 1; while (i >= 0) { /*if (C[i]%2==1) { cout << 0 << endl; return; } else { coun++; i -= 2; }*/ if (C[i] == 2) { coun++; i -= 2; } else { cout << 0 << endl; return; } } } else { //奇数個の場合 int i = N - 1; while (i >= 1) { /*if (C[i] == 1) { cout << 0 << endl; return; } else { coun++; i -= 2; }*/ if (C[i] == 2) { coun++; i -= 2; } else { cout << 0 << endl; return; } } if (C[i] != 1) { cout << 0 << endl; return; } } long long ans = pow(2, coun); ans = ans%M; cout << ans << endl; } int main() { input(); solve(); return 0; }
a.cc: In function 'void input()': a.cc:12:9: error: 'memset' was not declared in this scope 12 | memset(C, 0, sizeof(C)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s352736345
p03848
C++
#include<iostream> #include<cmath> using namespace std; const int MAX = 1e+5, M = 1e+9 + 7; int N; int C[MAX]; //C[i]:i番目の出現回数 void input() { memset(C, 0, sizeof(C)); cin >> N; for (int i = 0; i < N; i++) { int j; scanf("%d", &j); C[j]++; } } void solve() { double coun = 0; //偶数人並んでいる場合 if (N % 2 == 0) { int i = N - 1; while (i >= 0) { /*if (C[i]%2==1) { cout << 0 << endl; return; } else { coun++; i -= 2; }*/ if (C[i] == 2) { coun++; i -= 2; } else { cout << 0 << endl; return; } } } else { //奇数個の場合 int i = N - 1; while (i >= 1) { /*if (C[i] == 1) { cout << 0 << endl; return; } else { coun++; i -= 2; }*/ if (C[i] == 2) { coun++; i -= 2; } else { cout << 0 << endl; return; } } if (C[i] != 1) { cout << 0 << endl; return; } } int ans = pow(2, coun); ans = ans%M; cout << ans << endl; } int main() { input(); solve(); return 0; }
a.cc: In function 'void input()': a.cc:11:9: error: 'memset' was not declared in this scope 11 | memset(C, 0, sizeof(C)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<cmath> +++ |+#include <cstring> 3 | using namespace std;
s620369372
p03848
C++
#include <iostream> #include <vector> using namespace std; using type = long; bool check(const vector<type>& A) { type N = A.size(); if (N % 2 == 0) { for (type i = 0; i < N; ++i) { if (i % 2 == 0 and A[i] != 0) return false; if (i % 2 == 1 and A[i] != 2) return false; } } else { if (A[0] != 1) return false; for (type i = 1; i < N; ++i) { if (i % 2 == 0 and A[i] != 2) return false; if (i % 2 == 1 and A[i] != 0) return false; } } return true; } int main() { type N; cin >> N; cout << ans << endl; vector<type> A(N, 0); for (type i = 0; i < N; ++i) { type Ai; cin >> Ai; ++A[Ai]; } type ans = 0; if (check(A)) { ans = 1; for (type i = 0; i < N/2; ++i) { ans *= 2; ans %= 1000000007; } } cout << ans << endl; return true; }
a.cc: In function 'int main()': a.cc:29:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 29 | cout << ans << endl; | ^~~ | abs
s026082566
p03848
C++
#include<iostream> #include<vector> #include<cstdio> #include<iterator> #include<algorithm> #include<string> using namespace std; #define MOD int(1e9+7) #define int long long int n, a[100000], flag[100000]; int mod_pow(int x, int n) { int res = 1; while (n > 0) { if (n & 1) res = res * x %MOD; x = x * x % MOD; n >>= 1; } return res; } signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; flag[a[i]]++; } if (flag[0] != 1 && n % 2) { cout << 0 << endl; return 0; } for (int i = 0; i < n; i++) { if (flag[a[i]] > 2) { cout << 0 << endl; return 0; } } cout << mod_pow(2, n / 2) << endl;; }
a.cc: In function 'long long int mod_pow(long long int, long long int)': a.cc:9:13: error: expected primary-expression before 'long' 9 | #define int long long | ^~~~ a.cc:8:13: note: in expansion of macro 'int' 8 | #define MOD int(1e9+7) | ^~~ a.cc:16:43: note: in expansion of macro 'MOD' 16 | if (n & 1) res = res * x %MOD; | ^~~ a.cc:9:13: error: expected primary-expression before 'long' 9 | #define int long long | ^~~~ a.cc:8:13: note: in expansion of macro 'int' 8 | #define MOD int(1e9+7) | ^~~ a.cc:17:29: note: in expansion of macro 'MOD' 17 | x = x * x % MOD; | ^~~
s283539106
p03848
Java
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; import java.util.PriorityQueue; import javafx.scene.effect.Light.Spot; public class Main { InputStream is; int __t__ = 1; int __f__ = 0; int __FILE_DEBUG_FLAG__ = __f__; String __DEBUG_FILE_NAME__ = "src/D2"; FastScanner in; PrintWriter out; /* MOD_CALCULATION */ int MOD = 1_000_000_007; long ADD(long a, long b) { return (a + b) % MOD; } long SUB(long a, long b) { return (a - b + MOD) % MOD; } long MULT(long a, long b) { return (a * b) % MOD; } long POW(long a, long x) { long res = 1; for ( ; x > 0; x >>= 1) { if (x % 2 == 1) res = MULT(res, a); a = MULT(a, a); } return res; } long DIV(long a, long b) { return MULT(a, POW(b, MOD - 2)); } /* end */ public void solve() { int n = in.nextInt(); int[] a = in.nextIntArray(n); Arrays.sort(a); if (n % 2 == 0) { int next = 1; for (int i = 0; i < n; i += 2, next += 2) { if (a[i] == next && a[i+1] == next) continue; else { System.out.println(0); return; } } System.out.println(POW(2, n/2)); } else { if (a[0] != 0) { System.out.println(0); return; } int next = 2; for (int i = 1; i < n; i += 2, next += 2) { if (a[i] == next && a[i+1] == next) continue; else { System.out.println(0); return; } } System.out.println(POW(2, (n - 1) / 2)); } } public void run() { if (__FILE_DEBUG_FLAG__ == __t__) { try { is = new FileInputStream(__DEBUG_FILE_NAME__); } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println("FILE_INPUT!"); } else { is = System.in; } in = new FastScanner(is); out = new PrintWriter(System.out); Thread t = new Thread(null, new Runnable() { @Override public void run() { solve(); } }, "lul", 1 << 30); t.start(); } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------"); System.out.println(); } public void debug(Object... obj) { System.out.println(Arrays.deepToString(obj)); } class FastScanner { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FastScanner(InputStream stream) { this.stream = stream; // stream = new FileInputStream(new File("dec.in")); } int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } int[][] nextIntMap(int n, int m) { int[][] map = new int[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextIntArray(m); } return map; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } long[][] nextLongMap(int n, int m) { long[][] map = new long[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextLongArray(m); } return map; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } double[][] nextDoubleMap(int n, int m) { double[][] map = new double[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextDoubleArray(m); } return map; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }
Main.java:11: error: package javafx.scene.effect.Light does not exist import javafx.scene.effect.Light.Spot; ^ 1 error
s379637951
p03848
Java
import java.io.*; import java.util.*; public class Main { static final int MOD = 1_000_000_007; void run() { int n = in.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); b[i] = Math.abs(n - 1 - 2 * i); } Arrays.sort(a); Arrays.sort(b); if (!Arrays.equals(a, b)) { out.println(0); return; } int ans = 1; for (int i = 0; i < n / 2; i++) { ans *= 2; ans %= MOD; } out.println(ans); } static MyScanner in; static PrintWriter out; public static void main(String[] args) throws IOException { boolean stdStreams = true; String fileName = pC.class.getSimpleName().replaceFirst("_.*", "").toLowerCase(); String inputFileName = fileName + ".in"; String outputFileName = fileName + ".out"; Locale.setDefault(Locale.US); BufferedReader br; if (stdStreams) { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else { br = new BufferedReader(new FileReader(inputFileName)); out = new PrintWriter(outputFileName); } in = new MyScanner(br); int tests = 1;//in.nextInt(); for (int test = 0; test < tests; test++) { new Main().run(); } br.close(); out.close(); } static class MyScanner { BufferedReader br; StringTokenizer st; MyScanner(BufferedReader br) { this.br = br; } void findToken() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } } String next() { findToken(); return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } }
Main.java:34: error: cannot find symbol String fileName = pC.class.getSimpleName().replaceFirst("_.*", "").toLowerCase(); ^ symbol: class pC location: class Main 1 error
s484202922
p03849
C
#include <cstdio> #include <map> #define int long long using namespace std; const int M = 1e9+7; map<int, int> a; int n; int dfs(int x) { if (a[x]) return a[x]; if (x % 2) return a[x] = (2 * dfs(x / 2) + dfs(x / 2 - 1)) % M; else return a[x] = (dfs(x / 2) + 2 * dfs(x / 2 - 1)) % M; } signed main() { a[0] = 1; a[1] = 2; scanf("%lld", &n); printf("%lld", dfs(n)); return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s256022131
p03849
C++
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ALL(obj) (obj).begin(), (obj).end() #define EPS (1e-9) #define INF (1e17) #define PI (acos(-1)) //const double PI = acos(-1); //const double EPS = 1e-15; //long long INF=(long long)1E17; //#define i_7 (long long)(1e9+7) #define i_7 998'244'353 long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } 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; } using namespace std; //using namespace boost::multiprecision; bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd_(b,a%b); } } long long lcm_(long long x, long long y){ return (x/gcd_(x,y))*y; } typedef P pair<long long, long long>; map<P, long long> mp; long long func(long long s, long long x){ long long res = 0; if(s < 0 || x < 0){ return 0; } if(s == 0 && x == 0){ return 1; } if(s == 1 && x == 0){ return 0; } if(s == 0 && x == 1){ return 0; } if(mp[P(s,x)] < 0){ res = 0LL - mp[P(s,x)]; return res; } res += func(s/2, x/2); res = mod(res); res += func((s-1)/2, (x-1)/2); res = mod(res); res += func((s-2)/2, x/2); res = mod(res); mp[P(s,x)] = 0LL - res; return res; } int main(){ long long n; cin>>n; long long ans = func(n,n); cout<<ans<<endl; return 0; }
a.cc:65:9: error: 'P' does not name a type; did you mean 'PI'? 65 | typedef P pair<long long, long long>; | ^ | PI a.cc:66:5: error: 'P' was not declared in this scope; did you mean 'PI'? 66 | map<P, long long> mp; | ^ | PI a.cc:66:17: error: template argument 1 is invalid 66 | map<P, long long> mp; | ^ a.cc:66:17: error: template argument 3 is invalid a.cc:66:17: error: template argument 4 is invalid a.cc: In function 'long long int func(long long int, long long int)': a.cc:81:9: error: 'P' was not declared in this scope 81 | if(mp[P(s,x)] < 0){ | ^ a.cc:91:6: error: 'P' was not declared in this scope 91 | mp[P(s,x)] = 0LL - res; | ^
s123551834
p03849
C++
#include<bits/stdc++.h> #define Rint register int using namespace std; typedef long long LL; typedef pair<LL, LL> pii; const int mod = 1e9 + 7; LL n; map<pii, int> M; inline void upd(int &a, int b){a += b; if(a >= mod) a -= mod;} inline int dfs(LL x, LL y){ if(!y) return 1; if(M.count(MP(x, y))) return M[MP(x, y)]; int res = dfs(x >> 1, y >> 1); upd(res, dfs(x - 1 >> 1, y - 1 >> 1)); if(y >= 2) upd(res, dfs(x >> 1, y - 2 >> 1)); return M[MP(x, y)] = res; } int main(){ scanf("%lld", &n); printf("%lld", M[MP(n, n)]); }
a.cc: In function 'int dfs(LL, LL)': a.cc:12:20: error: 'MP' was not declared in this scope; did you mean 'M'? 12 | if(M.count(MP(x, y))) return M[MP(x, y)]; | ^~ | M a.cc:16:18: error: 'MP' was not declared in this scope; did you mean 'M'? 16 | return M[MP(x, y)] = res; | ^~ | M a.cc: In function 'int main()': a.cc:20:26: error: 'MP' was not declared in this scope; did you mean 'M'? 20 | printf("%lld", M[MP(n, n)]); | ^~ | M
s401223309
p03849
C++
#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #define EPS 1e-9 #define PI acos(-1.0) #define INF 0x3f3f3f3f #define LL long long const int MOD = 1E9+7; const int N = 1000000+5; const int dx[] = {0,0,-1,1,-1,-1,1,1}; const int dy[] = {-1,1,0,0,-1,1,-1,1}; using namespace std; LL a[21]= {1, 2, 4, 5, 8, 10, 13, 14, 18, 21, 26, 28, 33, 36, 40, 41, 46, 50, 57, 60, 68, 73, 80, 82, 89, 94, 102, 105, 112, 116, 121, 122, 128, 133, 142}; map<LL,LL> mp; LL cal(LL x) { if(x<=20) return a[x]; if(mp[x]) return mp[x]; if(x%2) return mp[x]=(2*cal(x/2)%MOD+cal(x/2-1)%MOD)%MOD; else return mp[x]=(2*cal(x/2-1)%MOD+cal(x/2)%MOD)%MOD; } int main() { LL n; scanf("%lld",&n); printf("%lld\n",cal(n)); return 0; }
a.cc:27:31: error: too many initializers for 'long long int [21]' 27 | 122, 128, 133, 142}; | ^
s732470025
p03849
C++
あ#include <iostream> using namespace std; typedef long long ll; ll mod=1e9+7; ll f(ll n){ if(n==0) return 1; else if(n%2==0) return f(n/2)+f(n/2-1); else return f(n/2); } ll sum(ll n){ if(n==0) return 1; else if(n%2==0) return (3*sum(n/2-1)+f(n/2))%mod; else return (3*sum(n/2)-f(n/2))%mod; } int main(){ ll n; cin >> n; cout << sum(n) << endl; }
a.cc:1:3: error: stray '#' in program 1 | あ#include <iostream> | ^ a.cc:1:1: error: '\U00003042' does not name a type 1 | あ#include <iostream> | ^~ a.cc: In function 'int main()': a.cc:22:3: error: 'cin' was not declared in this scope 22 | cin >> n; | ^~~ a.cc:23:3: error: 'cout' was not declared in this scope 23 | cout << sum(n) << endl; | ^~~~ a.cc:23:21: error: 'endl' was not declared in this scope 23 | cout << sum(n) << endl; | ^~~~
s871514844
p03849
C++
#include <iostream> using namespace std; typedef long long ll; ll mod=1e9+7; ll f(ll n){ if(n==0) return 1; else if(n%2==0) return f(n/2)+f(n/2-1); else return f(n/2); } ll sum(ll n){ if(n%2==0) return (3*sum(n/2-1)+f(n/2))%mod; else return (3*sum(n/2)-f(n/2))%mod; } int main(){ ll n; cin >> n; cout << sum(n) << endl; }
a.cc:8:11: error: expected initializer before '\U0000ff5b' 8 | ll f(ll n){ | ^~ a.cc:10:3: error: expected unqualified-id before 'else' 10 | else if(n%2==0) return f(n/2)+f(n/2-1); | ^~~~ a.cc:11:3: error: expected unqualified-id before 'else' 11 | else return f(n/2); | ^~~~ a.cc:12:1: error: '\U0000ff5d' does not name a type 12 | } | ^~ a.cc:16:3: error: expected unqualified-id before 'else' 16 | else return (3*sum(n/2)-f(n/2))%mod; | ^~~~ a.cc:17:1: error: '\U0000ff5d' does not name a type 17 | } | ^~ a.cc:21:3: error: 'cin' does not name a type 21 | cin >> n; | ^~~ a.cc:22:3: error: 'cout' does not name a type 22 | cout << sum(n) << endl; | ^~~~ a.cc:23:1: error: '\U0000ff5d' does not name a type 23 | } | ^~
s680548840
p03849
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> #include <stack#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> #include <stack> #include <set> #include <map> typedef long long ll; using namespace std; const ll MOD = 1e9+7; ll dp[61][3]; // uのiビット目以降を確定させたとき、(N>>i)-(v>>i)がjとなる場合の数 void add(ll &a, ll b) { a = (a + b) % MOD; } int nth_bit(ll n, int i){ return (n >> i) & 1; } int main() { ll n; cin >> n; dp[60][0] = 1; for (int i = 59; i >= 0; i--) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { int tmp = min(2, 2 * j + nth_bit(n, i) - k); if (tmp >= 0) add(dp[i][tmp], dp[i+1][j]); } } } cout << (dp[0][0] + dp[0][1] + dp[0][2]) % MOD << "\n"; return 0; } #include <set> #include <map> typedef long long ll; using namespace std; const ll MOD = 1000000007; ll dp[61][100005]; void add(ll &a, ll &b) { a = (a + b) % MOD; } int main() { ll n; cin >> n; dp[60][0] = 1; for (int i = 59; i >= 0; i--) { for (int j = 0; j <= n; j++) { // aもbも1 if (j + 2 * (1LL << i) <= n) { add(dp[i][j + 2 * (1LL << i)], dp[i+1][j]); } // abのどちらかが1 if (j + (1LL << i) <= n) { add(dp[i][j + (1LL << i)], dp[i+1][j]); } // aもbも0 add(dp[i][j], dp[i+1][j]); } } int ans = 0; for (int j = 0; j <= n; j++) { ans += dp[0][j]; } cout << ans << "\n"; return 0; }
a.cc:9:10: fatal error: stack#include <algorithm: No such file or directory 9 | #include <stack#include <algorithm> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s348337391
p03849
C++
#include <bits/stdc++.h> #define int long long using namespace std; std::vector<int> v(61),w(61); const int INF=1e9+7; int dp[600000][50]; int dfs(int S,int X){ if(S<600000&&S>=0&&X<=50&&X>=0)int &res=dp[S][X]; else int res=-2; if(res==-1)return res; if(S<0){res=0;return res;} if(S>(v[X]-1)*2){res=w[X];return res;} if(S==0&&X==0){res=1;return res;} res=(dfs(S,X-1)+dfs(S-v[X-1],X-1)+dfs(S-v[X],X-1))%INF;return res; } signed main(){ v[0]=1;for(int i=1;i<61;i++)v[i]=v[i-1]*2; w[0]=1;for(int i=1;i<61;i++)w[i]=w[i-1]*3; memset(dp,-1,sizeof(dp)); int N; cin>>N; cout<<dfs(N,60)<<endl; }
a.cc: In function 'long long int dfs(long long int, long long int)': a.cc:11:6: error: 'res' was not declared in this scope 11 | if(res==-1)return res; | ^~~ a.cc:12:11: error: 'res' was not declared in this scope 12 | if(S<0){res=0;return res;} | ^~~ a.cc:13:20: error: 'res' was not declared in this scope 13 | if(S>(v[X]-1)*2){res=w[X];return res;} | ^~~ a.cc:14:18: error: 'res' was not declared in this scope 14 | if(S==0&&X==0){res=1;return res;} | ^~~ a.cc:15:3: error: 'res' was not declared in this scope 15 | res=(dfs(S,X-1)+dfs(S-v[X-1],X-1)+dfs(S-v[X],X-1))%INF;return res; | ^~~
s184375032
p03849
C++
#include<iostream> #include<algorithm> using namespace std; long dp[66][3],m=1e9+7,n; int b; main(){ cin>>n; dp[60][0]=1; for(int i=59;i>=0;i--){ b=(n>>i)&1; for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ if(j*2+b>=k){ (dp[i][min(j*2+b-k,2)]+=dp[i+1][j])%=m; } } } }
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:18:2: error: expected '}' at end of input 18 | } | ^ a.cc:6:7: note: to match this '{' 6 | main(){ | ^
s218619734
p03849
C++
#include <iostream> #include <vector> #include <bitset> using namespace std; using ll = long long; const ll MOD = (ll)1e9 + 7; int main() { ll N; cin >> N; bitset<60> bs(N); vector<vector<long long>> dp(61, vector<long long>(3, 0)); dp[60][0] = 1; for (int i = 60; i >= 1; --i) { if (bs[i - 1]) { dp[i - 1][0] = dp[i][0]; dp[i - 1][1] = dp[i][0] + dp[i][1]; dp[i - 1][2] = 2 * dp[i][1] + 3 * dp[i][2]; } else { dp[i - 1][0] = dp[i][0] + dp[i][1]; dp[i - 1][1] = dp[i][1]; dp[i - 1][2] = dp[i][1] + 3 * dp[i][2]; } dp[i - 1][0] %= MOD; dp[i - 1][1] %= MOD; dp[i - 1][2] %= MOD; } cout << (((dp[0][0] + dp[0][1]) % MOD) + dp[0][2]) % MOD << endl return 0; }
a.cc: In function 'int main()': a.cc:29:73: error: expected ';' before 'return' 29 | cout << (((dp[0][0] + dp[0][1]) % MOD) + dp[0][2]) % MOD << endl | ^ | ; 30 | return 0; | ~~~~~~
s102737344
p03849
C++
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #include<numeric> #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 1000000007 #define MAX 100001 #define INF 1410065408 #define EPS 1e-9 using namespace std; typedef long long ll; signed main(){ unsigned long long n; cin >> n; int digit = ceil(log2((double)n)); bitset<64> nbs(n); ll dp[digit][3]; fill(dp[0], dp[digit], 0); dp[digit-1][0] = 1; dp[digit-1][1] = 1; dp[digit-1][2] = 0; for(int i=digit-2;i>=0;i--){ if(nbs.test(i)){ dp[i][0] = dp[i+1][0]; dp[i][1] = (dp[i+1][0] + dp[i+1][1]) % MOD; dp[i][2] = (dp[i+1][1] * 2 + dp[i+1][2] * 3) % MOD; }else{ dp[i][0] = (dp[i+1][0] + dp[i+1][1]) % MOD; dp[i][1] = dp[i+1][1] % MOD; dp[i][2] = (dp[i+1][1] + dp[i+1][2] * 3) % MOD; } } cout << (accumulate(dp[0], dp[0]+3, 0LL) % MOD) << endl; }
a.cc: In function 'int main()': a.cc:33:5: error: 'bitset' was not declared in this scope 33 | bitset<64> nbs(n); | ^~~~~~ a.cc:13:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>' 12 | #include<numeric> +++ |+#include <bitset> 13 | a.cc:33:16: error: 'nbs' was not declared in this scope; did you mean 'abs'? 33 | bitset<64> nbs(n); | ^~~ | abs
s447178197
p03849
C++
#include<bits\stdc++.h> using namespace std; #define mod 1000000007 typedef long long ll; ll N; ll dp[100][5] = {0}; int main() { scanf("%lld",&N); dp[61][0] = 1; for(int i = 60; i >= 0; i--) { ll mem = (N >> i) & 1; dp[i][2] += dp[i + 1][2] * 3; if(mem) { dp[i][2] += dp[i + 1][1] * 2; dp[i][1] += dp[i + 1][1]; dp[i][1] += dp[i + 1][0]; dp[i][0] += dp[i + 1][0]; } else { dp[i][2] += dp[i + 1][1]; dp[i][1] += dp[i + 1][1]; dp[i][0] += dp[i + 1][1]; dp[i][0] += dp[i + 1][0]; } dp[i][0] %= mod; dp[i][1] %= mod; dp[i][2] %= mod; } printf("%lld\n",(dp[0][0] + dp[0][1] + dp[0][2]) % mod); return 0; }
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s619335815
p03849
C++
#include "stdafx.h" #include "iostream" #include "vector" #include "algorithm" #include "map" typedef long long i64; i64 n; i64 MODULO = (i64)(1e9 + 7); std::map<i64, std::map<i64, i64>> map; i64 f(i64 x, i64 y) { if (x == 0 && y == 0) return 1; if (x < 0 || y < 0) return 0; i64& ret = map[x][y]; if (ret != 0)return ret; ret += f(x >> 1, y >> 1); ret += f((x - 1) >> 1, (y - 1) >> 1); ret += f((x - 2) >> 1, y >> 1); ret %= MODULO; return ret%MODULO; } int main() { std::cin >> n; std::cout << f(n, n); return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s474994619
p03849
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> #include <bitset> 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 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) template<int32_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 (int32_t i = 1; i <= X; ++i) { res *= i; set[i] = res; } return set; } template<typename RET = mint, typename Integral> RET combination(Integral all, Integral get) { assert(all >= get); get = std::min(all - get, get); #if 1 //時間計算量O(logMOD) static const auto fact_v = fact_set_c<100001>(); return fact_v[all] / (fact_v[get] * fact_v[all - get]); #elif 0 //時間計算量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 } uint64_t N; bool used[62][3]; mint dp[62][3]; //下にi桁、0:OK 1:繰り上がり詰まる 2:繰り上がりNG mint func(int i, int ismax) { if (i < 0) { return 1_mi; } bool NI = (N&(1ui64 << i)) != 0; auto& memo = dp[i][ismax]; if (used[i][ismax]) { return memo; } used[i][ismax] = true; mint res = 0; if (ismax == 0) { res += func(i - 1, 0);//11 res += func(i - 1, 0);//10 res += func(i - 1, 0);//00 } else if(ismax==1) { res += func(i - 1, NI?1:2);//11 res += func(i - 1, NI?0:1);//10 res += func(i - 1, 0);//00 } else { //11 if (NI) { res += func(i - 1, 2); }//10 res += func(i - 1, NI ? 1 : 2);//00 } #if 0 //11 if (ismax!=2) { int next_max = 0; if (ismax == 1) { next_max = NI ? 1 : 2; } res += func(i - 1, next_max); } //10 if (NI || (ismax != 2)) { int next_max = -1; if (ismax == 2) { next_max = 2; } else if (ismax == 1) { next_max = NI?0:1; } else { next_max = 0; } res += func(i - 1, next_max); } //00 { int next_max = 0; if (ismax == 2) { next_max = NI ? 1 : 2; } res += func(i - 1, next_max); } #endif return memo = res; } int main() { using std::endl; in.sync_with_stdio(false); out.sync_with_stdio(false); in.tie(nullptr); out.tie(nullptr); in >> N; out << func(61, 2)<<endl; return 0; } #endif
a.cc: In function 'mint func(int, int)': a.cc:334:23: error: unable to find numeric literal operator 'operator""ui64' 334 | bool NI = (N&(1ui64 << i)) != 0; | ^~~~~
s428460084
p03849
C++
#include <stdio.h> #include <algorithm> #define MOD 1000000007 long long int N; int dp[70][3], bit, ans; int main() { scanf("%lld", &N); dp[0][0] = 1; bit = std::log2(N); for (int i = 0; i <= bit; ++i) { for (int j = 0; j < 3; ++j) { if (N >> (bit - i) & 1) { dp[i + 1][std::min(j * 2 + 1, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 + 1, 2)] %= MOD; dp[i + 1][std::min(j * 2, 2)] %= MOD; if ((j * 2 - 1) >= 0) { dp[i + 1][std::min(j * 2 - 1, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 - 1, 2)] %= MOD; } } else { dp[i + 1][std::min(j * 2, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2, 2)] %= MOD; if ((j * 2 - 1) >= 0) { dp[i + 1][std::min(j * 2 - 1, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 - 1, 2)] %= MOD; } if ((j * 2 - 2) >= 0) { dp[i + 1][std::min(j * 2 - 2, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 - 2, 2)] %= MOD; } } } } ans = dp[bit + 1][0] + dp[bit + 1][1] + dp[bit + 1][2]; ans %= MOD; printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:14:20: error: 'log2' is not a member of 'std' 14 | bit = std::log2(N); | ^~~~
s370052304
p03849
C++
#include <stdio.h> #include <algorithm> #define MOD 1000000007 long long int N; int dp[70][3], bit, ans; int main() { scanf("%lld", &N); dp[0][0] = 1; bit = log2(N); for (int i = 0; i <= bit; ++i) { for (int j = 0; j < 3; ++j) { if (N >> (bit - i) & 1) { dp[i + 1][std::min(j * 2 + 1, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 + 1, 2)] %= MOD; dp[i + 1][std::min(j * 2, 2)] %= MOD; if ((j * 2 - 1) >= 0) { dp[i + 1][std::min(j * 2 - 1, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 - 1, 2)] %= MOD; } } else { dp[i + 1][std::min(j * 2, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2, 2)] %= MOD; if ((j * 2 - 1) >= 0) { dp[i + 1][std::min(j * 2 - 1, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 - 1, 2)] %= MOD; } if ((j * 2 - 2) >= 0) { dp[i + 1][std::min(j * 2 - 2, 2)] += dp[i][j]; dp[i + 1][std::min(j * 2 - 2, 2)] %= MOD; } } } } ans = dp[bit + 1][0] + dp[bit + 1][1] + dp[bit + 1][2]; ans %= MOD; printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:14:15: error: 'log2' was not declared in this scope 14 | bit = log2(N); | ^~~~
s587105710
p03849
C++
#include <bits/stdc++.h> #define SZ(x) ((int) (x).size()) using namespace std; typedef long long i64; const int MOD = 1e9 + 7; int dp[64][2][3]; int main() { #ifdef LOCAL_RUN freopen("task.in", "r", stdin); freopen("task.out", "w", stdout); //freopen("task.err", "w", stderr); #endif // ONLINE_JUDGE ios::sync_with_stdio(false); cin.tie(0); int64_t n; cin >> n; dp[63][0][0] = 1; for (int k = 62; k >= 0; --k) { int64_t r = 1LL << k; for (int64_t cput: {0LL, r}) { for (int i = 0; i < 2; ++i) { for (int pi = 0; pi < 2; ++pi) { if (i == 0 && pi == 1) { continue; } if (i == 1 && pi == 0 && !((n & r) != 0 && cput == 0)) { continue; } if (i == 0 && pi == 0 && cput != (r & n)) { continue; } if (cput == 0) { if (n & r) { dp[k][i][2] += dp[k + 1][pi][1]; dp[k][i][2] %= MOD; dp[k][i][2] += dp[k + 1][pi][1]; dp[k][i][2] %= MOD; dp[k][i][2] += dp[k + 1][pi][2]; dp[k][i][2] %= MOD; dp[k][i][2] += dp[k + 1][pi][2]; dp[k][i][2] %= MOD; dp[k][i][1] += dp[k + 1][pi][0]; dp[k][i][1] %= MOD; } else { dp[k][i][0] += dp[k + 1][pi][0]; dp[k][i][0] %= MOD; dp[k][i][0] += dp[k + 1][pi][1]; dp[k][i][0] %= MOD; dp[k][i][2] += dp[k + 1][pi][1]; dp[k][i][2] %= MOD; dp[k][i][2] += dp[k + 1][pi][2]; dp[k][i][2] %= MOD; dp[k][i][2] += dp[k + 1][pi][2]; dp[k][i][2] %= MOD; } } else { if (n & r) { dp[k][i][0] += dp[k + 1][pi][0]; dp[k][i][0] %= MOD; dp[k][i][1] += dp[k + 1][pi][1]; dp[k][i][1] %= MOD; dp[k][i][2] += dp[k + 1][pi][2]; dp[k][i][2] %= MOD; } else { dp[k][i][1] += dp[k + 1][pi][1]; dp[k][i][1] %= MOD; dp[k][i][2] += dp[k + 1][pi][2]; dp[k][i][2] %= MOD; } } } } } } int ans = 0; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 3; ++j) { ans = (ans + dp[0][i][j]) % MOD; } } cout << ans << '\n'; }
a.cc: In function 'int main()': a.cc:25:35: error: unable to deduce 'std::initializer_list<auto>&&' from '{0, r}' 25 | for (int64_t cput: {0LL, r}) { | ^ a.cc:25:35: note: deduced conflicting types for parameter 'auto' ('long long int' and 'long int')
s430179869
p03849
C++
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Majk */ #include <vector> #include <iostream> #include <unordered_map> #include <map> #include <iomanip> #include <functional> #include <algorithm> #include <cassert> #include <cmath> #include <string> #include <sstream> #include <queue> using namespace std; #define x first typedef long long ll; template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; } #ifndef MOD_H #define MOD_H template <unsigned int N> class Field { typedef unsigned int ui; public: inline Field<N>&operator+=(const Field<N>&o) {if ((ll)v+o.v >= N) v = (ll)v+o.v-N; else v = v+o.v; return *this; } inline Field<N> operator+(const Field<N>&o) {Field<N>r(*this);return r+=o;}; private: ui v; }; template<unsigned int N>ostream &operator<<(std::ostream&os,const Field<N>&f){return os<<(unsigned int)f;} typedef Field<1000000007> FieldMod; #endif class B { public: void solve(istream& cin, ostream& cout) { ll N; cin >> N; FieldMod X[2] = {1,0}; FieldMod Ans=1; for (int i = 60; i >= 0; --i) { ll x = N >> i; if (x <= 0) continue; Ans = Ans*3 - X[0]*(2-x%2); X[x%2] = X[0] + X[1]; } cout << Ans << endl; } }; int main() { ios_base::sync_with_stdio(false); B solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }
a.cc: In member function 'void B::solve(std::istream&, std::ostream&)': a.cc:50:34: error: could not convert '1' from 'int' to 'FieldMod' {aka 'Field<1000000007>'} 50 | FieldMod X[2] = {1,0}; | ^ | | | int a.cc:50:36: error: could not convert '0' from 'int' to 'FieldMod' {aka 'Field<1000000007>'} 50 | FieldMod X[2] = {1,0}; | ^ | | | int a.cc:51:30: error: conversion from 'int' to non-scalar type 'FieldMod' {aka 'Field<1000000007>'} requested 51 | FieldMod Ans=1; | ^ a.cc:55:34: error: no match for 'operator*' (operand types are 'FieldMod' {aka 'Field<1000000007>'} and 'int') 55 | Ans = Ans*3 - X[0]*(2-x%2); | ~~~^~ | | | | | int | FieldMod {aka Field<1000000007>} a.cc:55:43: error: no match for 'operator*' (operand types are 'FieldMod' {aka 'Field<1000000007>'} and 'll' {aka 'long long int'}) 55 | Ans = Ans*3 - X[0]*(2-x%2); | ~~~~^~~~~~~~ | | | | | ll {aka long long int} | FieldMod {aka Field<1000000007>} a.cc: In instantiation of 'std::ostream& operator<<(std::ostream&, const Field<N>&) [with unsigned int N = 1000000007; std::ostream = std::basic_ostream<char>]': a.cc:58:11: required from here 58 | cout << Ans << endl; | ^~~ a.cc:39:90: error: invalid cast from type 'const Field<1000000007>' to type 'unsigned int' 39 | template<unsigned int N>ostream &operator<<(std::ostream&os,const Field<N>&f){return os<<(unsigned int)f;} | ^~~~~~~~~~~~~~~
s806411358
p03849
C++
inline long long int dfs(long long int b){ if (b == 0){ return 1; } if (b == 1){ return 3; } if (b == 2){ return 4; } if (b == 3){ return 7; } if (b == 4){ return 9; } if (b % 2 == 0){ long long int NN = b / 2; return ((dfs(NN - 2)) + (2LL * dfs(NN - 1)) + 2LL)%MOD; } return (2LL * dfs((b - 3) / 2LL) + dfs((b - 1LL) / 2LL)+2LL)%MOD; } lnog long in int main(){ long long int f; scanf("%lld", &f); printf("%lld\n", dfs(f)+1LL); return 0; }
a.cc: In function 'long long int dfs(long long int)': a.cc:19:68: error: 'MOD' was not declared in this scope 19 | return ((dfs(NN - 2)) + (2LL * dfs(NN - 1)) + 2LL)%MOD; | ^~~ a.cc:21:70: error: 'MOD' was not declared in this scope 21 | return (2LL * dfs((b - 3) / 2LL) + dfs((b - 1LL) / 2LL)+2LL)%MOD; | ^~~ a.cc: At global scope: a.cc:23:1: error: 'lnog' does not name a type; did you mean 'long'? 23 | lnog long in | ^~~~ | long
s133097938
p03849
C++
#include <iostream> #define int long long using namespace std; int n; //短いほうの1辺の長さがn, nは2のべき乗 int f(int n) { if (n == 1) return 1; return (f(n / 2) * 3) % 1000000007; } int g(int n) { return f(n); //もうまじむり } int main() { cin >> n; cout << g(n) << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s711288022
p03850
C++
#include <bits/stdc++.h> using namespace std; #define LL long long 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; } signed main(){ int n=read(); x=0,y=z=-10000000000000ll; for (int i=1;i<=n;++i){ LL p=read();x+=p;y-=p;z+=p; if (p<0){ z=max(y,z);y=max(x,y); } x=max(x,y);y=max(y,z); } cout<<x<<endl; return 0; }
a.cc: In function 'int main()': a.cc:18:9: error: 'x' was not declared in this scope 18 | x=0,y=z=-10000000000000ll; | ^ a.cc:18:13: error: 'y' was not declared in this scope 18 | x=0,y=z=-10000000000000ll; | ^ a.cc:18:15: error: 'z' was not declared in this scope 18 | x=0,y=z=-10000000000000ll; | ^
s095943618
p03850
C++
#include <bits/stdc++.h> template <class T> inline void read(T &res) { res = 0; bool bo = 0; char c; while (((c = getchar()) < '0' || c > '9') && c != '-'); if (c == '-') bo = 1; else res = c - 48; while ((c = getchar()) >= '0' && c <= '9') res = (res << 3) + (res << 1) + (c - 48); if (bo) res = ~res + 1; } template <class T> inline T Max(const T &a, const T &b) {return a > b ? a : b;} typedef long long ll; const int N = 2e5 + 5, M = 4e6 + 5; int n, a[N], add[N]; char s[M], op[N]; ll sum[N]; void work() { int tot = 1, m; a[1] = 0; read(n); getline(s + 1); m = strlen(s + 1); for (int i = 1; i <= m; i++) { if (s[i] == ' ') continue; if (s[i] == '+' || s[i] == '-') op[tot++] = s[i], a[tot] = 0; else a[tot] = a[tot] * 10 + s[i] - '0'; } for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; add[n] = 0; for (int i = n - 1; i >= 1; i--) add[i] = op[i] == '-' ? 0 : add[i + 1] + 1; ll cur = a[1], ans = -1e18; for (int i = 1; i < n; i++) if (op[i] == '-') ans = Max(ans, cur - (sum[i + 1 + add[i + 1]] - sum[i]) + sum[n] - sum[i + 1 + add[i + 1]]), cur -= a[i + 1]; else cur += a[i + 1]; printf("%lld\n", Max(cur, ans)); } int main() { T = 1; while (T--) work(); return 0; }
a.cc: In function 'void work()': a.cc:28:28: error: cannot convert 'char*' to 'char**' 28 | read(n); getline(s + 1); | ~~^~~ | | | char* In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, 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/stdio.h:697:45: note: initializing argument 1 of '__ssize_t getline(char**, size_t*, FILE*)' 697 | extern __ssize_t getline (char **__restrict __lineptr, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~ a.cc: In function 'int main()': a.cc:50:9: error: 'T' was not declared in this scope 50 | T = 1; | ^
s410487168
p03850
C++
#include <bits/stdc++.h> template <class T> inline void read(T &res) { res = 0; bool bo = 0; char c; while (((c = getchar()) < '0' || c > '9') && c != '-'); if (c == '-') bo = 1; else res = c - 48; while ((c = getchar()) >= '0' && c <= '9') res = (res << 3) + (res << 1) + (c - 48); if (bo) res = ~res + 1; } template <class T> inline T Max(const T &a, const T &b) {return a > b ? a : b;} typedef long long ll; const int N = 2e5 + 5, M = 4e6 + 5; int n, a[N], add[N]; char s[M], op[N]; ll sum[N]; void work() { int tot = 1, m; a[1] = 0; read(n); gets(s + 1); m = strlen(s + 1); for (int i = 1; i <= m; i++) { if (s[i] == ' ') continue; if (s[i] == '+' || s[i] == '-') op[tot++] = s[i], a[tot] = 0; else a[tot] = a[tot] * 10 + s[i] - '0'; } for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; add[n] = 0; for (int i = n - 1; i >= 1; i--) add[i] = op[i] == '-' ? 0 : add[i + 1] + 1; ll cur = a[1], ans = -1e18; for (int i = 1; i < n; i++) if (op[i] == '-') ans = Max(ans, cur - (sum[i + 1 + add[i + 1]] - sum[i]) + sum[n] - sum[i + 1 + add[i + 1]]), cur -= a[i + 1]; else cur += a[i + 1]; printf("%lld\n", Max(cur, ans)); } int main() { T = 1; while (T--) work(); return 0; }
a.cc: In function 'void work()': a.cc:28:18: error: 'gets' was not declared in this scope; did you mean 'getw'? 28 | read(n); gets(s + 1); | ^~~~ | getw a.cc: In function 'int main()': a.cc:50:9: error: 'T' was not declared in this scope 50 | T = 1; | ^
s439511388
p03850
C++
//@winlere #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; char __buf[1<<18],*__c=__buf,*__ed=__buf; inline int qr(){ int ret=0,f=0,c=getchar(); while(!isdigit(c)) f|=c==45,c=getchar(); while( isdigit(c)) ret=ret*10+c-48,c=getchar(); return f?-ret:ret; } const int maxn=1e5+5; int data[maxn],n; ll dp[maxn][3]; int main(){ memset(dp,0xcc,sizeof dp); n=qr(); for(int t=1;t<=n;++t) data[t]=qr(); dp[0][0]=0; for(int t=1;t<=n;++t){ if(data[t]>0){ dp[t][0]=max({dp[t][0],dp[t-1][0]+data[t],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); dp[t][1]=max({dp[t][1],dp[t-1][1]-data[t],dp[t-1][2]-data[t]}); dp[t][2]=max({dp[t][2],dp[t-1][2]+data[t]}); }else{ data[t]=-data[t]; dp[t][0]=max({dp[t][0],dp[t-1][0]-data[t],dp[t-1][1]-data[t],dp[t-1][2]-data[t]}); dp[t][1]=max({dp[t][1],dp[t-1][0]-data[t],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); dp[t][2]=max({dp[t][2],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); } } cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl; return 0; }
a.cc: In function 'int main()': a.cc:21:31: error: reference to 'data' is ambiguous 21 | for(int t=1;t<=n;++t) data[t]=qr(); | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/range_access.h: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:15:5: note: 'int data [100005]' 15 | int data[maxn],n; | ^~~~ a.cc:24:20: error: reference to 'data' is ambiguous 24 | if(data[t]>0){ | ^~~~ /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:15:5: note: 'int data [100005]' 15 | int data[maxn],n; | ^~~~ a.cc:25:59: error: reference to 'data' is ambiguous 25 | dp[t][0]=max({dp[t][0],dp[t-1][0]+data[t],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); | ^~~~ /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:15:5: note: 'int data [100005]' 15 | int data[maxn],n; | ^~~~ a.cc:25:78: error: reference to 'data' is ambiguous 25 | dp[t][0]=max({dp[t][0],dp[t-1][0]+data[t],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); | ^~~~ /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:15:5: note: 'int data [100005]' 15 | int data[maxn],n; | ^~~~ a.cc:25:97: error: reference to 'data' is ambiguous 25 | dp[t][0]=max({dp[t][0],dp[t-1][0]+data[t],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); | ^~~~ /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:15:5: note: 'int data [100005]' 15 | int data[maxn],n; | ^~~~ a.cc:25:37: error: no matching function for call to 'max(<brace-enclosed initializer list>)' 25 | dp[t][0]=max({dp[t][0],dp[t-1][0]+data[t],dp[t-1][1]+data[t],dp[t-1][2]+data[t]}); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:5: /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: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided a.cc:26:59: error: reference to 'data' is ambiguous 26 | dp[t][1]=max({dp[t][1],dp[t-1][1]-data[t],dp[t-1][2]-data[t]}); | ^~~~ /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:15:5: note: 'int data [100005]' 15 | int data[maxn],n; | ^~~~ a.cc:26:78: error: reference to 'data' is ambiguous 26 | dp[t][1]=max({dp[t][1],dp[t-1][1]-data[t],dp[t-1][2]-data[t]}); | ^~~~ /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
s831875061
p03850
C++
// Math = ♥️ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; /*-------------------------------------------------------------------------------------------------------------------------*/ #define ll long long // Short form for long long #define ld long double // Short form for long double typedef pair<ll, ll> ii; // Pair of long long typedef vector<ll> vi; // Vector of long long typedef vector<vi> vvi; // Vector of vector of long long typedef vector<ii> vii; // Vector of pairs typedef vector<vii> vvii; // Vector of vector of pairs #define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value) #define ff first // For pairs #define ss second // For pairs #define pb push_back // Pushback to vector #define mp make_pair // Makes pairs to be stored as pair #define all(c) (c).begin(), (c).end() // Mainly used by me in sorting // ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key() // order_of_key returns number of elements less that parameter. If element exists, that order is its index #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> /*-------------------------------------------------------------------------------------------------------------------------*/ #define MAXN (ll)(1e5 + 5) #define INF (ll)(1e18) ll dp[MAXN][3]; ll n; vi arr; ll solve(ll i, ll t) { if (i == n) return 0; if (dp[i][t] == INF) { if (t == 0) { if (arr[i] < 0) dp[i][t] = arr[i] + max(solve(i + 1, 0), solve(i + 1, 1)); else dp[i][t] = arr[i] + solve(i + 1, 0); } else if (t == 1) { ll maxi = max(solve(i + 1, 0) + arr[i], solve(i + 1, 1) - arr[i]); if (arr[i] < 0) maxi = max(maxi, solve(i + 1, 2) - arr[i]); dp[i][t] = maxi; } else dp[i][t] = max(arr[i] + solve(i + 1, 2), max(-arr[i] + solve(i + 1, 1), arr[i] + solve(i + 1, 0))); } return dp[i][t]; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); for (int i = 0; i < n; i++) dp[i] = INF; cin >> n; arr.resize(n); cin >> arr[0]; for (int i = 1; i < n; i++) { char c; cin >> c >> arr[i]; if (c == '-') arr[i] = -arr[i]; } cout << solve(0, 0) << "\n"; }
a.cc: In function 'int main()': a.cc:67:15: error: incompatible types in assignment of 'long long int' to 'long long int [3]' 67 | dp[i] = INF; | ^
s906485977
p03850
C++
// Math = ♥ // Sometimes it is people that no one imagines anything of who do things that no one can imagine // After all this time? Always #include <bits/stdc++.h> // uncomment before submission //#include <ext/pb_ds/assoc_container.hpp> // uncomment before submission //#include <ext/pb_ds/tree_policy.hpp> // uncomment before submission //using namespace __gnu_pbds; // uncomment before submission using namespace std; //<---------------------------------------------------Template-----------------------------------------------------------> #define int long long #define ll long long #define ld long double int INF = 1e9 + 7; typedef pair<ll, ll> ii; typedef vector<ll> vi; // Vector of long long typedef vector<vi> vvi; // Vector of vi typedef vector<ii> vii; // Vector of pairs typedef vector<vii> vvii; // Vector of Vector of pairs typedef vector<bool> vb; // Vector of bool #define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value) #define ff first // For pairs #define ss second // For pairs #define pb push_back // Pushback to vector #define mp make_pair // Makes pairs to be stored as pair #define all(c) (c).begin(), (c).end() // Mainly used by me in sorting // ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key() // order_of_key returns number of elements less that parameter. If element exists, that order is its index #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> //<-----------------------------------------------------------------------------------------------------------------------> signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<char> op; vi num; int x; cin >> x, num.pb(x); for (int i = 0; i < n - 1; i++) { char ch; cin >> ch >> x; op.pb(ch), num.pb(x); } vvi dp(n, vector<int>(3)); dp[0][0] = num[0]; dp[0][1] = -INF; dp[0][2] = -INF; for (int i = 1; i < n; i++) { if (op[i - 1] == '+') { dp[i][0] = dp[i - 1][0] + num[i]; dp[i][1] = dp[i - 1][1] - num[i]; dp[i][2] = dp[i - 1][2] + num[i]; dp[i][0] = max(dp[i][0], max(dp[i][1], dp[i][2]); dp[i][1] = max(dp[i][1], dp[i][2]); } else { dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - num[i]; dp[i][2] = max(dp[i - 1][1], dp[i - 1][2]) + num[i]; dp[i][0] = -INF; } } int a[] = {dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}; sort(a, a + 3); cout << a[2] << endl; return 0; }
a.cc: In function 'int main()': a.cc:63:61: error: expected ')' before ';' token 63 | dp[i][0] = max(dp[i][0], max(dp[i][1], dp[i][2]); | ~ ^ | )
s282066442
p03850
C++
// Math = ♥ // Sometimes it is people that no one imagines anything of who do things that no one can imagine // After all this time? Always #include <bits/stdc++.h> // uncomment before submission //#include <ext/pb_ds/assoc_container.hpp> // uncomment before submission //#include <ext/pb_ds/tree_policy.hpp> // uncomment before submission //using namespace __gnu_pbds; // uncomment before submission using namespace std; //<---------------------------------------------------Template-----------------------------------------------------------> #define int long long #define ll long long #define ld long double int INF = 1e9 + 7; typedef pair<ll, ll> ii; typedef vector<ll> vi; // Vector of long long typedef vector<vi> vvi; // Vector of vi typedef vector<ii> vii; // Vector of pairs typedef vector<vii> vvii; // Vector of Vector of pairs typedef vector<bool> vb; // Vector of bool #define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value) #define ff first // For pairs #define ss second // For pairs #define pb push_back // Pushback to vector #define mp make_pair // Makes pairs to be stored as pair #define all(c) (c).begin(), (c).end() // Mainly used by me in sorting // ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key() // order_of_key returns number of elements less that parameter. If element exists, that order is its index #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> //<-----------------------------------------------------------------------------------------------------------------------> signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<char> op; vi num; int x; cin >> x, num.pb(x); for (int i = 0; i < n - 1; i++) { char ch; cin >> ch >> x; op.pb(ch), num.pb(x); } vvi dp(n, vector<int>(3)); dp[0][0] = num[0]; dp[0][1] = -INF; dp[0][2] = -INF; for (int i = 1; i < n; i++) { if (op[i - 1] == '+') { dp[i][0] = dp[i - 1][0] + num[i]; dp[i][1] = dp[i - 1][1] - num[i]; dp[i][2] = dp[i - 1][2] + num[i]; dp[i][0] = max(dp[i][0], dp[i][2])); dp[i][1] = max(dp[i][1], dp[i][2]); } else { dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - num[i]; dp[i][2] = max(dp[i - 1][1], dp[i - 1][2]) + num[i]; dp[i][0] = -INF; } } int a[] = {dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}; sort(a, a + 3); cout << a[2] << endl; return 0; }
a.cc: In function 'int main()': a.cc:63:47: error: expected ';' before ')' token 63 | dp[i][0] = max(dp[i][0], dp[i][2])); | ^ | ;
s954982006
p03850
C++
#include <bits/stdc++.h> #define inf 100000000000000ll using namespace std; int read(); int n; long long f[100005][3]; void chmax(long long &x, long long y) { x = x > y ? x : y; } int main() { n = read(); f[0][0] = 0, f[0][1] = f[0][2] = -inf; for (int i = 1, x; i <= n; ++i) { x = read(); { f[i][0] = max(f[i - 1][0], f[i - 1][1]), f[i][1] = max(f[i - 1][1], f[i - 1][2]); f[i][2] = f[i - 1][2]; } f[i][0] += x, f[i][1] -= x, f[i][2] += x; if (x < 0) chmax(f[i][2], f[i][1]), chmax(f[i][1], f[i][0]); } printf("%lld\n", max(f[n][0], max(f[n][1], f[n][2]))); return 0; }
/usr/bin/ld: /tmp/ccsdsQBX.o: in function `main': a.cc:(.text+0x39): undefined reference to `read()' /usr/bin/ld: a.cc:(.text+0x7a): undefined reference to `read()' collect2: error: ld returned 1 exit status
s742737023
p03850
C++
#include<bits/stdc++.h> using namespace std; const int maxn=15; const int mod=1e9+7; const int S=(1<<4)+10; int n,k,top=0; int a[maxn],bel[maxn]; struct cat { int val,col; bool operator ==(const cat &b)const { return val==b.val&&col==b.col; } bool operator <(const cat &b)const { return val==b.val?col<b.col:val<b.val; } }s[S+maxn]; int L[maxn],R[maxn]; int pl[maxn],pr[maxn]; bool dfs2(int dep,int lim) { if(dep==k+1) { bool flag=1; for(int i=1;i<=lim;i++) if(L[i]<=pl[i]&&pr[i]<=R[i])flag=1; else return false; return true; } for(int i=1;i<=lim;i++) { int tmp=L[i],flag=0; L[i]=max(L[i],a[dep]),R[i]+=a[dep]; flag=dfs2(dep+1,lim); L[i]=tmp,R[i]-=a[dep]; if(flag)return true; } return false; } int l[maxn],r[maxn],inv[maxn]; int ans=0; int Pow(int a,long long k) { int ret=1; while(k) { if(k&1)ret=ret*1LL*a%mod; a=a*1LL*a%mod,k>>=1; } return ret; } int C(int n,int m) { int mul=1,c=1; for(int i=n-m+1;i<=n;i++)mul=mul*1LL*i%mod; for(int i=1;i<=m;i++)c=c*1LL*i%mod; return mul*1LL*Pow(c,mod-2)%mod; } void calc(int cnt) { for(int i=1;i<=cnt;i++) { if(s[bel[i]-1].col)pl[i]=s[bel[i]-1].val+1; else pl[i]=s[bel[i]-1].val; if(s[bel[i]].col)pr[i]=s[bel[i]].val; else pr[i]=s[bel[i]].val-1; } if(!dfs2(1,cnt))return; int now=0; l[++now]=0,r[now]=n; l[++now]=pl[1],r[now]=pr[1]; for(int i=2;i<=cnt;i++) { l[++now]=1,r[now]=n; l[++now]=pl[1],r[now]=pr[1]; } l[++now]=0,r[now]=n; int all=(1<<now)-1; for(int s=0;s<=all;s++) { long long sum=0; for(int i=1;i<=now;i++) if(s&(1<<i-1))sum+=r[i]+1; else sum+=l[i]; if(sum>n)continue; ans+=(count(s)&1?-1:1)*C(n-sum+now-1,now-1)%mod; ans=(ans%mod+mod)%mod; } } void dfs(int dep) { calc(dep-1); if(dep==k+1)return; for(int i=2;i<=top;i++)bel[dep]=i,dfs(dep+1); } int main() { scanf("%d%d",&n,&k); for(int i=1;i<=k;i++)scanf("%d",&a[i]); int all=(1<<k)-1; for(int i=1;i<=k;i++)s[++top].val=a[i],s[top].col=0; for(int s=1;s<=all;s++) { int sum=0; for(int i=1;i<=k;i++)if(s&(1<<i-1))sum+=a[i]; s[++top].val=sum; s[top].col=1; } sort(s+1,s+1+top); top=unique(s+1,s+1+top)-s-1; dfs(1); printf("%d\n",ans); }
a.cc: In function 'void calc(int)': a.cc:88:28: error: no matching function for call to 'count(int&)' 88 | ans+=(count(s)&1?-1:1)*C(n-sum+now-1,now-1)%mod; | ~~~~~^~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidate expects 4 arguments, 1 provided a.cc: In function 'int main()': a.cc:109:18: error: invalid types 'int[int]' for array subscript 109 | s[++top].val=sum; | ^ a.cc:110:18: error: invalid types 'int[int]' for array subscript 110 | s[top].col=1; | ^
s112759249
p03850
C++
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 2e5+5; int n; int arr[maxn]; ll sum[maxn]; ll qs[maxn]; int main() { scanf("%d", &n); int best = 0; for(int i = 1; i<= n; i++) { char tmp = '+'; if(i != 1) scanf(" %c", &tmp); int x; scanf("%d", &x); if(tmp == '-') x = -x; arr[i] = x; best += arr[i]; } sum[n] = abs(arr[n]); for(int i = n-1; i>= 1; i--) { sum[i] = sum[i+1]+abs(arr[i]); } for(int i = 1; i<= n; i++) { qs[i] = qs[i-1]+arr[i]; } vector<int> neg; for(int i = 1; i<= n; i++) if(arr[i]< 0) neg.pb(i); for(int i = 0; i+1< (int) neg.size(); i++) { int loc = 0; loc += arr[neg[i]]; for(int j = neg[i]+1; j< neg[i+1]; j++) { loc -= arr[j]; } // printf("[%d, %d) loc = %d\n", neg[i], neg[i+1], loc); best = max(best, qs[neg[i]-1]+loc+sum[neg[i+1]]); } printf("%d\n", best); }
a.cc: In function 'int main()': a.cc:51:27: error: no matching function for call to 'max(int&, ll)' 51 | best = max(best, qs[neg[i]-1]+loc+sum[neg[i+1]]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:51:27: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 51 | best = max(best, qs[neg[i]-1]+loc+sum[neg[i+1]]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:51:27: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 51 | best = max(best, qs[neg[i]-1]+loc+sum[neg[i+1]]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s222002961
p03850
C++
long a,b,c;o; main(A){ b=c=-1e9; for(scanf("%*d%ld",&a);~scanf(" %c%d",&o,&A);) b=o%3?a+=A,fmax(b-A,c+=A):(a=fmax(a-A,c=b+A)); printf("%ld",a); }
a.cc:1:12: error: 'o' does not name a type 1 | long a,b,c;o; | ^ a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token 2 | main(A){ | ^
s833320658
p03850
C++
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> pint; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N; int A[110000]; char op[110000]; signed main() { cin >> N; cin >> A[0]; for (int i = 1; i < N; i++)cin >> op[i] >> A[i]; op[N] = '-'; A[N] = 0; int sum = A[0], total_minus = 0, cur_minus = 0, min_minus = LLONG_MAX; for (int i = 1; i <= N; i++) { if (op[i] == '+') { if (total_minus > 0)cur_minus += A[i]; } else { if (total_minus > 0)min_minus = min(min_dec, total_minus + cur_minus); total_minus += A[i]; cur_minus = 0; } sum += A[i]; } if (min_minus == LLONG_MAX)min_minus = 0; cout << sum - 2 * min_minus; }
a.cc: In function 'int main()': a.cc:26:49: error: 'min_dec' was not declared in this scope 26 | if (total_minus > 0)min_minus = min(min_dec, total_minus + cur_minus); | ^~~~~~~
s156885641
p03850
C++
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<iostream> #include<algorithm> #include<queue> #include<time.h> #include<stack> #include<map> #include<set> #include<string> using namespace std; int main() { int n,i,t,j=0,x=0; cin>>n; int s[100008]={0}; bool k[100008]={0}; char r[500008]={0}; long long int a[100008]={0}; int b=0; getchar(); gets(r); for(i=0;r[i]!=0;i++) { if(isdigit(r[i]))s[j++]=r[i]-'0'; else if(r[i]==' ')continue; else if(r[i]=='+')k[x++]=1; else if(r[i]=='-')k[x++]=0; } a[b++]=s[0]; bool ka[100008]={0}; int bka=0; for(i=0;i<x;i++) { if(k[i]==1) { a[b++]=s[i+1]; ka[bka++]=1; } if(k[i]==0&&k[i+1]==0) { int y; ka[bka++]=0; long long int yy=s[i+1]; for(y=i+1;y<=x;y++) { if(k[y]==0)yy-=s[y+1]; } a[b++]=yy; i--; i=y; } if(k[i]==0) { a[b++]=s[i+1]; ka[bka++]=0; } } if(k[x-2]!=0) { if(k[x-1]==0) { a[b++]=s[i+1]; ka[bka++]=0; } if(k[x-1]==1) { a[b++]=s[i+1]; ka[bka++]=1; } } long long int m=a[0]; long long int q=m; for(i=0;i<bka;i++) { if(ka[i]==0)q-=a[i+1]; if(ka[i]==1)q+=a[i+1]; m=max(q,m); } cout<<m<<endl; return 0; }
a.cc: In function 'int main()': a.cc:24:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 24 | gets(r); | ^~~~ | getw
s139457716
p03850
Java
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; public class mm_martian_n2 { static final long INF = Long.MAX_VALUE / 10; void submit() { int n = nextInt(); long[] a = new long[n]; boolean[] plus = new boolean[n - 1]; for (int i = 0; i < n; i++) { a[i] = nextInt(); if (i != n - 1) { plus[i] = nextToken().equals("+"); } } long[] dp = new long[n]; Arrays.fill(dp, -INF); dp[0] = a[0]; for (int i = 1; i < n; i++) { long[] nxt = new long[n]; Arrays.fill(nxt, -INF); boolean sgn = plus[i - 1]; long x = a[i]; for (int was = 0; was < C; was++) { int nowMax = Math.min(was + (sgn ? 0 : 1), n - 1); long delta = (nowMax % 2 == 0) ? x : -x; for (int j = 0; j <= nowMax; j++) { nxt[j] = Math.max(nxt[j], dp[was] + delta); } } dp = nxt; } out.println(Arrays.stream(dp).max().getAsLong()); } void test() { } void stress() { for (int tst = 0;; tst++) { if (false) { throw new AssertionError(); } System.err.println(tst); } } mm_martian_n2() throws IOException { is = System.in; out = new PrintWriter(System.out); submit(); // stress(); // test(); out.close(); } static final Random rng = new Random(); static final int C = 5; static int rand(int l, int r) { return l + rng.nextInt(r - l + 1); } public static void main(String[] args) throws IOException { new mm_martian_n2(); } private InputStream is; PrintWriter out; private byte[] buf = new byte[1 << 14]; private int bufSz = 0, bufPtr = 0; private int readByte() { if (bufSz == -1) throw new RuntimeException("Reading past EOF"); if (bufPtr >= bufSz) { bufPtr = 0; try { bufSz = is.read(buf); } catch (IOException e) { throw new RuntimeException(e); } if (bufSz <= 0) return -1; } return buf[bufPtr++]; } private boolean isTrash(int c) { return c < 33 || c > 126; } private int skip() { int b; while ((b = readByte()) != -1 && isTrash(b)) ; return b; } String nextToken() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!isTrash(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } String nextString() { int b = readByte(); StringBuilder sb = new StringBuilder(); while (!isTrash(b) || b == ' ') { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } double nextDouble() { return Double.parseDouble(nextToken()); } char nextChar() { return (char) skip(); } int nextInt() { int ret = 0; int b = skip(); if (b != '-' && (b < '0' || b > '9')) { throw new InputMismatchException(); } boolean neg = false; if (b == '-') { neg = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { ret = ret * 10 + (b - '0'); } else { if (b != -1 && !isTrash(b)) { throw new InputMismatchException(); } return neg ? -ret : ret; } b = readByte(); } } long nextLong() { long ret = 0; int b = skip(); if (b != '-' && (b < '0' || b > '9')) { throw new InputMismatchException(); } boolean neg = false; if (b == '-') { neg = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { ret = ret * 10 + (b - '0'); } else { if (b != -1 && !isTrash(b)) { throw new InputMismatchException(); } return neg ? -ret : ret; } b = readByte(); } } }
Main.java:6: error: class mm_martian_n2 is public, should be declared in a file named mm_martian_n2.java public class mm_martian_n2 { ^ 1 error
s667884088
p03850
Java
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; public class mm_martian_ac { static final long INF = Long.MAX_VALUE / 10; void submit() { int n = nextInt(); long[] a = new long[n]; boolean[] plus = new boolean[n - 1]; for (int i = 0; i < n; i++) { a[i] = nextInt(); if (i != n - 1) { plus[i] = nextToken().equals("+"); } } long[] dp = new long[C]; Arrays.fill(dp, -INF); dp[0] = a[0]; for (int i = 1; i < n; i++) { long[] nxt = new long[C]; Arrays.fill(nxt, -INF); boolean sgn = plus[i - 1]; long x = a[i]; for (int was = 0; was < C; was++) { int nowMax = Math.min(was + (sgn ? 0 : 1), C - 1); long delta = (nowMax % 2 == 0) ? x : -x; for (int j = 0; j <= nowMax; j++) { nxt[j] = Math.max(nxt[j], dp[was] + delta); } } dp = nxt; } out.println(Arrays.stream(dp).max().getAsLong()); } void test() { } void stress() { for (int tst = 0;; tst++) { if (false) { throw new AssertionError(); } System.err.println(tst); } } mm_martian_ac() throws IOException { is = System.in; out = new PrintWriter(System.out); submit(); // stress(); // test(); out.close(); } static final Random rng = new Random(); static final int C = 5; static int rand(int l, int r) { return l + rng.nextInt(r - l + 1); } public static void main(String[] args) throws IOException { new mm_martian_ac(); } private InputStream is; PrintWriter out; private byte[] buf = new byte[1 << 14]; private int bufSz = 0, bufPtr = 0; private int readByte() { if (bufSz == -1) throw new RuntimeException("Reading past EOF"); if (bufPtr >= bufSz) { bufPtr = 0; try { bufSz = is.read(buf); } catch (IOException e) { throw new RuntimeException(e); } if (bufSz <= 0) return -1; } return buf[bufPtr++]; } private boolean isTrash(int c) { return c < 33 || c > 126; } private int skip() { int b; while ((b = readByte()) != -1 && isTrash(b)) ; return b; } String nextToken() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!isTrash(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } String nextString() { int b = readByte(); StringBuilder sb = new StringBuilder(); while (!isTrash(b) || b == ' ') { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } double nextDouble() { return Double.parseDouble(nextToken()); } char nextChar() { return (char) skip(); } int nextInt() { int ret = 0; int b = skip(); if (b != '-' && (b < '0' || b > '9')) { throw new InputMismatchException(); } boolean neg = false; if (b == '-') { neg = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { ret = ret * 10 + (b - '0'); } else { if (b != -1 && !isTrash(b)) { throw new InputMismatchException(); } return neg ? -ret : ret; } b = readByte(); } } long nextLong() { long ret = 0; int b = skip(); if (b != '-' && (b < '0' || b > '9')) { throw new InputMismatchException(); } boolean neg = false; if (b == '-') { neg = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { ret = ret * 10 + (b - '0'); } else { if (b != -1 && !isTrash(b)) { throw new InputMismatchException(); } return neg ? -ret : ret; } b = readByte(); } } }
Main.java:6: error: class mm_martian_ac is public, should be declared in a file named mm_martian_ac.java public class mm_martian_ac { ^ 1 error
s150048171
p03850
C++
//ΔARC066E #include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<cmath> #include<cstring> #include<cstdlib> using namespace std; typedef long long LL; typedef double DB; const int N = 111111; const LL INF = 1e18; int n,a[N],op[N]; LL dp[N][3]; int main() { int i,x; char ch[5]; scanf("%d",&n); for(i=1;i<n;i=i+1){ scanf("%d%s",a+i,ch); op[i+1]=(ch[0]=='-'); } scanf("%d",a+n); dp[1][0]=a[1]; dp[1][1]=-INF; dp[1][2]=-INF; for(i=2;i<=n;i=i+1){ if(op[i]){ dp[i][0]=max(max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]),dp[i-1][2]-a[i]); dp[i][1]=max(max([i-1][0]-a[i],dp[i-1][1]+a[i]),dp[i-1][2]+a[i]); dp[i][2]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]); } else{ dp[i][0]=max(max(dp[i-1][0]+a[i],dp[i-1][1]+a[i]),dp[i-1][2]+a[i]); dp[i][1]=dp[i-1][1]-a[i]; dp[i][2]=dp[i-1][2]+a[i]; } } cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]); return 0; }
a.cc: In function 'int main()': a.cc:36:44: error: expected ',' before '-' token 36 | dp[i][1]=max(max([i-1][0]-a[i],dp[i-1][1]+a[i]),dp[i-1][2]+a[i]); | ^ | , a.cc:36:44: error: expected identifier before '-' token a.cc: In lambda function: a.cc:36:47: error: expected '{' before '[' token 36 | dp[i][1]=max(max([i-1][0]-a[i],dp[i-1][1]+a[i]),dp[i-1][2]+a[i]); | ^ a.cc: In function 'int main()': a.cc:36:47: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
s706327119
p03850
C++
#include<bits/stdc++.h> using namespace std; typedef long long LL; int n,a[100008],t,next,pos[100008]; char op[100008]; LL ans,tmp,suf[100008]; int main() { ios::sync_with_stdio(false); cin>>n>>t; for(int i=1;i<n;++i){ cin>>op[i]>>a[i]; } next=n; for(int i=n-1;i;--i){ suf[i]=suf[i+1]+a[i]; if(op[i]=='-'){ pos[i]=next; next=i; } } for(int i=1;i<n;++i){ if(op[i]=='-'){ ans=max(ans,tmp-(suf[i]-suf[pos[i]])+suf[pos[i]]); tmp-=a[i]; } else{ tmp+=a[i]; if(i==n-1) ans=max(ans,tmp); } } cout<<ans+t; return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: reference to 'next' is ambiguous 14 | next=n; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:4:19: note: 'int next' 4 | int n,a[100008],t,next,pos[100008]; | ^~~~ a.cc:18:32: error: reference to 'next' is ambiguous 18 | pos[i]=next; | ^~~~ /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:4:19: note: 'int next' 4 | int n,a[100008],t,next,pos[100008]; | ^~~~ a.cc:19:25: error: reference to 'next' is ambiguous 19 | next=i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:4:19: note: 'int next' 4 | int n,a[100008],t,next,pos[100008]; | ^~~~
s389546521
p03850
C++
#include<cstdio> #include<cstring> #include<algorithm> #define N 100010 #define ll long long #define inf 1000000000000000000LL using namespace std; int n, flag[N], w[N], next[N]; ll ans, now, s[N]; char S[10]; int main(){ scanf("%d", &n); memset(flag, 0, sizeof(flag)); for(int i=1; i<=n; i++){ scanf("%d", &w[i]); if(i<=n-1){scanf("%s", S+1); if(S[1]=='-')flag[i+1]=1;} } s[0]=0; for(int i=1; i<=n; i++)s[i]=s[i-1]+w[i]; now=n+1; for(int i=n; i; i--){next[i]=now; if(flag[i])now=i;} ans=inf; now=0; for(int i=1; i<=n; i++)if(flag[i]){ ans=min(ans, now+s[next[i]-1]-s[i-1]); now+=w[i]; } printf("%lld", s[n]-ans*2); return 0; }
a.cc: In function 'int main()': a.cc:19:30: error: reference to 'next' is ambiguous 19 | for(int i=n; i; i--){next[i]=now; if(flag[i])now=i;} | ^~~~ 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:8:23: note: 'int next [100010]' 8 | int n, flag[N], w[N], next[N]; | ^~~~ a.cc:22:36: error: reference to 'next' is ambiguous 22 | ans=min(ans, now+s[next[i]-1]-s[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:8:23: note: 'int next [100010]' 8 | int n, flag[N], w[N], next[N]; | ^~~~
s959892047
p03850
C++
Status Accepted Time 14ms Memory 2424kB Length 859 Lang C++14 (GCC 5.3.0) Submitted 2017-03-11 14:37:44 Shared RemoteRunId 1154502 Select Code #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define LL long long #define ULL unsigned long long #define PB push_back #define MP make_pair #define VI vector<int> #define PII pair<int,int> #define IOS ios::sync_with_stdio(0);cin.tie(0); #define IN freopen("in", "r", stdin); #define OUT freopen("out", "w", stdout); const int maxn=100010; LL a[maxn],per[maxn]; char c[maxn]; int main() { IOS; int n; cin>>n>>a[0]; per[0]=a[0]; LL abssum=a[0]; LL ans=a[0]; VI sub; for (int j=1;j<n;++j) { cin>>c[j]>>a[j]; per[j]=per[j-1]+a[j]; abssum+=a[j]; if (c[j]=='+') ans+=a[j]; else { ans-=a[j]; sub.PB(j); } } for (int j=0;j<(int)sub.size()-1;++j) { int p1=sub[j]; int p2=sub[j+1]; LL tis=abssum-(per[p2-1]-per[p1-1])*2; ans=max(ans,tis); abssum-=a[p1]*2; } cout<<ans<<endl; return 0; }
a.cc:11:12: error: too many decimal points in number 11 | C++14 (GCC 5.3.0) | ^~~~~ a.cc:2:1: error: 'Status' does not name a type 2 | Status | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:19: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /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) | ^~~~~~ /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]
s901747865
p03850
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #include <string> #include <cstring> #include <bitset> #define ll long long #define rep(x,n) for(ll (x)=0;(x)<n;(x)++) #define rep1(x,n) for(ll (x)=1;(x)<=n;(x)++) #define ios::sync_with_stdio(0); #define lson(x) ((x)<<1) #define rson(x) ((x)<<1|1) using namespace std; const ll N=100010; ll a[N],per[N]; vector<ll> sub; int main() { #ifdef LOCAL //freopen("C_data.txt","r",stdin); #endif // LOCAL ll n; ll cin>>n>>a[0]; per[0]=a[0]; ll abssum=a[0],ans=a[0]; char op; for(ll j=1;j<n;j++) { cin>>op>>a[j]; per[j]=per[j-1]+a[j]; abssum+=a[j]; if(op=='+') ans+=a[j]; else { ans-=a[j]; sub.push_back(j); } } for(ll j=0;j<sub.size()-1;j++) { ll p1=sub[j],p2=sub[j+1]; ll t=abssum-=(per[p2-1]-per[p1-1])*2; ans=max(ans,t); abssum-=a[p1]*2; } cout<<ans<<endl; }
a.cc:15:9: warning: ISO C++11 requires whitespace after the macro name 15 | #define ios::sync_with_stdio(0); | ^~~ a.cc: In function 'int main()': a.cc:31:8: error: expected initializer before '>>' token 31 | cin>>n>>a[0]; | ^~
s450330824
p03850
C++
#include <iostream> #include <algorithm> #include <string.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define ull unsigned ll #define db double #define INF 0x3f3f3f3f #define MOD 1000000007 #define PII pair<int, int> int n; ll a[100010]; char op[100010]; char buf[8]; ll left=0,right=0,ans=-2e11; int main() { scanf("%d",&n); scanf("%lld",&a[0]); left=a[0]; for (int i=1;i<n;i++) { scanf("%s",buf); scanf("%lld",a+i); op[i]=buf[0]; right+=a[i]; } int idx=1; while (idx<n&&op[idx]=='+') { left+=a[idx]; right-=a[idx]; idx++; } ll tmp=0; while (idx<n) { left+=2*tmp; left-=a[idx]; right-=a[idx]; idx++; tmp=0; while (idx<n&&op[idx]=='+') { tmp+=a[idx]; left-=a[idx]; right-=a[idx]; idx++; } ans=max(ans,left+right); } ans=max(ans,left+right); printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:26:5: error: reference to 'left' is ambiguous 26 | left=a[0]; | ^~~~ In file included from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:31:9: error: reference to 'right' is ambiguous 31 | right+=a[i]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:21:11: note: 'long long int right' 21 | ll left=0,right=0,ans=-2e11; | ^~~~~ a.cc:35:9: error: reference to 'left' is ambiguous 35 | left+=a[idx]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:36:9: error: reference to 'right' is ambiguous 36 | right-=a[idx]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:21:11: note: 'long long int right' 21 | ll left=0,right=0,ans=-2e11; | ^~~~~ a.cc:41:9: error: reference to 'left' is ambiguous 41 | left+=2*tmp; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:42:9: error: reference to 'left' is ambiguous 42 | left-=a[idx]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:43:9: error: reference to 'right' is ambiguous 43 | right-=a[idx]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:21:11: note: 'long long int right' 21 | ll left=0,right=0,ans=-2e11; | ^~~~~ a.cc:48:13: error: reference to 'left' is ambiguous 48 | left-=a[idx]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:49:13: error: reference to 'right' is ambiguous 49 | right-=a[idx]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:21:11: note: 'long long int right' 21 | ll left=0,right=0,ans=-2e11; | ^~~~~ a.cc:52:21: error: reference to 'left' is ambiguous 52 | ans=max(ans,left+right); | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:52:26: error: reference to 'right' is ambiguous 52 | ans=max(ans,left+right); | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:21:11: note: 'long long int right' 21 | ll left=0,right=0,ans=-2e11; | ^~~~~ a.cc:54:17: error: reference to 'left' is ambiguous 54 | ans=max(ans,left+right); | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:21:4: note: 'long long int left' 21 | ll left=0,right=0,ans=-2e11; | ^~~~ a.cc:54:22: error: reference to 'right' is ambiguous 54 | ans=max(ans,left+right); | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:21:11: note: 'long long int right' 21 | ll left=0,right=0,ans=-2e11; | ^~~~~
s974228559
p03850
C++
#include <bits/stdc++.h> #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++) #define REP(i,b) FOR(i,0,b) using namespace std; typedef long long LL; const int SIZE=5+1e5; const LL INF=1<<30; const LL p=7+(1e9); LL A[SIZE]; char B[SIZE]; bool isMinus[SIZE]; int main(){ int N; cin >> N; LL ans=0; cin >> ans; REP(i,N-1){ cin >> B[i]; cin >> A[i]; isMinus[i]=B[i]=='-'; } LL freedom=0,needm=0,cost=0; REP(j,N-1){ int i=N-1-j-1; cost+=A[i]; needm+=A[i]; if(isMinus[i]){ freedom=max(freedom-A[i],needm-cost*2); cost=0; } else freedom+=A[i]; } cout << freedom+ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:2:24: error: 'ut' was not declared in this scope 2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++) | ^~ a.cc:3:18: note: in expansion of macro 'FOR' 3 | #define REP(i,b) FOR(i,0,b) | ^~~ a.cc:17:9: note: in expansion of macro 'REP' 17 | REP(i,N-1){ | ^~~ a.cc:17:13: error: 'i' was not declared in this scope 17 | REP(i,N-1){ | ^ a.cc:2:33: note: in definition of macro 'FOR' 2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++) | ^ a.cc:17:9: note: in expansion of macro 'REP' 17 | REP(i,N-1){ | ^~~ a.cc:2:24: error: 'ut' was not declared in this scope 2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++) | ^~ a.cc:3:18: note: in expansion of macro 'FOR' 3 | #define REP(i,b) FOR(i,0,b) | ^~~ a.cc:23:9: note: in expansion of macro 'REP' 23 | REP(j,N-1){ | ^~~ a.cc:23:13: error: 'j' was not declared in this scope 23 | REP(j,N-1){ | ^ a.cc:2:33: note: in definition of macro 'FOR' 2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++) | ^ a.cc:23:9: note: in expansion of macro 'REP' 23 | REP(j,N-1){ | ^~~
s841076390
p03850
C
#include <stdio.h> #define MAX(a, b) ((a)>(b))?(a):(b) #define MIN(a, b) ((a)<(b))?(a):(b) const long long int z = 1000000000000000ULL; int a[200000]; char b[200000]; long long int dpmax[100000][100000]; long long int dpmin[100000][100000]; void solve(int i, int j){ long long int x, y; if(dpmax[i][j] != z) return; solve(i+1, j); solve(i, j-1); if(b[i]) x = a[i] - dpmin[i+1][j]; else x = a[i] + dpmax[i+1][j]; if(b[j-1]) y = dpmax[i][j-1] - a[j]; else y = dpmax[i][j-1] + a[j]; dpmax[i][j] = MAX(x, y); if(b[i]) x = a[i] - dpmax[i+1][j]; else x = a[i] + dpmin[i+1][j]; if(b[j-1]) y = dpmin[i][j-1] - a[j]; else y = dpmin[i][j-1] + a[j]; dpmin[i][j] = MIN(x, y); // if(b[i] && b[j-1]) dp[i][j] = MAX(dp[i][j], a[i] - solve(i+1,j-1) - a[j]); printf("dpmax %d, %d = %lld\n", i, j, dpmax[i][j]); printf("dpmin %d, %d = %lld\n", i, j, dpmin[i][j]); // return dp[i][j]; } int main(){ int i, j; int n; scanf("%d", &n); for(i=0;i<n-1;i++){ scanf("%d ", a+i); scanf("%c", b+i); b[i] &= 0x4; } scanf("%d", a+n-1); for(i=0;i<n;i++){ printf("a[%d] = %d\n", i, a[i]); } for(i=0;i<n-1;i++){ printf("b[%d] = %d\n", i, b[i]); } for(i=0;i<n;i++){ dpmax[i][i] = dpmin[i][i] = a[i]; if(b[i]) dpmax[i][i+1] = dpmin[i][i+1] = a[i] - a[i+1]; else dpmax[i][i+1] = dpmin[i][i+1] = a[i] + a[i+1]; for(j=i+2;j<n;j++){ dpmax[i][j] = dpmin[i][j] = z; } } solve(0, n-1); printf("%lld", dpmax[0][n-1]); }
/tmp/ccQAOVjG.o: in function `solve': main.c:(.text+0xbe): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x2a1): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x2ea): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x337): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x38f): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x3fb): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o /tmp/ccQAOVjG.o: in function `main': main.c:(.text+0x5c7): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x5de): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x66f): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x69a): relocation truncated to fit: R_X86_64_PC32 against symbol `dpmin' defined in .bss section in /tmp/ccQAOVjG.o main.c:(.text+0x727): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s336481046
p03851
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, pii> pipii; typedef pair<pii, int> piipi; typedef pair<pii, pii> piipii; #define mp make_pair #define fi first #define se second #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() #define eb emplace_back int t[300005]; int p[300005], x[300005]; bool Q; struct Line { mutable ll k, m, p; bool operator<(const Line& o) const { return Q ? p < o.p : k < o.k; } }; struct LineContainer : multiset<Line> { const ll inf = LLONG_MAX; void init(){ clear(); } ll div(ll a, ll b){ return a / b - ((a ^ b) < 0 && a % b); } bool isect(iterator x, iterator y) { if (y == end()) { x->p = inf; return false; } if (x->k == y->k) x->p = x->m > y->m ? inf : -inf; else x->p = div(y->m - x->m, x->k - y->k); return x->p >= y->p; } void add(ll k, ll m) { auto z = insert({k, m, 0}), y = z++, x = y; while (isect(y, z)) z = erase(z); if (x != begin() && isect(--x, y)) isect(x, y = erase(y)); while ((y = x) != begin() && (--x)->p >= y->p) isect(x, erase(y)); } ll query(ll x) { assert(!empty()); Q = 1; auto l = *lower_bound({0,0,x}); Q = 0; return l.k * x + l.m; } }C; ll pref[300005], suff[300005]; ll sum[300005]; ll dp[300005]; void dfs(int s, int e){ if(s == e){ dp[s] = max(dp[s], 1-t[s]); return; } int mid = (s+e)/2; dfs(s, mid); dfs(mid+1, e); ll mx = -1e18; C.init(); for(int i=mid+1;i<=e;i++){ int r = i; ll k = -r; ll m = (r*1ll*r + r)/2 + suff[i+1] - sum[i]; C.add(k, m); } for(int i=s;i<=mid;i++){ int l = i-1; mx = max(mx, C.query(l) + (l*1ll*l - l)/2 + sum[i-1]); dp[i] = max(dp[i], mx); } mx = -1e18; C.init(); for(int i=s;i<=mid;i++){ int l = i-1; ll k = -l; ll m = (l*1ll*l - l)/2 + pref[i-1] + sum[i-1]; C.add(k, m); } for(int i=e;i>=mid+1;i--){ int r = i; mx = max(mx, C.query(r) + (r*1ll*r + r)/2 - sum[i]); dp[i] = max(dp[i], mx); } } int main(){ int n; scanf("%d", &n); for(int i=1;i<=n;i++) scanf("%d", &t[i]), sum[i] = sum[i-1] + t[i]; for(int i=1;i<=n;i++) dp[i] = -1e18; int m; scanf("%d", &m); for(int i=1;i<=m;i++) scanf("%d%d", &p[i], &x[i]); C.init(); for(int i=1;i<=n;i++){ int l = i-1, r = i; ll k = -l; ll m = (l*1ll*l - l)/2 + pref[i-1] + sum[i-1]; C.add(k, m); pref[i] = C.query(r) + (r*1ll*r + r)/2 - sum[i]; pref[i] = max(pref[i], pref[i-1]); } C.init(); for(int i=n;i>=1;i--){ int l = i-1, r = i; ll k = -r; ll m = (r*1ll*r + r)/2 + suff[i+1] - sum[i]; C.add(k, m); suff[i] = C.query(l) + (l*1ll*l - l)/2 + sum[i-1]; suff[i] = max(suff[i], suff[i+1]); } dfs(1, n); for(int i=1;i<=m;i++) printf("%lld\n", max(pref[p[i]-1] + suff[p[i]+1], dp[p[i]] + t[p[i]] - x[i])); }
a.cc: In function 'void dfs(int, int)': a.cc:60:20: error: no matching function for call to 'max(ll&, int)' 60 | dp[s] = max(dp[s], 1-t[s]); | ~~~^~~~~~~~~~~~~~~ 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:60:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 60 | dp[s] = max(dp[s], 1-t[s]); | ~~~^~~~~~~~~~~~~~~ /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:60:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 60 | dp[s] = max(dp[s], 1-t[s]); | ~~~^~~~~~~~~~~~~~~
s790400062
p03851
C++
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define all(x) (x).begin() , (x).end() #define rall(x) (x).rbegin() , (x).rend() #define len(x) (int)(x).size() using namespace std; //#define int long long typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int N = (int)3e5 + 100; ll inf = 1e18; int t[N]; ll pref[N] , ansPref[N] , ansSuf[N] , answer[N]; vector<pii>que[N]; struct line{ ll k , b , x; ll get(ll _x){return k * _x + b;} }; ll cross(line a , line b){ return ceil((a.b - b.b) / ld(b.k - a.k)); } vector<line>cht; void add(line nw){ while(!cht.empty() && cht.back().k == nw.k && cht.back().b < nw.b) cht.pop_back(); if(!cht.empty() && cht.back().k == nw.k) return; while(!cht.empty() && cross(nw, cht.back()) <= cht.back().x) cht.pop_back(); if(cht.empty()) nw.x = -inf; else nw.x = cross(nw , cht.back()); cht.pb(nw); } ll get(ll x){ int l = 0 , r = len(cht) - 1; while(l != r){ int mid = (l + r) >> 1; if(x >= cht[mid].x){ if(l + 1 == r) l = r; else l = mid; }else r = mid; } if(x >= cht[r].x) ++r; --r; assert(x >= cht[r].x); if(r + 1 < len(cht)) assert(x < cht[r + 1].x); return cht[r].get(x); } void clr(){ cht.clear(); } void solve(int l , int r){ if(l == r){ for(auto u : que[l]){ answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0ll , 1 - u.fi)); } return; } int mid = (l + r) >> 1; solve(l , mid); solve(mid + 1 , r); clr(); /// we wonder to update for [l , mid] for(int i = r + 1; i >= mid + 1; --i){ add({-i , 1ll*i*(i+1)/2+ansSuf[i]-pref[i-1]}); } ll curbest = -inf; for(int i = l; i <= mid; ++i){ curbest = max(curbest , get(i) + 1ll*i*(i-1)/2 + pref[i-1] + ansPref[i-1]); for(auto u : que[i]){ answer[u.se] = max(answer[u.se] , curbest + t[i] - u.fi); } } clr(); for(int i = l - 1; i <= mid; ++i){ add({i , 1ll*i*(i-1)/2+ansPref[i]+pref[i]}); } curbest = -inf; for(int i = r; i >= mid + 1; --i){ curbest = max(curbest , get(-i)+1ll*i*(i+1)/2-pref[i] + ansSuf[i+1]); for(auto u : que[i]){ answer[u.se] = max(answer[u.se] , curbest + t[i] - u.fi); } } /// omamamamagat } signed main(){ ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); int n;cin >> n; for(int i = 1 ; i <= n; ++i){ cin >> t[i] , pref[i] = pref[i - 1] + t[i]; } int m;cin >> m; for(int i = 0 ; i < m; ++i){ int p , x;cin >> p >> x; que[p].pb({x , i}); } add({0 , 0}); for(int i = 1; i <= n; ++i){ /// firstly if we have ll cur = get(-i)+1ll*i*(i+1)/2-pref[i]; if(i) ansPref[i] = max(ansPref[i-1],cur); /// update cht add({i , 1ll*i*(i-1)/2+ansPref[i]+pref[i]}); } /// next is mem clr(); /// calculate for suf pref[n + 1] = pref[n]; add({-(n+1),1ll*(n+1)*(n+2)/2+ansSuf[n+1]-pref[n]}); for(int i = n; i >= 1; --i){ ll cur = get(i) + 1ll*i*(i-1)/2 + pref[i-1]; ansSuf[i] = max(ansSuf[i + 1] , cur); add({-i , 1ll*i*(i+1)/2+ansSuf[i]-pref[i-1]}); } clr(); solve(1 , n); for(int i = 0 ; i < m; ++i) cout << answer[i] << '\n'; return 0; }
a.cc: In function 'void solve(int, int)': a.cc:66:83: error: no matching function for call to 'max(long long int, int)' 66 | answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0ll , 1 - u.fi)); | ~~~^~~~~~~~~~~~~~~~ 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:66:83: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 66 | answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0ll , 1 - u.fi)); | ~~~^~~~~~~~~~~~~~~~ /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:66:83: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 66 | answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0ll , 1 - u.fi)); | ~~~^~~~~~~~~~~~~~~~
s466313341
p03851
C++
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define all(x) (x).begin() , (x).end() #define rall(x) (x).rbegin() , (x).rend() #define len(x) (int)(x).size() using namespace std; #define int long long typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int N = (int)3e5 + 100 , inf = 1e9; int t[N]; ll pref[N] , ansPref[N] , ansSuf[N] , answer[N]; vector<pii>que[N]; struct line{ ll k , b , x; ll get(ll _x){return k * _x + b;} }; ll cross(line a , line b){ return ceil((a.b - b.b) / ld(b.k - a.k)); } vector<line>cht; void add(line nw){ while(!cht.empty() && cht.back().k == nw.k && cht.back().b < nw.b) cht.pop_back(); if(!cht.empty() && cht.back().k == nw.k) return; while(!cht.empty() && cross(nw, cht.back()) <= cht.back().x) cht.pop_back(); if(cht.empty()) nw.x = -inf; else nw.x = cross(nw , cht.back()); cht.pb(nw); } ll get(ll x){ int l = 0 , r = len(cht) - 1; while(l != r){ int mid = (l + r) >> 1; if(x >= cht[mid].x){ if(l + 1 == r) l = r; else l = mid; }else r = mid; } if(x >= cht[r].x) ++r; --r; return cht[r].get(x); } void clr(){ cht.clear(); } void solve(int l , int r){ if(l == r){ for(auto u : que[l]){ answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0 , 1 - u.fi)); } return; } int mid = (l + r) >> 1; solve(l , mid); solve(mid + 1 , r); clr(); /// we wonder to update for [l , mid] for(int i = r + 1; i >= mid + 1; --i){ add({-i , 1ll*i*(i+1)/2+ansSuf[i]-pref[i-1]}); } ll curbest = 0; for(int i = l; i <= mid; ++i){ curbest = max(curbest , get(i) + 1ll*i*(i-1)/2 + pref[i-1]); for(auto u : que[i]){ answer[u.se] = max(answer[u.se] , curbest + t[i] - u.fi); } } clr(); for(int i = l - 1; i <= mid; ++i){ add({i , 1ll*i*(i-1)/2+ansPref[i]+pref[i]}); } curbest = 0; for(int i = r; i >= mid + 1; --i){ curbest = max(curbest , get(-i)+1ll*i*(i+1)/2-pref[i]); for(auto u : que[i]){ answer[u.se] = max(answer[u.se] , curbest + t[i] - u.fi); } } /// omamamamagat } signed main(){ ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); int n;cin >> n; for(int i = 1 ; i <= n; ++i){ cin >> t[i] , pref[i] = pref[i - 1] + t[i]; } int m;cin >> m; for(int i = 0 ; i < m; ++i){ int p , x;cin >> p >> x, p; que[p].pb({x , i}); } /// calculating ansPref add({0 , 0}); for(int i = 1; i <= n; ++i){ /// firstly if we have ll cur = get(-i)+1ll*i*(i+1)/2-pref[i]; if(i) ansPref[i] = max(ansPref[i-1],cur); /// update cht add({i , 1ll*i*(i-1)/2+ansPref[i]+pref[i]}); } /// next is mem clr(); /// calculate for suf pref[n + 1] = pref[n]; add({-(n+1),1ll*(n+1)*(n+2)/2+ansSuf[n+1]-pref[n]}); for(int i = n; i >= 0; --i){ ll cur = get(i) + 1ll*i*(i-1)/2 + pref[i-1]; ansSuf[i] = max(ansSuf[i + 1] , cur); add({-i , 1ll*i*(i+1)/2+ansSuf[i]-pref[i-1]}); } clr(); solve(1 , n); for(int i = 0 ; i < m; ++i) cout << answer[i] << '\n'; return 0; }
a.cc: In function 'void solve(long long int, long long int)': a.cc:62:83: error: no matching function for call to 'max(int, long long int)' 62 | answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0 , 1 - u.fi)); | ~~~^~~~~~~~~~~~~~ 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:62:83: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 62 | answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0 , 1 - u.fi)); | ~~~^~~~~~~~~~~~~~ /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:62:83: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 62 | answer[u.se] = max(answer[u.se] , ansPref[l - 1] + ansSuf[l + 1] + max(0 , 1 - u.fi)); | ~~~^~~~~~~~~~~~~~
s472986088
p03851
C++
#include<cstdio> #include<algorithm> using namespace std; #define int long long #define N 300010 struct no{ int k,b; int f(int x){return k*x+b;} }st[N]; double xl(no a,no b){ return (b.b-a.b)/double(a.k-b.k); } int f[N],g[N],a[N],v[N],h[N],n,tp; void dp(int *f){ for(int i=1;i<=n;i++) v[i]=v[i-1]+a[i]; tp=1; st[1]=(no){0,0}; for(int i=1;i<=n;i++){ while(tp>1&&st[tp].f(i)<=st[tp-1].f(i))tp--; f[i]=max(st[tp].f(i)+(i*i+i)/2-v[i],f[i-1]); no x=(no){-i,f[i]+(i*i-i)/2+v[i]}; while(tp>1&&xl(x,st[tp-1])>=xl(st[tp],st[tp-1]))tp--; st[++tp]=x; } } void fz(int l,int r){ if(l==r){ h[l]=1-a[l]; return; } int md=(l+r)/2; fz(l,md); fz(md+1,r); tp=0; for(int i=l-1;i<md;i++){ no x=(no){-i,f[i]+(i*i-i)/2+v[i]}; while(tp>1&&xl(x,st[tp-1])>=xl(st[tp],st[tp-1]))tp--; st[++tp]=x; } int mx=-1e9; int s=1; for(int i=r;i>md;i--){ while(s<tp&&xl(st[s],st[s+1])>=i)s++; mx=max(mx,st[s].f(i)+(i*i+i)/2-v[i]+g[i+1]); h[i]=max(h[i],mx); } tp=0; for(int i=md+1;i<=r;i++){ no x=(no){-i,g[i+1]+(i*i+i)/2-v[i]}; while(tp>1&&xl(x,st[tp-1])>=xl(st[tp],st[tp-1]))tp--; st[++tp]=x; } s=tp; mx=-1e9; for(int i=l-1;i<md;i++){ while(s>1&&xl(st[s],st[s-1])<=i)s--; mx=max(mx,st[s].f(i)+(i*i-i)/2+v[i]+f[i]); h[i+1]=max(h[i+1],mx); } } signed main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; dp(f); reverse(a+1,a+n+1); dp(g); reverse(a+1,a+n+1); reverse(g+1,g+n+1); for(int i=1;i<=n;i++) v[i]=v[i-1]+a[i]; fz(1,n); int q,x,y; cin>>q; while(q--){ cin>>x>>y; cout<<max(f[x-1]+g[x+1],h[x]-y+a[x])<<'\n'; } }
a.cc: In function 'int main()': a.cc:63:9: error: 'cin' was not declared in this scope 63 | cin>>n; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<algorithm> +++ |+#include <iostream> 3 | using namespace std; a.cc:78:17: error: 'cout' was not declared in this scope 78 | cout<<max(f[x-1]+g[x+1],h[x]-y+a[x])<<'\n'; | ^~~~ a.cc:78:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'