submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s283706376
p03987
C++
题解,解压密码ssd2 https://www.51nod.com/upload/%E6%A8%A1%E6%B5%8B2.rar 比赛网址 https://www.51nod.com/Contest/ContestDescription.html#!#contestId=119
a.cc:1:1: error: '\U00009898\U000089e3\U0000ff0c\U000089e3\U0000538b\U00005bc6\U00007801ssd2' does not name a type 1 | 题解,解压密码ssd2 | ^~~~~~~~~~~~~~~~~~
s944482109
p03987
C++
#include <bits/stdc++.h> #include <iostream> #include <iomanip> #include <ios> #include <vector> #include <string> #include <algorithm> #include <functional> #include <queue> #include <stack> #include <set> #include <cmath> #include <bitset> #include <map> using namespace std; typedef long long ll; #define mp make_pair; #define pb push_back; #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #include <bits/stdc++.h> #define MAX 200010 using namespace std; typedef long long int lli; int n; int v[MAX]; int L[MAX]; int R[MAX]; lli ans; int main() { scanf("%d",&n); v[0] = v[n + 1] = -MAX; rep1(g,n){ scanf("%d",&v[g]); rep1(g,n){ { int cur = g - 1; while(v[cur] > v[g]) cur = L[cur]; L[g] = cur; } for(int g = n ; g >= 1 ; g--) { int cur = g + 1; while(v[cur] > v[g]) cur = R[cur]; R[g] = cur; } for(lli g = 1 ; g <= n ; g++) { lli qtd = (R[g] - g)*(g - L[g]); ans += qtd*v[g]; } printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:70:2: error: expected '}' at end of input 70 | } | ^ a.cc:44:12: note: to match this '{' 44 | rep1(g,n){ | ^ a.cc:70:2: error: expected '}' at end of input 70 | } | ^ a.cc:39:1: note: to match this '{' 39 | { | ^
s506485335
p03987
C++
#include<bits/stdc++.h> using namespace std; long a[1<<18][1<<18],ans; int main(){ long N; cin>>N; for(int i=0;i<N;i++){ cin>>a[0][i]; ans+=a[0][i]; } for(int i=1;i<N;i++){ for(int j=i;j<N;j++){ a[i][j]=min(a[i-1][j],a[i-1][j-1]); ans+=a[i][j]; } } cout<<ans<<endl; }
/tmp/ccXzg8p6.o: in function `main': a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXzg8p6.o a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXzg8p6.o a.cc:(.text+0x150): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXzg8p6.o a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXzg8p6.o a.cc:(.text+0x18f): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXzg8p6.o collect2: error: ld returned 1 exit status
s586613004
p03987
C++
#include<bits/stdc++.h> using namespace std; long N,a[1<<18][1<<18],ans; int main(){ cin>>N; for(int i=0;i<N;i++){ cin>>a[0][i]; ans+=a[0][i]; } for(int i=1;i<N;i++){ for(int j=i;j<N;j++){ a[i][j]=min(a[i-1][j],a[i-1][j-1]); ans+=a[i][j]; } } cout<<ans<<endl; }
/tmp/cc8qHw0T.o: in function `main': a.cc:(.text+0x6e): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc8qHw0T.o a.cc:(.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc8qHw0T.o a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc8qHw0T.o a.cc:(.text+0x160): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc8qHw0T.o a.cc:(.text+0x19b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc8qHw0T.o collect2: error: ld returned 1 exit status
s594357096
p03987
C++
/* ID: div1der LANG: C++ 17 MOOD: CALM READINESS: PRETTY WELL */ #include <iostream> #include <fstream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <bitset> #include <sstream> #include <iomanip> using namespace std; typedef long long ll; typedef vector <int> vi; typedef vector <vector <int>> vii; typedef vector <long long> vll; typedef vector <string> vs; typedef vector <char> vc; typedef set <int> si; typedef set <string> ss; typedef queue <int> qi; typedef queue <long long> qll; typedef queue <string> qs; typedef queue <char> qc; typedef struct board board; typedef pair <int, int> pi; typedef pair <long long, long long> pll; typedef pair <int, pair<int, int>> pii; #define eb emplace_back #define ppb pop_back #define clr(a) a.clear() #define F first #define S second #define mkp make_pair #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define left(x) x * 2 #define right(x) x * 2 + 1 #define bin(l, r) (l + r + 1) >> 1 #define ml " " #define nl endl #define fo(i, a, b) for (int i = a; i <= b; ++ i) #define foo(i, a, b) for (int i = a; i >= b; -- i) #define meme(a, b) memset(a, b, sizeof a) #define TOKAEV_NE_MOY_PRESIDENT return 0 template <typename T> void printArr(const T * arr, int s, int fn) { for (int i = s; i <= fn; ++ i) cout << arr[i] << " "; cout << '\n'; } template <typename T> long long minArr(const T * arr, int s, int fn) { ll res = 1e16 + 1; for (int i = s; i <= fn; ++ i) { res = min(res, arr[i]); } return res; } template <typename T> void printVec(const T * arr) { for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " "; cout << '\n'; } void to_pray() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 2e5 + 10; const int NN = 1e3 + 10; const int MXLOG = 30; const int NNN = 2e3 + 9; const int MOD = 1e9 - 7; const int INF = 1e9 + 7; const ll LLINF = 1e12 + 7; const int EPS = 1e-9 - 8; const int vN = 2e4 + 10; const int sz = (1 << 22) - 1; const int dx[] = {0, 0, 1, -1}; const int dy[] = {1, -1, 0, 0}; const double PI = acos(-1); ll a[N], ans, t[N][30], n; void build() { for (int i = 0; i < n; ++ i) t[i][0] = i; for (int j = 1; (1 << j) <= n; ++ j) { for (int i = 0; (1 << j) + i - 1 < n; ++ i) { if (a[t[i][j - 1]] < a[t[i + (1 << (j - 1))][j - 1]]) t[i][j] = t[i][j - 1]; else t[i][j] = t[(1 << (j - 1)) + i][j - 1]; } } } int get(int l, int r){ int len = (int)(log(r - l + 1) * 1.0) / log(2.0); if (a[t[l][len]] < a[t[r - (1 << len) + 1][len]]) return t[l][len]; else return t[r - (1 << len) + 1][len]; } void func(int l, int r) { if (l == r){ ans += a[l]; return; } int mn = get(l, r); ans += (mn - l + 1) * (r - mn + 1) * a[mn]; if (l <= mn - 1) func(l, mn - 1); if (r >= mn + 1) func(mn + 1, r); } int main () { #ifdef div1der #endif //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); to_pray(); scanf("%d", &n); for (int i = 0; i < n; ++ i) { scnaf("%lld", &a[i];) } build(); func(0, n - 1); printf("%lld\n", sum); return 0; }
a.cc: In function 'int main()': a.cc:155:28: error: expected ')' before ';' token 155 | scnaf("%lld", &a[i];) | ~ ^ | ) a.cc:155:29: error: expected primary-expression before ')' token 155 | scnaf("%lld", &a[i];) | ^ a.cc:162:22: error: 'sum' was not declared in this scope 162 | printf("%lld\n", sum); | ^~~
s092611157
p03987
C++
int main()return 0;
a.cc: In function 'int main()': a.cc:1:18: error: expected identifier before numeric constant 1 | int main()return 0; | ^ a.cc:1:11: error: named return values are no longer supported 1 | int main()return 0; | ^~~~~~ a.cc:1:20: error: expected '{' at end of input 1 | int main()return 0; | ^
s673954822
p03987
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s891942319
p03987
C++
#include<bits/stdc++.h> #define mp make_pair using namespace std; int n; int arr[2000005]; stack< pair<int,int> > st; int main() { cin >> n; for(int i = 0; i < n; i++) cin >> arr[i]; int curSum = 0, res = 0; for (int j = 0; j < n; j++) { if((!st.empty()) && arr[j] >= st.top().first) { curSum += arr[j]; st.push(mp(arr[j], 1)); }else { int cnt = 1; while((!st.empty()) && st.top().first > arr[j]) cnt += st.top().second, curSum -= st.top().second * st.top().first,st.pop(); st.push(mp(arr[j], cnt)); curSum += cnt * arr[j]; } res += curSum; } cout << res << endl; return 0;
a.cc: In function 'int main()': a.cc:34:14: error: expected '}' at end of input 34 | return 0; | ^ a.cc:12:1: note: to match this '{' 12 | { | ^
s096228548
p03987
C++
#include<bits/stdc++.h> #define mp make_pair using namespace std; int n; int arr[100005]; stack< pair<int,int> > st; int main() { cin >> n; for(int i = 0; i < n; i++) cin >> arr[i]; int curSum = 0, res = 0; for (int j = 0; j < n; j++) { if((!st.empty()) && arr[j] >= st.top().first) { curSum += arr[j]; st.push(mp(arr[j], 1)); }else { int cnt = 1; while((!st.empty()) && st.top().first > arr[j]) cnt += st.top().second, curSum -= st.top().second * st.top().first,st.pop(); st.push(mp(arr[j], cnt)); curSum += cnt * arr[j]; } res += curSum; } cout << res << endl; return 0;
a.cc: In function 'int main()': a.cc:34:14: error: expected '}' at end of input 34 | return 0; | ^ a.cc:12:1: note: to match this '{' 12 | { | ^
s082789752
p03987
C++
#include <bits/stdc++.h> using namespace std; using lint=long long; int main(){ lint sum=0ll; int n;cin>>n; vector<lint> a(n); vector<int> pos(n),l(n),r(n); for(int i=0;i<n;i++){ cin>>a[i];pos[a[i]]=i; } for(int i=0;i<n;i++){ l[i]=i; r[i]=i; } for(int i=n;i>=1;i--){ int p=pos[i]; sum+=i*(p-l[p]+1)*(r[p]-p+1); if(p>0) r[l[p-1]]=r[p]; if(p<n-1)l[r[p+1]]]=l[p]; } cout<<sum<<endl; }
a.cc: In function 'int main()': a.cc:22:27: error: expected ';' before ']' token 22 | if(p<n-1)l[r[p+1]]]=l[p]; | ^ | ; a.cc:22:26: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result] 22 | if(p<n-1)l[r[p+1]]]=l[p]; | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:1128:7: note: declared here 1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~
s755961057
p03987
C++
#include "/Users/daikikodama/Desktop/stdc++.h" //#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); i++) #define int long long #define double long double #define mod 1000000007 #define F first #define S second #define P pair<long long,long long> #define all(a) a.begin(),a.end() #define INF 10000000000000000 #define endl '\n' template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; class UnionFindS{ private: vector<int> par; public: UnionFindS(int n){ par=vector<int>(n,-1); } int find(int x){ if(par.at(x)<0) return x; else return par.at(x)=find(par.at(x)); } int size(int x){ return -par.at(find(x)); } void unite(int x, int y){ x=find(x); y=find(y); if(x==y) return; if(size(x)<size(y)) swap(x,y); par.at(x)+=par.at(y); par.at(y)=x; } bool same(int x, int y){ return find(x)==find(y); } }; signed main(void){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; vector<int> a(n),b(n); rep(i,n){ cin>>a.at(i); b.at(a.at(i)-1)=i; } UnionFindS uni(n); int ans=0; for(int i=n-1; i>=0; i--){ int pl=b.at(i); int s=0,t=0; if(pl>0)if(a.at(pl-1)>i+1){ s=uni.size(pl-1); uni.unite(pl,pl-1); } if(pl<n-1)if(a.at(pl+1)>i+1){ t=uni.size(pl+1); uni.unite(pl,pl+1); } ans+=(i+1)*(s+1)*(t+1); } cout<<ans<<endl; }
a.cc:1:10: fatal error: /Users/daikikodama/Desktop/stdc++.h: No such file or directory 1 | #include "/Users/daikikodama/Desktop/stdc++.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s314102998
p03987
C++
#include <stdio.h> #include <algorithm> #include <set> #include <vector> #include <string.h> #include <string> #include <bitset> #include <stdlib.h> #include <assert.h> #include <cmath> #include <chrono> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:32:5: error: 'cout' was not declared in this scope 32 | cout<<ans<<endl; | ^~~~ a.cc:12:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 11 | #include <chrono> +++ |+#include <iostream> 12 | #define ll long long a.cc:32:16: error: 'endl' was not declared in this scope 32 | cout<<ans<<endl; | ^~~~ a.cc:12:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 11 | #include <chrono> +++ |+#include <ostream> 12 | #define ll long long
s260143887
p03987
C++
#include <stdio.h> #include <algorithm> #include <set> #include <vector> #include <string.h> #include <string> #include <bitset> #include <stdlib.h> #include <assert.h> #include <cmath> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:31:5: error: 'cout' was not declared in this scope 31 | cout<<ans<<endl; | ^~~~ a.cc:11:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 10 | #include <cmath> +++ |+#include <iostream> 11 | #define ll long long a.cc:31:16: error: 'endl' was not declared in this scope 31 | cout<<ans<<endl; | ^~~~ a.cc:11:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 10 | #include <cmath> +++ |+#include <ostream> 11 | #define ll long long
s420821403
p03987
C++
#include <stdio.h> #include <algorithm> #include <set> #include <vector> #include <string.h> #include <string> #include <bitset> #include <stdlib.h> #include <assert.h> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:30:5: error: 'cout' was not declared in this scope 30 | cout<<ans<<endl; | ^~~~ a.cc:10:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 9 | #include <assert.h> +++ |+#include <iostream> 10 | #define ll long long a.cc:30:16: error: 'endl' was not declared in this scope 30 | cout<<ans<<endl; | ^~~~ a.cc:10:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 9 | #include <assert.h> +++ |+#include <ostream> 10 | #define ll long long
s428833386
p03987
C++
#include <stdio.h> #include <algorithm> #include <set> #include <vector> #include <string.h> #include <string> #include <stdlib.h> #include <assert.h> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:29:5: error: 'cout' was not declared in this scope 29 | cout<<ans<<endl; | ^~~~ a.cc:9:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 8 | #include <assert.h> +++ |+#include <iostream> 9 | #define ll long long a.cc:29:16: error: 'endl' was not declared in this scope 29 | cout<<ans<<endl; | ^~~~ a.cc:9:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 8 | #include <assert.h> +++ |+#include <ostream> 9 | #define ll long long
s450506974
p03987
C++
#include <stdio.h> #include <algorithm> #include <set> #include <vector> #include <string.h> #include <string> #include <stdlib.h> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:28:5: error: 'cout' was not declared in this scope 28 | cout<<ans<<endl; | ^~~~ a.cc:8:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 7 | #include <stdlib.h> +++ |+#include <iostream> 8 | #define ll long long a.cc:28:16: error: 'endl' was not declared in this scope 28 | cout<<ans<<endl; | ^~~~ a.cc:8:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 7 | #include <stdlib.h> +++ |+#include <ostream> 8 | #define ll long long
s344357081
p03987
C++
#include <stdio.h> #include <algorithm> #include <set> #include <vector> #include <string.h> #include <string> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:27:5: error: 'cout' was not declared in this scope 27 | cout<<ans<<endl; | ^~~~ a.cc:7:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 6 | #include <string> +++ |+#include <iostream> 7 | #define ll long long a.cc:27:16: error: 'endl' was not declared in this scope 27 | cout<<ans<<endl; | ^~~~ a.cc:7:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 6 | #include <string> +++ |+#include <ostream> 7 | #define ll long long
s781531093
p03987
C++
#include <stdio.h> #include <set> #include <vector> #include <string.h> #include <string> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:26:5: error: 'cout' was not declared in this scope 26 | cout<<ans<<endl; | ^~~~ a.cc:6:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include <string> +++ |+#include <iostream> 6 | #define ll long long a.cc:26:16: error: 'endl' was not declared in this scope 26 | cout<<ans<<endl; | ^~~~ a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 5 | #include <string> +++ |+#include <ostream> 6 | #define ll long long
s135209699
p03987
C++
#include <stdio.h> #include <set> #include <vector> #include <string.h> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:25:5: error: 'cout' was not declared in this scope 25 | cout<<ans<<endl; | ^~~~ a.cc:5:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 4 | #include <string.h> +++ |+#include <iostream> 5 | #define ll long long a.cc:25:16: error: 'endl' was not declared in this scope 25 | cout<<ans<<endl; | ^~~~ a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 4 | #include <string.h> +++ |+#include <ostream> 5 | #define ll long long
s715180472
p03987
C++
#include <stdio.h> #include <set> #include <vector> #define ll long long #define rep2(i,a,b) for(ll i=a;i<=b;i++) #define rep(i,n) for(ll i=0;i<n;i++) #define vec vector<int> #define All(c) (c).begin(),(c).end() using namespace std; int in() {int x;scanf("%d",&x);return x;} int main(){ int n=in(); ll ans=0; set<int> set; vec a(n+2); rep(i,n)a[in()]=i+1; set.insert(0); set.insert(n+1); rep2(k,1,n){ auto x=set.upper_bound(a[k]); ans+=(*x-a[k])*(a[k]-*--x)*k; set.insert(a[k]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:24:5: error: 'cout' was not declared in this scope 24 | cout<<ans<<endl; | ^~~~ a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <vector> +++ |+#include <iostream> 4 | #define ll long long a.cc:24:16: error: 'endl' was not declared in this scope 24 | cout<<ans<<endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include <vector> +++ |+#include <ostream> 4 | #define ll long long
s342050310
p03987
C++
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <unordered_map> #include <utility> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <cstdio> #include <math.h> #include <stdio.h> using namespace std; #define REP(i,n,m) for( long long int i = (n); i < (m); i++ ) #define ll long long #define ALL(a) (a).begin(), (a).end() #define SORT(v) sort( ALL(v) ); #define LAST(v) v[v.size()-1] #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #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 pi pair<int, int> #define MP make_pair #define PB push_back #define IIN(a) int a; cin >> a; #define LIN(a) ll a; cin >> a; #define SIN(a) string a; cin >> a; #define EPS (1e-10) #define INF 1000000000000LL int MOD=1000000007; int dx[4] = {0, 0, -1, 1}; int dy[4] = {1, -1, 0, 0}; //I ASCII code: '0' = 48; 'A' = 65; 'a' = 97 ll INT_MAX = 100000000 const ll MAX_N = 1LL << 17; ll n,dat[ 2 * MAX_N - 1 ]; ll dls = 1,ep = 0,v_num = 1,d = 1; void init( ll n_ ){ n = 1; while( n < n_ ){ n *= 2; v_num += n; d++; } dls = n; for( ll i = 0; i < 2 * n - 1 ; i++ ) dat[i] = INT_MAX; } void update( ll k,ll a ){ k += n - 1; dat[k] = a; while( k > 0 ){ k = ( k - 1 ) / 2; dat[ k ] = fmin( dat[ k * 2 + 1 ], dat[ k * 2 + 2 ] ); } } ll query(ll a, ll b, ll k, ll l , ll r){ if( r <= a || b <= l){ return INT_MAX; }else if( a <= l && r <= b ){ return dat[k]; } else{ ll vl = query( a, b, k * 2 + 1, l, ( l + r ) / 2 ); ll vr = query( a, b, k * 2 + 2, ( l + r ) / 2, r); return fmin( vl, vr ); } } signed main(){ IIN(b) init(b); ll ans = 0; REP(i, 0, b ){ IIN(a) update(i,a); } REP( i, 0, b ){ REP( j, i, b ){ // cout << query( i , j + 1 , 0, 0, b )<< endl; ans += query( i, j + 1, 0, 0, b ); } } cout << ans << endl; return 0; }
a.cc:47:1: error: expected ',' or ';' before 'const' 47 | const ll MAX_N = 1LL << 17; | ^~~~~ a.cc:48:15: error: 'MAX_N' was not declared in this scope 48 | ll n,dat[ 2 * MAX_N - 1 ]; | ^~~~~ a.cc: In function 'void init(long long int)': a.cc:61:40: error: 'dat' was not declared in this scope 61 | for( ll i = 0; i < 2 * n - 1 ; i++ ) dat[i] = INT_MAX; | ^~~ a.cc: In function 'void update(long long int, long long int)': a.cc:66:3: error: 'dat' was not declared in this scope 66 | dat[k] = a; | ^~~ a.cc: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)': a.cc:81:12: error: 'dat' was not declared in this scope 81 | return dat[k]; | ^~~
s938308052
p03987
C++
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <unordered_map> #include <utility> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <cstdio> #include <math.h> #include <stdio.h> using namespace std; #define REP(i,n,m) for( long long int i = (n); i < (m); i++ ) #define ll long long #define ALL(a) (a).begin(), (a).end() #define SORT(v) sort( ALL(v) ); #define LAST(v) v[v.size()-1] #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #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 pi pair<int, int> #define MP make_pair #define PB push_back #define IIN(a) int a; cin >> a; #define LIN(a) ll a; cin >> a; #define SIN(a) string a; cin >> a; #define EPS (1e-10) #define INF 1000000000000LL int MOD=1000000007; int dx[4] = {0, 0, -1, 1}; int dy[4] = {1, -1, 0, 0}; //I ASCII code: '0' = 48; 'A' = 65; 'a' = 97 const ll MAX_N = 1LL << 17; ll n,dat[ 2 * MAX_N - 1 ]; ll dls = 1,ep = 0,v_num = 1,d = 1; void init( ll n_ ){ n = 1; while( n < n_ ){ n *= 2; v_num += n; d++; } dls = n; for( ll i = 0; i < 2 * n - 1 ; i++ ) dat[i] = 10000000; } void update( ll k,ll a ){ k += n - 1; dat[k] = a; while( k > 0 ){ k = ( k - 1 ) / 2; dat[ k ] = fmin( dat[ k * 2 + 1 ], dat[ k * 2 + 2 ] ); } } ll query(ll a, ll b, ll k, ll l , ll r){ if( r <= a || b <= l){ return INT_MAX; }else if( a <= l && r <= b ){ return dat[k]; } else{ ll vl = query( a, b, k * 2 + 1, l, ( l + r ) / 2 ); ll vr = query( a, b, k * 2 + 2, ( l + r ) / 2, r); return fmin( vl, vr ); } } signed main(){ IIN(b) init(b); ll ans = 0; REP(i, 0, b ){ IIN(a) update(i,a); } REP( i, 0, b ){ REP( j, i, b ){ // cout << query( i , j + 1 , 0, 0, b )<< endl; ans += query( i, j + 1, 0, 0, b ); } } cout << ans << endl; return 0; }
a.cc: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)': a.cc:76:14: error: 'INT_MAX' was not declared in this scope 76 | return INT_MAX; | ^~~~~~~ a.cc:18:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 17 | #include <math.h> +++ |+#include <climits> 18 | #include <stdio.h>
s777353978
p03987
C++
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <unordered_map> #include <utility> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <cstdio> #include <math.h> #include <stdio.h> using namespace std; #define REP(i,n,m) for( long long int i = (n); i < (m); i++ ) #define ll long long #define ALL(a) (a).begin(), (a).end() #define SORT(v) sort( ALL(v) ); #define LAST(v) v[v.size()-1] #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #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 pi pair<int, int> #define MP make_pair #define PB push_back #define IIN(a) int a; cin >> a; #define LIN(a) ll a; cin >> a; #define SIN(a) string a; cin >> a; #define EPS (1e-10) #define INF 1000000000000LL int MOD=1000000007; int dx[4] = {0, 0, -1, 1}; int dy[4] = {1, -1, 0, 0}; //I ASCII code: '0' = 48; 'A' = 65; 'a' = 97 const ll MAX_N = 1LL << 17; ll n,dat[ 2 * MAX_N - 1 ]; ll dls = 1,ep = 0,v_num = 1,d = 1; void init( ll n_ ){ n = 1; while( n < n_ ){ n *= 2; v_num += n; d++; } dls = n; for( ll i = 0; i < 2 * n - 1 ; i++ ) dat[i] = INT_MAX; } void update( ll k,ll a ){ k += n - 1; dat[k] = a; while( k > 0 ){ k = ( k - 1 ) / 2; dat[ k ] = fmin( dat[ k * 2 + 1 ], dat[ k * 2 + 2 ] ); } } ll query(ll a, ll b, ll k, ll l , ll r){ if( r <= a || b <= l){ return INT_MAX; }else if( a <= l && r <= b ){ return dat[k]; } else{ ll vl = query( a, b, k * 2 + 1, l, ( l + r ) / 2 ); ll vr = query( a, b, k * 2 + 2, ( l + r ) / 2, r); return fmin( vl, vr ); } } signed main(){ IIN(b) init(b); ll ans = 0; REP(i, 0, b ){ IIN(a) update(i,a); } REP( i, 0, b ){ REP( j, i, b ){ cout << query( i , j + 1 , 0, 0, b )<< endl; ans += query( i, j + 1, 0, 0, b ); } } cout << ans << endl; return 0; }
a.cc: In function 'void init(long long int)': a.cc:61:49: error: 'INT_MAX' was not declared in this scope 61 | for( ll i = 0; i < 2 * n - 1 ; i++ ) dat[i] = INT_MAX; | ^~~~~~~ a.cc:18:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 17 | #include <math.h> +++ |+#include <climits> 18 | #include <stdio.h> a.cc: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)': a.cc:76:14: error: 'INT_MAX' was not declared in this scope 76 | return INT_MAX; | ^~~~~~~ a.cc:76:14: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s566262388
p03987
C++
#include <iostream> #include <vector> #include <set> using namespace std; #define int long long int main() { int N; vector<int> A(N + 1); cin >> N; for (int i = 1; i <= N; i++) cin >> A[i]; vector<long> idx(N + 1); for (int i = 1; i <= N; i++) idx[A[i]] = i; long res = 0; set<int> st = {0, N + 1}; for (int i = 1; i <= N; i++) { auto itr = st.lower_bound(idx[i]); int right = *itr; int left = *(--itr); res += i * (idx[i] - left) * (right - idx[i]); st.insert(idx[i]); } cout << res << "\n"; return 0; }
cc1plus: error: '::main' must return 'int'
s890677497
p03987
C++
#include <iostream> #include <string> #include <vector> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <map> #include <stack> #include <queue> #include <set> #include <cstring> using namespace std; // ascending order #define vsort(v) sort(v.begin(), v.end()) // descending order #define vsort_r(v) sort(v.begin(), v.end(), greater<int>()) #define vunique(v) unique(v.begin(), v.end()) #define mp make_pair #define ts(x) to_string(x) #define rep(i, a, b) for(int i = (int)a; i < (int)b; i++) #define repm(i, a, b) for(int i = (int)a; i > (int)b; i--) #define bit(a) bitset<8>(a) #define des_priority_queue priority_queue<int, vector<int>, greater<int> > #define all(v) (v).begin(), (v).end() typedef long long ll; typedef pair<int, int> P; const ll INF = 1e18; const int MAX_N = 1 << 17; // セグメント木を持つグロバール配列 int n, dat[2 * MAX_N - 1]; // 初期化 void init(int n_) { // 簡単のため、要素数を2のべき乗に n = 1; while(n < n_) n *= 2; // 全ての値をINT_MAXに for(int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX; } // k番目の値(0-indexed)をaに変更 void update(int k, int a) { // 葉の節点 k += n - 1; dat[k] = a; // 登りながら更新 while(k > 0) { k = (k - 1) / 2; dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]); } } // [a, b)の最小値を求める // 後ろの方の引数は、計算の簡単のための引数 // kは節点の番号、1、rはその節点が[1,r)に対応づいていることを表す // したがって、外からはquery(a, b, 0, 0, n)として呼ぶ int query(int a, int b, int k, int l, int r) { // [a, b)と[l,r)が交差しなければ、INT_MAX if(r <= a or b <= l) return INT_MAX; // [a, b)が[l,r)を完全に含んでいれば、この節点の値 if(a <= l and r <= b) return dat[k]; else { // そうでなければ、2つの子の最小値 int vl = query(a, b, k * 2 + 1, l, (l + r) / 2); int vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return min(vl, vr); } } int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int a[N]; init(N); rep(i, 0, N) { cin >> a[i]; update(i, a[i]); } ll rsl = 0; rep(l, 0, N) rep(r, l, N) { rsl += query(l, r + 1, 0, 0, n); } cout << rsl << endl; }
a.cc: In function 'void init(int)': a.cc:43:53: error: 'INT_MAX' was not declared in this scope 43 | for(int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX; | ^~~~~~~ a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 12 | #include <cstring> +++ |+#include <climits> 13 | a.cc: In function 'int query(int, int, int, int, int)': a.cc:64:37: error: 'INT_MAX' was not declared in this scope 64 | if(r <= a or b <= l) return INT_MAX; | ^~~~~~~ a.cc:64:37: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s343410937
p03987
C++
import java.util.*; public class Main { static int[] bit; static int n; public static void main(String[] args){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); bit = new int[n+1]; int[] pos = new int[n+1]; int[] a = new int[n+1]; for(int i=1;i<=n;i++){ a[i] = sc.nextInt(); pos[a[i]] = i; } int[] left = new int[n+1], right = new int[n+1]; TreeSet<Integer> ts = new TreeSet<>(); for(int v=1;v<=n;v++){ int p = pos[v]; Integer x = ts.lower(p); if(x==null) left[v]=p; // 1-base. else left[v] = p-x; ts.add(p); } ts = new TreeSet<>(); for(int v=1;v<=n;v++){ int p = pos[v]; Integer y = ts.higher(p); if(y==null) right[v] = n+1-p; else right[v] = y-p; ts.add(p); } long ans = 0; for(int v=1;v<=n;v++){ long cur = ((long) v)*((long)left[v])*((long)right[v]); ans += cur; } System.out.println(ans); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s813349903
p03987
C++
#include <bits/stdc++.h> using namespace std; const ll N=5e5; ll n,A; ll a[N],l[N],k[N],r[N]; ll cmp(ll x,ll y) { return a[x]>a[y]; } int main() { cin>>n; for (ll i=0;++i<=n;) scanf("%d",a+i), l[i]=i-1,k[i]=i,r[i]=i+1; sort(k+1,k+n+1,cmp); for (ll i=0;++i<=n;) { A+=a[k[i]]*(r[k[i]]-k[i])*(k[i]-l[k[i]]); r[l[k[i]]]=r[k[i]]; l[r[k[i]]]=l[k[i]]; } cout<<A; exit(0); }
a.cc:3:7: error: 'll' does not name a type 3 | const ll N=5e5; | ^~ a.cc:5:3: error: 'll' does not name a type 5 | ll n,A; | ^~ a.cc:6:3: error: 'll' does not name a type 6 | ll a[N],l[N],k[N],r[N]; | ^~ a.cc:7:1: error: 'll' does not name a type 7 | ll cmp(ll x,ll y) | ^~ a.cc: In function 'int main()': a.cc:14:8: error: 'n' was not declared in this scope; did you mean 'yn'? 14 | cin>>n; | ^ | yn a.cc:15:8: error: 'll' was not declared in this scope 15 | for (ll i=0;++i<=n;) | ^~ a.cc:15:17: error: 'i' was not declared in this scope 15 | for (ll i=0;++i<=n;) | ^ a.cc:16:16: error: 'a' was not declared in this scope 16 | scanf("%d",a+i), | ^ a.cc:17:11: error: 'l' was not declared in this scope 17 | l[i]=i-1,k[i]=i,r[i]=i+1; | ^ a.cc:17:20: error: 'k' was not declared in this scope 17 | l[i]=i-1,k[i]=i,r[i]=i+1; | ^ a.cc:17:27: error: 'r' was not declared in this scope 17 | l[i]=i-1,k[i]=i,r[i]=i+1; | ^ a.cc:18:8: error: 'k' was not declared in this scope 18 | sort(k+1,k+n+1,cmp); | ^ a.cc:18:18: error: 'cmp' was not declared in this scope; did you mean 'bcmp'? 18 | sort(k+1,k+n+1,cmp); | ^~~ | bcmp a.cc:19:8: error: 'll' was not declared in this scope 19 | for (ll i=0;++i<=n;) | ^~ a.cc:19:17: error: 'i' was not declared in this scope 19 | for (ll i=0;++i<=n;) | ^ a.cc:21:7: error: 'A' was not declared in this scope 21 | A+=a[k[i]]*(r[k[i]]-k[i])*(k[i]-l[k[i]]); | ^ a.cc:21:10: error: 'a' was not declared in this scope 21 | A+=a[k[i]]*(r[k[i]]-k[i])*(k[i]-l[k[i]]); | ^ a.cc:21:19: error: 'r' was not declared in this scope 21 | A+=a[k[i]]*(r[k[i]]-k[i])*(k[i]-l[k[i]]); | ^ a.cc:21:39: error: 'l' was not declared in this scope 21 | A+=a[k[i]]*(r[k[i]]-k[i])*(k[i]-l[k[i]]); | ^ a.cc:25:9: error: 'A' was not declared in this scope 25 | cout<<A; | ^
s642966906
p03987
C
#include <cstdio> #include <cstdint> #include <iostream> #include <iomanip> #include <string> #include <queue> #include <stack> #include <vector> #include <set> #include <map> #include <unordered_map> #include <algorithm> #include <utility> #include <cmath> #include <climits> #include <bitset> #define ll long long int #define pb push_back #define mk make_pair #define pq priority_queue using namespace std; typedef pair<int, int> P; typedef pair<ll, int> Pl; typedef pair<ll, ll> Pll; const int inf = 1e9; const ll linf = 1LL << 50; const double EPS = 1e-10; int main(int argc, char const* argv[]) { int n; cin >> n; vector<int> a; vector<int> tr = vector<int>(n + 1, 0); for(int i = 0; i < n; i++){ int x; cin >> x; a.pb(x); tr[x] = i; } set<int> st; ll res = 0; for(int i = 1; i <= n; i++){ auto itr = st.upper_bound(tr[i]); int rd = (itr == st.end()) ? n: *itr; int ld; if(itr == st.begin())ld = -1; else { itr--; ld = *itr; } res += (ll)i * (tr[i] - ld) * (rd - tr[i]); st.insert(tr[i]); } cout << res << endl; return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s709565778
p03987
C
#include <cstdio> #include <cstdint> #include <iostream> #include <iomanip> #include <string> #include <queue> #include <stack> #include <vector> #include <set> #include <map> #include <unordered_map> #include <algorithm> #include <utility> #include <cmath> #include <climits> #include <bitset> #define ll long long int #define pb push_back #define mk make_pair #define pq priority_queue using namespace std; typedef pair<int, int> P; typedef pair<ll, int> Pl; typedef pair<ll, ll> Pll; const int inf = 1e9; const ll linf = 1LL << 50; const double EPS = 1e-10; int main(int argc, char const* argv[]) { int n; cin >> n; vector<int> a = vector<int>(n, 0); vector<int> tr = vector<int>(n + 1, 0); for(int i = 0; i < n; i++){ int x; scanf("%d", &x); a[i] = x; tr[x] = i; } set<int> st; ll res = 0; for(int i = 1; i <= n; i++){ auto itr = upper_bound(st.begin(), st.end(), tr[i]); int rd = (itr == st.end()) ? n: *itr; int ld; if(itr == st.begin())ld = -1; else { itr--; ld = *itr; } res += (ll)i * (tr[i] - ld) * (rd - tr[i]); st.insert(tr[i]); } cout << res << endl; return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s013854533
p03987
Java
import java.io.*; import java.util.*; /* * // Given an array A[] , calculate the sum of minimum of all subarrays of A. * e.g, A[] = {1, 2, 3} , ans = sum( min({1}), min({2}), min({3}), min({1, 2}), min({2, 3}), min({1, 2, 3}) ) = 10 2 5 8 9= 2*4+5*3+8*2+9*1 6 4 1 7 8 6 1 1=1*1 4 1 2=2*1 1 1 5=3*3 7 4 5=1*2 8 5 5=1*1 */ class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int arr[]=new int[n+2]; int leftSmall[]=new int[n+2]; int rightSmall[]=new int[n+2; for(int i=0;i<n;i++) arr[i]=sc.nextInt(); int leftIdx=0; Stack<Integer> stk=new Stack<>(); for(int i=0;i<n;i++){ while(!stk.isEmpty() && arr[i]<arr[stk.peek()]){ stk.pop(); } if(stk.isEmpty()) leftSmall[i]=-1; else{ leftSmall[i]=stk.peek(); } stk.push(i); } stk.clear(); for(int i=n-1;i>=0;i--){ while(!stk.isEmpty() && arr[i]<arr[stk.peek()]){ stk.pop(); } if(stk.isEmpty()) rightSmall[i]=n; else{ rightSmall[i]=stk.peek(); } stk.push(i); } long ans=0; for(int i=0;i<n;i++){ long left=i-leftSmall[i]; long right=rightSmall[i]-i; ans+=((left*right)*arr[i]); } System.out.println(ans); } }
Main.java:26: error: ']' expected int rightSmall[]=new int[n+2; ^ 1 error
s338453299
p03987
C++
int main() { int n;cin>>n; vector<long long> a(n+1),r(n+1); for(int i=1;i<=n;i++){ cin>>a[i]; r[a[i]]=i; } // priority_queue<long long,vector<long long>,greater<long long>> q; // vector<long long> v; map<long long,int> m; m[r[1]]=0; // q.push(r[1]); // v.push_back(r[1]); long long ans=(n-r[1]+1)*r[1]; for(int i=2;i<=n;i++){ // int num=lower_bound(v.begin(),v.end(),r[i])-v.begin(); auto itr=m.lower_bound(r[i]); long long left,right; // if(num==0){ // left=0; // }else{ // left=v[num-1]; // } if(itr==m.begin()){ left=0; }else{ itr--; left=itr->first; itr++; } if(itr==m.end()){ right=n+1; }else{ right=itr->first; } // if(num==v.size()){ // right=n+1; // }else{ // right=v[num]; // } ans+=i*(right-r[i])*(r[i]-left); m[r[i]]=0; // v.insert(v.begin()+num,r[i]); // cout<<ans<<' '<<i<<' '<<left<<' '<<right<<endl; // for(int j=0;j<v.size();j++){ // cout<<v[j]<<' '; // } // cout<<endl; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:2:15: error: 'cin' was not declared in this scope 2 | int n;cin>>n; | ^~~ a.cc:3:9: error: 'vector' was not declared in this scope 3 | vector<long long> a(n+1),r(n+1); | ^~~~~~ a.cc:3:16: error: expected primary-expression before 'long' 3 | vector<long long> a(n+1),r(n+1); | ^~~~ a.cc:5:22: error: 'a' was not declared in this scope 5 | cin>>a[i]; | ^ a.cc:6:17: error: 'r' was not declared in this scope 6 | r[a[i]]=i; | ^ a.cc:10:9: error: 'map' was not declared in this scope 10 | map<long long,int> m; | ^~~ a.cc:10:13: error: expected primary-expression before 'long' 10 | map<long long,int> m; | ^~~~ a.cc:11:9: error: 'm' was not declared in this scope 11 | m[r[1]]=0; | ^ a.cc:11:11: error: 'r' was not declared in this scope 11 | m[r[1]]=0; | ^ a.cc:50:9: error: 'cout' was not declared in this scope 50 | cout<<ans<<endl; | ^~~~ a.cc:50:20: error: 'endl' was not declared in this scope 50 | cout<<ans<<endl; | ^~~~
s554101660
p03987
C++
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vpii = vector<pii>; using vpll = vector<pll>; using vs = vector<string>; template <typename T> using ost = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define forn(i,n) for(int i=0; i<int(n); ++i) #define all(x) (x).begin(), (x).end() #define pb push_back #define ff first #define ss second int main() { ios::sync_with_stdio(false); int n; cin >> n; vi xs(n); forn(i, n) cin>>xs[i]; vvl D(2, vl(n)); forn(_, 2) { vpii stk; stk.pb(pii(0, -1)); forn(i, n) { while (stk.back().ff >= xs[i]) stk.pop_back(); D[_][i] = i - stk.back().ss; stk.pb(pii(xs[i], i)); } reverse(all(xs)); } reverse(all(D[1])); ll ans = 0; forn(i, n) ans += xs[i]*(D[0][i]*D[1][i]); cout << ans << '\n'; }
a.cc: In function 'int main()': a.cc:30:5: error: 'vvl' was not declared in this scope; did you mean 'vvll'? 30 | vvl D(2, vl(n)); | ^~~ | vvll a.cc:37:13: error: 'D' was not declared in this scope 37 | D[_][i] = i - stk.back().ss; | ^ a.cc:42:17: error: 'D' was not declared in this scope 42 | reverse(all(D[1])); | ^ a.cc:19:17: note: in definition of macro 'all' 19 | #define all(x) (x).begin(), (x).end() | ^
s208260746
p03987
C++
#include<iostream> #include<fstream> #include<string> #include<cstring> #include<stdio.h> #include<algorithm> #include<functional> #include<vector> #include<set> #include<queue> #include<list> #include<stdio.h> #include<stdlib.h> #include<map> #include<cstdio> #include <iomanip> using namespace std; template<class T>bool chmax(T &a, const T &b) { return (a<b) ? (a = b, 1) : 0; } template<class T>bool chmin(T &a, const T &b) { return (b<a) ? (a = b, 1) : 0; } typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef int _loop_int; #define rep(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define CHMIN(a,b) a=min((a),(b)) #define CHMAX(a,b) a=max((a),(b)) // mod const ll MOD = 1000000007ll; #define FIX(a) ((a)%MOD+MOD)%MOD // floating typedef double Real; const Real EPS = 1e-11; #define EQ0(x) (abs(x)<EPS) #define EQ(a,b) (abs(a-b)<EPS) typedef vector<int> vi; typedef pair<int, int> pii; const int N = 1234567; int a[N], pr[N], ne[N], pos[N]; #define scanf scanf_s int main() { int n; scanf("%d", &n); //大きい要素順に取り出せるように要素を指定すると、ai上での添字が返って //くるようにする。0,n+1を番兵として1,2,…nに要素を格納していく。 for (int i = 1; i <= n; i++) { scanf("%d", a + i); pos[a[i]] = i; } //各番号の前後をもっておきたい。初期化。 for (int i = 0; i <= n + 1; i++) { pr[i] = i - 1; ne[i] = i + 1; } long long ans = 0; //大きい要素から順番に空の区間に加えていく。 for (int i = n; i >= 1; i--) { int j = pos[i]; ans += i * 1LL * (j - pr[j]) * (ne[j] - j); //これから先入ってくる要素は、すでにある要素より小さい。 //つまり今ある要素は以降挿入される要素を最小値区間にかならず含まれる。 //要素を挿入した区間は拡張される。 //左端として、挿入した要素の右端を持つ区間は、挿入した要素の左端まで拡張 pr[ne[j]] = pr[j]; //右端も同様 ne[pr[j]] = ne[j]; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:60:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 60 | #define scanf scanf_s | ^~~~~~~ a.cc:63:9: note: in expansion of macro 'scanf' 63 | scanf("%d", &n); | ^~~~~
s714077235
p03987
C
#include <iostream> #include <bitset> #include <fstream> #include <string> #include <cstring> #include <cmath> #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <functional> #include <cctype> #include <list> #include <limits> //#include <boost/multiprecision/cpp_int.hpp> #define BIT(a) (1 << (a)) #define EPS (1e-10) using namespace std; //using namespace boost::multiprecision; const long long MOD = 1000000007; const int COUNTER_CLOCKWISE = 1; const int CLOCKWISE = -1; const int ONLINE_BACK = 2; const int ONLINE_FRONT = -2; const int ON_SEGMENT = 0; class DisjointSet{ public: vector<int> rank, p; DisjointSet(){} DisjointSet(int size){ rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size; i++) makeSet(i); } void makeSet(int x){ p[x] = x; rank[x] = 0; } bool same(int x, int y){ return findSet(x) == findSet(y); } void unite(int x, int y){ link(findSet(x), findSet(y)); } void link(int x, int y){ if (rank[x] > rank[y]){ p[y] = x; }else{ p[x] = y; if (rank[x] == rank[y]){ rank[y]++; } } } int findSet(int x){ if (x != p[x]){ p[x] = findSet(p[x]); } return p[x]; } }; class Point{ public: double x, y; Point(double x = 0, double y = 0): x(x), y(y) {} Point operator+(Point p){return Point(x + p.x, y + p.y);} Point operator-(Point p){return Point(x - p.x, y - p.y);} Point operator*(double a){return Point(a * x, a * y);} Point operator/(double a){return Point(x / a, y / a);} bool operator < (const Point &p) const { return y != p.y ? y < p.y : x < p.x; } double norm(){return x * x + y * y;} }; typedef Point Vector; typedef vector<Vector> Polygon; double cross(Vector a, Vector b){ return a.x*b.y - a.y*b.x; } double dot(Vector a, Vector b){ return a.x * b.x + a.y * b.y; } int ccw(Point p0, Point p1, Point p2){ Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS)return COUNTER_CLOCKWISE; if (cross(a, b) > -EPS)return CLOCKWISE; if (dot(a, b) < -EPS)return ONLINE_BACK; if (a.norm() < b.norm())return ONLINE_FRONT; return ON_SEGMENT; } Polygon andrewScan(Polygon s){ Polygon u, l; if (s.size() < 3) return s; sort(s.begin(), s.end()); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size()-1]); l.push_back(s[s.size()-2]); for (size_t i = 2; i < s.size(); i++){ for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){ u.pop_back(); } u.push_back(s[i]); } for (int i = (int)s.size() - 3; i >= 0; i--){ for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){ l.pop_back(); } l.push_back(s[i]); } reverse(l.begin(), l.end()); for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]); return l; } long long mss(long long A[], int l, int r){ int left; int right; long long ma; long long ma2; for (int i = l; i < r; i++){ if (i == l){ ma = A[i]; ma2 = A[i]; continue; } ma2 = max(A[i], ma2+A[i]); ma = max(ma2, ma); } return ma; } long long mod_pow(long long x, long long n){ long long res = 1; for(int i = 0;i < 60; i++){ if(n >> i & 1) res = res * x % MOD; x = x * x % MOD; } return res; } int a[200005]; int position[200005]; set<int> s; int main(){ int N; long long ans = 0; cin >> N; for (int i = 0; i < N; i++){ cin >> a[i]; position[a[i]] = i; s.insert(i); } s.insert(N); s.insert(-1); for (int i = N; i > 0; i--){ auto pos = s.find(position[i]); int l = *(--pos); int r = *(++++pos); s.erase(--pos); ans += (position[i] - l) * (r - position[i]) * i; } cout << ans << endl; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s599130324
p03987
C++
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #include "set" #include "stack" #define lp(n) for (int i = 0; i < n; i++) #define LP(n,i) for (int i = 0; i < n; i++) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" typedef long long ll; using namespace std; ll n,a[200000],mem,ans; set<int>st; int main(){ cin>>n; lp(n){ cin>>mem; a[mem-1]=i; } ans=(a[0]+1)*(n-a[0]); st.insert(a[0]); lp(n-1){ auto it=st.end(); it--; it2--; if(a[i+1]<*st.begin()){ ans+=(a[i+1]+1)*(*st.begin()-a[i+1])*(i+2); } else if(*it<a[i+1]){ ans+=(a[i+1]-*it)*(n-a[i+1])*(i+2); } else { auto it2=lower_bound(st.begin(),st.end(),a[i+1]); auto it3=it2; ans+=(a[i+1]-*it2)*(*it3-a[i+1])*(i+2); } st.insert(a[i+1]); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:39:17: error: 'it2' was not declared in this scope; did you mean 'it'? 39 | it2--; | ^~~ | it
s051835870
p03987
C++
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #include "set" #include "stack" #define lp(n) for (int i = 0; i < n; i++) #define LP(n,i) for (int i = 0; i < n; i++) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" typedef long long ll; using namespace std; ll n,a[200000],mem,ans; set<int>st; int main(){ cin>>n; lp(n){ cin>>mem; a[mem-1]=i; } ans=(a[0]+1)*(n-a[0]); st.insert(a[0]); cout<<ans<<endl; lp(n-1){ auto it=st.end(); it--; auto it2=lower_bound(st.begin(),st.end(),a[i+1]); auto it3=it2; it2--; if(a[i+1]<*st.begin()){ ans+=(a[i+1]+1)*(*st.begin()-a[i+1])*(i+2); } else if(*it<a[i+1]){ ans+=(a[i+1]-*it)*(n-a[i+1])*(i+2); } else { ans+=(a[i+1]-*it2)*(*it3-a[i+1])*(i+2); } st.insert(a[i+1]); } cout<<ans<<endl; return 0;
a.cc: In function 'int main()': a.cc:54:18: error: expected '}' at end of input 54 | return 0; | ^ a.cc:27:11: note: to match this '{' 27 | int main(){ | ^
s481915358
p03987
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class AGC005B{ static int SZ=500; public static void main(String[] args) throws IOException { MyScanner sc = new MyScanner(System.in); int n=sc.nextInt(); long[] a = new long[n]; for(int i=0; i<n; i++) a[i]=sc.nextLong(); long[]bkt=new long[400]; Arrays.fill(bkt, Long.MAX_VALUE); for(int i=0; i<n; i++) { bkt[i/SZ]=Math.min(a[i], bkt[i/SZ]); } long ans=0; for(int i=0; i<n; i++) { int l=0; for(;l<400; l++) { if(bkt[l]==a[i]) break; } if(l>399) { int kl; for(kl=0; i-kl>=0; kl++) { if(a[i]>a[i-kl]) break; } int kr; for(kr=0; i+kr<n; kr++) { if(a[i]>a[i+kr]) break; } //ans+=(1+kr)*(1+kl); long b=kr*kl; ans+=b*a[i]; } else { int r=l; for(;r<400; r++) { if(bkt[r]!=a[i]) break; } // l*SZ..r*sz l=Math.max(0, (l-1)*SZ); r=Math.min(n-1, (r+2)*SZ); int kl; for(kl=0; i-kl>=l; kl++) { if(a[i]>a[i-kl]) break; } int kr=0; for(;i+kr<=r; kr++) { if(a[i]>a[i+kr]) break; } //ans+=(1+kr)*(1+kl); long b=kr*kl; ans+=b*a[i]; } } System.out.println(ans); } static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner(InputStream s) { br=new BufferedReader(new InputStreamReader(s)); } public String nextLine() throws IOException { return br.readLine(); } public String next() throws IOException { while(st==null || !st.hasMoreTokens()) st=new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public boolean ready() throws IOException { return br.ready(); } public long nextLong() throws IOException { return Long.parseLong(next()); } } }
Main.java:7: error: class AGC005B is public, should be declared in a file named AGC005B.java public class AGC005B{ ^ 1 error
s581275164
p03987
C++
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5+5, L = 18; int st[N][L], A[N], n, rt; int gt(int x) { for(int i=1;;i++) if((1<<i)>x) return(i-1); } int get(int l, int r){ int d = r-l+1; int g = gt(d); return(min(st[l][g], st[r-(1<<g)+1][g])); } int32_t main(){ scanf("%lld", &n); for(int i=0;i<n;i++) scanf("%lld", &A[i]); for(int j=0;j<L;j++) for(int i=0;i<n;i++) if(i+(1<<j)<=n){ st[i][j] = !j?A[i]:min(st[i][j-1], st[i+(1<<(j-1))][j-1]); } for(int i=0;i<n;i++){ int l = 0, r = i; while(r-l>1){ int mid = ((l+r)>>1); if(get(mid, i)!=A[i]) l = mid; else r = mid; } if(l<i && get(l, i)!=A[i]) l++; if(l && get(l-1, i)==A[i]) l--; int d1 = i-l; l = i, r = n; while(r-l>1){ int mid = ((l+r)>>1); if(get(i, mid)!=A[i]) r = mid; else l = mid; } if(l>i && get(i, l)!=A[i]) l--; if(l^n ** get(i, l+1)==A[i]) l++; int d2 = l-i; rt += A[i] * (d1+1)*(d2+1); } printf("%lld", rt); }
a.cc: In function 'int32_t main()': a.cc:35:17: error: invalid type argument of unary '*' (have 'long long int') 35 | if(l^n ** get(i, l+1)==A[i]) l++; | ^~~~~~~~~~~~~
s776974246
p03987
C++
#include <iostream> #include <set> #include <algorithm> #include <bits/stdc++.h> using namespace std; int main(){ long long i,n,a[200010],b[200010],x,ans=0; set<long long> s; cin >> n; for(i=0;i<n;i++){ cin >> a[i]; b[a[i]] = i; } s.insert(n+1); s.insert(-1); for(i=0;i<n;i++){ x = s.lower_bound(b[i])-s.begin(); ans += i*(b[i]-s[x])*(s[x+1]-b[i]); s.insert(b[i]); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:18:32: error: no match for 'operator-' (operand types are 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} and 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'}) 18 | x = s.lower_bound(b[i])-s.begin(); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ | | | | | _Rb_tree_const_iterator<[...]> | _Rb_tree_const_iterator<[...]> In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:4: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::complex<_Tp>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::complex<_Tp>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::complex<_Tp>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 18 | x = s.lower_bound(b[i])-s.begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:18:41: note: 'std::set<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 18 | x = s.lower_bound(b[i])-s.begin(); |
s472903695
p03987
C++
#include <iostream> #include <fstream> #include <cmath> #include <cstdlib> #include <ctime> #include <algorithm> #include <numeric> #include <functional> #include <string> #include <vector> #include <bitset> #include <map> #include <set> #include <stack> #include <queue> #include <deque> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define REP(i,n) for(int i = 0; i < int(n); i++) #define REREP(i,n) for(int i = int(n - 1); i >= 0; i--) #define FOR(i, m, n) for(int i = int(m);i < int(n);i++) #define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VVI vector<vector<int>> #define VVVI vector<vector<vector<int>>> #define VD vector<double> #define VVD vector<vector<double>> #define VVVD vector<vector<vector<double>>> #define VL vector<ll> #define VVL vector<vector<ll>> #define VVVL vector<vector<vector<ll>>> #define VB vector<bool> #define VVB vector<vector<bool>> #define VVVB vector<vector<vector<bool>>> #define VS vector<string> #define VVS vector<vector<string>> #define VVVS vector<vector<vector<string>>> #define PII pair<int,int> #define PDD pair<double,double> #define PLL pair<ll,ll> #define VPII vector<pair<int,int>> #define VVPII vector<vector<pair<int,int>>> #define VVVPII vector<vector<vector<pair<int,int>>>> #define VPLL vector<pair<ll,ll>> #define VVPLL vector<vector<pair<ll,ll>>> #define VVVPLL vector<vector<vector<pair<ll,ll>>>> #define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0) #define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.) #define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL) #define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5... #define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1... #define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n #define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n const ll HMOD = (ll)1e9 + 7; const ll LMOD = 998244353; const ll HINF = (ll)1e18; const ll LINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; const long double EPS = 1e-10; //integer class Integer { public: ll gcd(ll a, ll b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); while (b != 0) { a = a%b; swap(a, b); } return a; } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return 0; return a / gcd(a, b)*b; } set<ll> divisor(ll N){ set<ll> st; for (ll i = 1; i*i <= N; i++) { if (N%i == 0) { st.insert(i); st.insert(N / i); } } return st; } //a vector that has prime factors of N (this includes only elements, which has no number of each prime factor) vector<ll> prime_factorization(ll N) { vector<ll> v; ll M = N; for (ll i = 2; i*i <= N; i++) { if (M%i == 0) v.push_back(i); while (M%i == 0) M /= i; } if (M != 1) v.push_back(M); return v; } int bitcount(ll N, int K){ int cnt = 0; for (int i = 0; i < K; i++) if (N & (1 << i)) cnt++; return cnt; } ll digitsum(ll N, int K){ ll sum = 0; for (; N > 0; N /= K) sum += N%K; return sum; } }; //geometry class Geometry { public: double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); } bool intersection_judgment(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) { double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax); double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx); double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx); double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx); return tc * td < 0 && ta * tb < 0; } }; //eratosthenes class Eratosthenes{ public: vector<bool> primary(int N) { vector<bool> primary(N + 1, true); primary[0] = false; if (N == 0) return primary; primary[1] = false; for (int i = 1; i*i <= N; i++) if (primary[i]) for (int j = 2 * i; j <= N; j += i) primary[j] = false; return primary; } }; //combination mod class Combination_Mod { public: VL factorial; //N! table void set(ll N, ll quotient){ factorial.resize(N + 1, 1); for (ll i = 1; i <= N; i++) { factorial[i] *= factorial[i - 1] * i; factorial[i] %= quotient; } return; } //repeat square method y = x^n mod quotient ll rsm(ll x, ll n, ll quotient) { ll y = 1; while (n > 0) { if (n & 1) { y *= x; y %= quotient; } x *= x; x %= quotient; n >>= 1; } return y; } //modulus of nCk - combination mod ll nCk(ll n, ll k, ll quotient) { if (n < k || n <= 0 || k <= 0) return 0; ll nCk = (factorial[n] % quotient); nCk *= rsm(factorial[k], quotient - 2, quotient); nCk %= quotient; nCk *= rsm(factorial[n - k], quotient - 2, quotient); return (nCk % quotient); } }; //combination class Combination{ public: VVL nCk; VVD nCkP; void set(int N){ nCk.resize(N + 1); REP(i,N + 1) nCk[i].resize(N + 1,0); nCk[0][0] = 1; for (int n = 1; n <= N; n++) { for (int k = 0; k <= n; k++) { if(k == 0) nCk[n][k] = nCk[n - 1][k]; else nCk[n][k] = nCk[n - 1][k - 1] + nCk[n - 1][k]; } } } void setP(int N) { nCkP.resize(N + 1); REP(i, N + 1) nCkP[i].resize(N + 1, 0.); nCkP[0][0] = 1; for (int n = 1; n <= N; n++) { for (int k = 0; k <= n; k++) { if (k == 0) nCkP[n][k] = nCkP[n - 1][k]/2.; else nCkP[n][k] = (nCkP[n - 1][k - 1] + nCkP[n - 1][k])/2.; } } } }; //union-find class Union_Find { public: VI node; void set(int n){ node.resize(n); REP(i, n) node[i] = i; } int root(int n) { if (node[n] == n) return n; else return node[n] = root(node[n]); } void unite(int n, int m) { if (n > m) swap(n, m); n = root(n); m = root(m); if (n == m) return; else node[m] = n; } }; //dijkstra class Dijkstra{ public: VVPII edge; VVI dist; void set(int N, int inf){ edge.resize(N); dist.resize(N); REP(i, N) dist[i].resize(N); REP(i, N)REP(j, N) dist[i][j] = inf; } void make_edge(int from, int to, int cost) { edge[from].push_back({ to,cost }); } void dijkstra(int start) { priority_queue<PII, vector<PII>, greater<PII>> pq; dist[start][start] = 0; pq.push({ 0,start }); while (!pq.empty()) { int from = pq.top().second; pq.pop(); REP(i, edge[from].size()) { int to = edge[from][i].first; if (dist[start][to] > dist[start][from] + edge[from][i].second) { dist[start][to] = dist[start][from] + edge[from][i].second; pq.push({ dist[start][from] + edge[from][i].second,to }); } } } } }; //bellman ford class Bellman_Ford { public: struct edge{ int from, to, cost; }; int N; VI node; vector<edge> graph; void set(int node_, int inf) { N = node_; node.resize(node_); } void make_edge(int from,int to, int cost){ graph.push_back({from,to,cost}); } void bellman_ford(int start,int inf) { REP(i, N) node[i] = inf; node[start] = 0; REP(i, N - 1) REP(j, graph.size()) if (node[graph[j].to] > node[graph[j].from] + graph[j].cost) node[graph[j].to] = node[graph[j].from] + graph[j].cost; } }; //ford fulkerson class Ford_Fulkerson{ public: struct edge { int to, cap, rev; }; int node, start, goal; vector<vector<edge>> graph; vector<bool> visit; void set(int node_, int start_, int goal_) { node = node_; start = start_; goal = goal_; graph.resize(node); visit.resize(node); } void make_edge(int from, int to, int cap) { graph[from].push_back({ to,cap,(int)graph[to].size() }); graph[to].push_back({ from,0,(int)graph[from].size() - 1 }); } int dfs(int from, int flow) { if (from == goal) return flow; visit[from] = false; REP(i, graph[from].size()) { if (visit[graph[from][i].to] && (graph[from][i].cap > 0)) { int dflow = dfs(graph[from][i].to, min(flow, graph[from][i].cap)); if (dflow > 0) { graph[from][i].cap -= dflow; graph[graph[from][i].to][graph[from][i].rev].cap += dflow; return dflow; } } } return 0; } int maxflow(void) { int maxflow = 0; while (1) { REP(i, graph.size()) visit[i] = true; int flow = dfs(start, 1); if (flow == 0) return maxflow; maxflow += flow; } } }; //longest increasing subsequence class Longest_Increasing_Subsequence{ public: int N; VI dp, ar; void set(int N_){ N = N_; dp.resize(N, LINF); ar.resize(N);// ar has to be set value. } int make(void){ REP(i, N) *lower_bound(ALL(dp), ar[i]) = ar[i]; return distance(dp.begin(), lower_bound(ALL(dp), LINF)); } }; //least common ancestor class Least_Common_Ancestor { public: int node; int MAXLOG2; VVI edge; VI depth; VVI parent; void set(int node_, int MAXLOG2_) { node = node_; MAXLOG2 = MAXLOG2_; edge.resize(node); depth.resize(node); parent.resize(node); REP(i, node) parent[i].resize(MAXLOG2); } void dfs(int root, int root_from) { depth[root] = 0; parent[root][0] = root_from; stack<pair<int, int>> st; st.push({ root,root_from }); while (!st.empty()) { int from = st.top().first; int from_from = st.top().second; st.pop(); REP(i, edge[from].size()) { int to = edge[from][i]; if (to != from_from) { depth[to] = depth[from] + 1; parent[to][0] = from; st.push({ to,from }); } } } return; } //make table void initialize(int N) { REP(k, MAXLOG2 - 1) { REP(i, N) { if (parent[i][k] < 0) parent[i][k + 1] = -1; else parent[i][k + 1] = parent[parent[i][k]][k]; } } return; } //get least common ancestor int get(int a, int b) { if (depth[a] > depth[b]) swap(a, b); REP(k, MAXLOG2 - 1) if (((depth[b] - depth[a]) >> k) & 1) b = parent[b][k]; if (a == b) return a; REREP(k, MAXLOG2) { if (parent[a][k] != parent[b][k]) { a = parent[a][k]; b = parent[b][k]; } } return parent[a][0]; } }; //directed acyclic graph class Directed_Acyclic_Graph{ public: int N; Dijkstra dijkstra; struct edge { int dest, cost; bool need; }; vector<vector<edge>> output; VI input; VI topological_order; void set(int N_, int inf){ N = N_; dijkstra.set(N, inf); output.resize(N); input.resize(N,0); } void make_edge(int from, int to, int cost){ dijkstra.make_edge(from, to, cost); output[from].push_back({to, cost, true}); } void make_dag(int start) { dijkstra.dijkstra(start); REP(i, N) { REP(j, output[i].size()) { int from = i; edge &e = output[i][j]; if (dijkstra.dist[start][e.dest] - dijkstra.dist[start][from] != e.cost) e.need = false; } } } bool topological_sort(int start){ REP(i, N) REP(j, output[i].size()) if (output[i][j].need) input[output[i][j].dest]++; stack<int> st; st.push(start); while(!st.empty()){ int from = st.top(); st.pop(); topological_order.push_back(from); REP(i, output[from].size()) { edge &e = output[from][i]; if (e.need) { input[e.dest]--; if (input[e.dest] == 0) st.push(e.dest); } } } bool valid = true; REP(i, N) if (input[i] > 0) valid = false; return valid; } }; //binary indexed tree class Binary_Indexed_Tree { public: int N; ll ini; vector<ll> bit; void set(int N_, ll ini_) { N = N_; ini = ini_; bit.resize(N + 1); for (int i = 0; i <= N; i++) bit[i] = ini; } //sum void add(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] += w; } ll sum(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret += bit[j]; return ret; } //max void inc(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] = (bit[j]>w)?bit[j]:w; } ll max(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret = (ret>bit[j])?ret:bit[j]; return ret; } //min void dec(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] = (bit[j]<w) ? bit[j] : w; } ll min(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret = (ret<bit[j]) ? ret : bit[j]; return ret; } }; void YN(bool flag){ cout << ((flag) ? "YES" : "NO") << endl; } void Yn(bool flag) { cout << ((flag) ? "Yes" : "No") << endl; } void yn(bool flag) { cout << ((flag) ? "yes" : "no") << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) ll N; cin >> N; VL a(N + 1); REP(i, N) { ll aa; cin >> aa; a[aa] = i + 1; } ll sum = 0; set<ll> st = { 0,N + 1 }; FOR(i,1,N + 1){ auto itr = lower_bound(st.begin(), st.end(), a[i]); ll r = *itr - a[i]; itr--; ll l = -*itr + a[i]; sum += r*l*i; st.insert(a[i]); } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:573:61: error: expected ';' before 'll' 573 | ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) | ^ | ; 574 | 575 | ll N; cin >> N; | ~~ a.cc:575:22: error: 'N' was not declared in this scope; did you mean 'YN'? 575 | ll N; cin >> N; | ^ | YN a.cc:584:32: error: could not convert '{0, <expression error>}' from '<brace-enclosed initializer list>' to 'std::set<long long int>' 584 | set<ll> st = { 0,N + 1 }; | ^ | | | <brace-enclosed initializer list>
s703557988
p03987
C++
#include <iostream> #include <fstream> #include <cmath> #include <cstdlib> #include <ctime> #include <algorithm> #include <numeric> #include <functional> #include <string> #include <vector> #include <bitset> #include <map> #include <set> #include <stack> #include <queue> #include <deque> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define REP(i,n) for(int i = 0; i < int(n); i++) #define REREP(i,n) for(int i = int(n - 1); i >= 0; i--) #define FOR(i, m, n) for(int i = int(m);i < int(n);i++) #define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VVI vector<vector<int>> #define VVVI vector<vector<vector<int>>> #define VD vector<double> #define VVD vector<vector<double>> #define VVVD vector<vector<vector<double>>> #define VL vector<ll> #define VVL vector<vector<ll>> #define VVVL vector<vector<vector<ll>>> #define VB vector<bool> #define VVB vector<vector<bool>> #define VVVB vector<vector<vector<bool>>> #define VS vector<string> #define VVS vector<vector<string>> #define VVVS vector<vector<vector<string>>> #define PII pair<int,int> #define PDD pair<double,double> #define PLL pair<ll,ll> #define VPII vector<pair<int,int>> #define VVPII vector<vector<pair<int,int>>> #define VVVPII vector<vector<vector<pair<int,int>>>> #define VPLL vector<pair<ll,ll>> #define VVPLL vector<vector<pair<ll,ll>>> #define VVVPLL vector<vector<vector<pair<ll,ll>>>> #define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0) #define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.) #define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL) #define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5... #define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1... #define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n #define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n const ll HMOD = (ll)1e9 + 7; const ll LMOD = 998244353; const ll HINF = (ll)1e18; const ll LINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; const long double EPS = 1e-10; //integer class Integer { public: ll gcd(ll a, ll b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); while (b != 0) { a = a%b; swap(a, b); } return a; } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return 0; return a / gcd(a, b)*b; } set<ll> divisor(ll N){ set<ll> st; for (ll i = 1; i*i <= N; i++) { if (N%i == 0) { st.insert(i); st.insert(N / i); } } return st; } //a vector that has prime factors of N (this includes only elements, which has no number of each prime factor) vector<ll> prime_factorization(ll N) { vector<ll> v; ll M = N; for (ll i = 2; i*i <= N; i++) { if (M%i == 0) v.push_back(i); while (M%i == 0) M /= i; } if (M != 1) v.push_back(M); return v; } int bitcount(ll N, int K){ int cnt = 0; for (int i = 0; i < K; i++) if (N & (1 << i)) cnt++; return cnt; } ll digitsum(ll N, int K){ ll sum = 0; for (; N > 0; N /= K) sum += N%K; return sum; } }; //geometry class Geometry { public: double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); } bool intersection_judgment(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) { double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax); double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx); double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx); double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx); return tc * td < 0 && ta * tb < 0; } }; //eratosthenes class Eratosthenes{ public: vector<bool> primary(int N) { vector<bool> primary(N + 1, true); primary[0] = false; if (N == 0) return primary; primary[1] = false; for (int i = 1; i*i <= N; i++) if (primary[i]) for (int j = 2 * i; j <= N; j += i) primary[j] = false; return primary; } }; //combination mod class Combination_Mod { public: VL factorial; //N! table void set(ll N, ll quotient){ factorial.resize(N + 1, 1); for (ll i = 1; i <= N; i++) { factorial[i] *= factorial[i - 1] * i; factorial[i] %= quotient; } return; } //repeat square method y = x^n mod quotient ll rsm(ll x, ll n, ll quotient) { ll y = 1; while (n > 0) { if (n & 1) { y *= x; y %= quotient; } x *= x; x %= quotient; n >>= 1; } return y; } //modulus of nCk - combination mod ll nCk(ll n, ll k, ll quotient) { if (n < k || n <= 0 || k <= 0) return 0; ll nCk = (factorial[n] % quotient); nCk *= rsm(factorial[k], quotient - 2, quotient); nCk %= quotient; nCk *= rsm(factorial[n - k], quotient - 2, quotient); return (nCk % quotient); } }; //combination class Combination{ public: VVL nCk; VVD nCkP; void set(int N){ nCk.resize(N + 1); REP(i,N + 1) nCk[i].resize(N + 1,0); nCk[0][0] = 1; for (int n = 1; n <= N; n++) { for (int k = 0; k <= n; k++) { if(k == 0) nCk[n][k] = nCk[n - 1][k]; else nCk[n][k] = nCk[n - 1][k - 1] + nCk[n - 1][k]; } } } void setP(int N) { nCkP.resize(N + 1); REP(i, N + 1) nCkP[i].resize(N + 1, 0.); nCkP[0][0] = 1; for (int n = 1; n <= N; n++) { for (int k = 0; k <= n; k++) { if (k == 0) nCkP[n][k] = nCkP[n - 1][k]/2.; else nCkP[n][k] = (nCkP[n - 1][k - 1] + nCkP[n - 1][k])/2.; } } } }; //union-find class Union_Find { public: VI node; void set(int n){ node.resize(n); REP(i, n) node[i] = i; } int root(int n) { if (node[n] == n) return n; else return node[n] = root(node[n]); } void unite(int n, int m) { if (n > m) swap(n, m); n = root(n); m = root(m); if (n == m) return; else node[m] = n; } }; //dijkstra class Dijkstra{ public: VVPII edge; VVI dist; void set(int N, int inf){ edge.resize(N); dist.resize(N); REP(i, N) dist[i].resize(N); REP(i, N)REP(j, N) dist[i][j] = inf; } void make_edge(int from, int to, int cost) { edge[from].push_back({ to,cost }); } void dijkstra(int start) { priority_queue<PII, vector<PII>, greater<PII>> pq; dist[start][start] = 0; pq.push({ 0,start }); while (!pq.empty()) { int from = pq.top().second; pq.pop(); REP(i, edge[from].size()) { int to = edge[from][i].first; if (dist[start][to] > dist[start][from] + edge[from][i].second) { dist[start][to] = dist[start][from] + edge[from][i].second; pq.push({ dist[start][from] + edge[from][i].second,to }); } } } } }; //bellman ford class Bellman_Ford { public: struct edge{ int from, to, cost; }; int N; VI node; vector<edge> graph; void set(int node_, int inf) { N = node_; node.resize(node_); } void make_edge(int from,int to, int cost){ graph.push_back({from,to,cost}); } void bellman_ford(int start,int inf) { REP(i, N) node[i] = inf; node[start] = 0; REP(i, N - 1) REP(j, graph.size()) if (node[graph[j].to] > node[graph[j].from] + graph[j].cost) node[graph[j].to] = node[graph[j].from] + graph[j].cost; } }; //ford fulkerson class Ford_Fulkerson{ public: struct edge { int to, cap, rev; }; int node, start, goal; vector<vector<edge>> graph; vector<bool> visit; void set(int node_, int start_, int goal_) { node = node_; start = start_; goal = goal_; graph.resize(node); visit.resize(node); } void make_edge(int from, int to, int cap) { graph[from].push_back({ to,cap,(int)graph[to].size() }); graph[to].push_back({ from,0,(int)graph[from].size() - 1 }); } int dfs(int from, int flow) { if (from == goal) return flow; visit[from] = false; REP(i, graph[from].size()) { if (visit[graph[from][i].to] && (graph[from][i].cap > 0)) { int dflow = dfs(graph[from][i].to, min(flow, graph[from][i].cap)); if (dflow > 0) { graph[from][i].cap -= dflow; graph[graph[from][i].to][graph[from][i].rev].cap += dflow; return dflow; } } } return 0; } int maxflow(void) { int maxflow = 0; while (1) { REP(i, graph.size()) visit[i] = true; int flow = dfs(start, 1); if (flow == 0) return maxflow; maxflow += flow; } } }; //longest increasing subsequence class Longest_Increasing_Subsequence{ public: int N; VI dp, ar; void set(int N_){ N = N_; dp.resize(N, LINF); ar.resize(N);// ar has to be set value. } int make(void){ REP(i, N) *lower_bound(ALL(dp), ar[i]) = ar[i]; return distance(dp.begin(), lower_bound(ALL(dp), LINF)); } }; //least common ancestor class Least_Common_Ancestor { public: int node; int MAXLOG2; VVI edge; VI depth; VVI parent; void set(int node_, int MAXLOG2_) { node = node_; MAXLOG2 = MAXLOG2_; edge.resize(node); depth.resize(node); parent.resize(node); REP(i, node) parent[i].resize(MAXLOG2); } void dfs(int root, int root_from) { depth[root] = 0; parent[root][0] = root_from; stack<pair<int, int>> st; st.push({ root,root_from }); while (!st.empty()) { int from = st.top().first; int from_from = st.top().second; st.pop(); REP(i, edge[from].size()) { int to = edge[from][i]; if (to != from_from) { depth[to] = depth[from] + 1; parent[to][0] = from; st.push({ to,from }); } } } return; } //make table void initialize(int N) { REP(k, MAXLOG2 - 1) { REP(i, N) { if (parent[i][k] < 0) parent[i][k + 1] = -1; else parent[i][k + 1] = parent[parent[i][k]][k]; } } return; } //get least common ancestor int get(int a, int b) { if (depth[a] > depth[b]) swap(a, b); REP(k, MAXLOG2 - 1) if (((depth[b] - depth[a]) >> k) & 1) b = parent[b][k]; if (a == b) return a; REREP(k, MAXLOG2) { if (parent[a][k] != parent[b][k]) { a = parent[a][k]; b = parent[b][k]; } } return parent[a][0]; } }; //directed acyclic graph class Directed_Acyclic_Graph{ public: int N; Dijkstra dijkstra; struct edge { int dest, cost; bool need; }; vector<vector<edge>> output; VI input; VI topological_order; void set(int N_, int inf){ N = N_; dijkstra.set(N, inf); output.resize(N); input.resize(N,0); } void make_edge(int from, int to, int cost){ dijkstra.make_edge(from, to, cost); output[from].push_back({to, cost, true}); } void make_dag(int start) { dijkstra.dijkstra(start); REP(i, N) { REP(j, output[i].size()) { int from = i; edge &e = output[i][j]; if (dijkstra.dist[start][e.dest] - dijkstra.dist[start][from] != e.cost) e.need = false; } } } bool topological_sort(int start){ REP(i, N) REP(j, output[i].size()) if (output[i][j].need) input[output[i][j].dest]++; stack<int> st; st.push(start); while(!st.empty()){ int from = st.top(); st.pop(); topological_order.push_back(from); REP(i, output[from].size()) { edge &e = output[from][i]; if (e.need) { input[e.dest]--; if (input[e.dest] == 0) st.push(e.dest); } } } bool valid = true; REP(i, N) if (input[i] > 0) valid = false; return valid; } }; //binary indexed tree class Binary_Indexed_Tree { public: int N; ll ini; vector<ll> bit; void set(int N_, ll ini_) { N = N_; ini = ini_; bit.resize(N + 1); for (int i = 0; i <= N; i++) bit[i] = ini; } //sum void add(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] += w; } ll sum(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret += bit[j]; return ret; } //max void inc(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] = (bit[j]>w)?bit[j]:w; } ll max(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret = (ret>bit[j])?ret:bit[j]; return ret; } //min void dec(int i, ll w) { for (int j = i; j <= N; j += j & -j) bit[j] = (bit[j]<w) ? bit[j] : w; } ll min(int i) { ll ret = ini; for (int j = i; j >= 1; j -= j & -j) ret = (ret<bit[j]) ? ret : bit[j]; return ret; } }; void YN(bool flag){ cout << ((flag) ? "YES" : "NO") << endl; } void Yn(bool flag) { cout << ((flag) ? "Yes" : "No") << endl; } void yn(bool flag) { cout << ((flag) ? "yes" : "no") << endl; } int main() { ll N; scanf_s("%d",&N); VL a(N + 1); REP(i, N) { ll aa; scanf_s("%d", &aa); a[aa] = i + 1; } ll sum = 0; set<ll> st = { 0,N + 1 }; FOR(i,1,N + 1){ auto itr = lower_bound(st.begin(), st.end(), a[i]); ll r = *itr - a[i]; itr--; ll l = -*itr + a[i]; sum += r*l*i; st.insert(a[i]); } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:573:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 573 | ll N; scanf_s("%d",&N); | ^~~~~~~ | scanf
s653906562
p03987
C++
#include<iostream> #include <cstdio> #include <vector> #include <algorithm> #include <cstring> using namespace std; #ifdef NO_UNLOCK_IO #define getchar_unlocked getchar #define putchar_unlocked putchar #endif struct FastIO { static const size_t BUFFER_SIZE = 1 << 17; static char inbuf[BUFFER_SIZE | 1], *inptr; static char outbuf[BUFFER_SIZE | 1], *outptr, *endbuf; template <class Integral> static void scan(Integral &x) { bool read = false; x = 0; for (;;) { char tmp = *inptr++; if (tmp == '\0') { size_t len = fread(inbuf, 1, BUFFER_SIZE, stdin); inbuf[len] = '\0'; inptr = inbuf; tmp = *inptr++; } if (tmp >= '0' && tmp <= '9') { read = true; x = x * 10 + tmp - '0'; } else if (read) { ++tmp; break; } } } template <class Arithmetic, class... Rest> static void scan(Arithmetic &x, Rest&... y) { scan(x); scan(y...); } static void print(const char *s, bool flush = false) { size_t count = strlen(s); char *tmp = outptr + count; if (flush || tmp >= endbuf) { fwrite(outbuf, 1, outptr - outbuf, stdout); tmp = outbuf + count; outptr = outbuf; } memcpy(outptr, s, count); outptr = tmp; } static void flush() { fwrite(outbuf, 1, outptr - outbuf, stdout); outptr = outbuf; } }; char FastIO::inbuf[], *FastIO::inptr = FastIO::inbuf; char FastIO::outbuf[], *FastIO::outptr = FastIO::outbuf; char *FastIO::endbuf = outbuf + FastIO::BUFFER_SIZE; int tree[1 << 17]; class UnionFindTree { public: UnionFindTree() { memset(tree, 0xFF, sizeof tree); } size_t find_root(size_t v) { return (tree[v] < 0) ? v : (tree[v] = find_root(tree[v])); } bool unite(size_t x, size_t y) { x = find_root(x); y = find_root(y); if (x == y) return false; if (tree[x] > tree[y]) std::swap(x, y); tree[x] += tree[y]; tree[y] = x; return true; } bool connected(size_t x, size_t y) { return find_root(x) == find_root(y); } size_t rank(size_t v) { return -tree[find_root(v)]; } }; int main() { int N; vector<int> a(N); UnionFindTree uni; for (size_t i = 0; i < N; i++) { int tmp; cin >> tmp; a[i] = tmp; } vector<int>where(N + 1); for (size_t i = 0; i < N; i++) { where[a[i]] = i; } bool usedIndex[300000]; long sum = 0; for (size_t i = N; i > 0; i--) { int index = where[i];//indexは0から long res = i; if (index - 1 >= 0 && usedIndex[index - 1]) { res *= (long)uni.size(A[index - 1]) + 1; uni.unite(A[index], A[index - 1]); } if (index + 1 < N && usedIndex[index + 1]) { res *= (long)uni.size(A[index + 1]) + 1; uni.unite(A[index], A[index + 1]); } usedIndex[index] = true; sum += res; } cout << sum<<endl; return 0; }
a.cc: In function 'int main()': a.cc:119:42: error: 'class UnionFindTree' has no member named 'size' 119 | res *= (long)uni.size(A[index - 1]) + 1; | ^~~~ a.cc:119:47: error: 'A' was not declared in this scope 119 | res *= (long)uni.size(A[index - 1]) + 1; | ^ a.cc:123:42: error: 'class UnionFindTree' has no member named 'size' 123 | res *= (long)uni.size(A[index + 1]) + 1; | ^~~~ a.cc:123:47: error: 'A' was not declared in this scope 123 | res *= (long)uni.size(A[index + 1]) + 1; | ^
s261096134
p03987
Java
import javafx.scene.layout.Priority; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class Main { static int N; static int[] A; static int[] X; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); A = new int[N]; X = new int[N+1]; X[0] = -1; for (int i = 0; i < N; i++) { A[i] = sc.nextInt(); X[A[i]] = i; } System.out.println( solve() ); } private static long solve() { List<Integer> indice = new ArrayList<>(); long sum = 0; for (int a = 1; a <= N; a++) { int ai = X[a]; add(indice, ai); int ii = indice.indexOf(ai); int l; if( ii == 0 ) { l = ai + 1; } else { int lai = indice.get(ii-1); l = ai - lai; } int r; if( ii == indice.size()-1) { r = N - ai; } else { int rai = indice.get(ii+1); r = rai - ai; } sum += (long)a * l * r; } return sum; } static void add(List<Integer> indice, int i) { int low = 0; int high = indice.size(); while( low < high ) { int mid = (low + high) / 2; if( indice.get(mid) < i ) { low = mid + 1; } else { high = mid; } } indice.add(low, i); } static class FastScanner { private BufferedReader reader; private StringTokenizer tokenizer; FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } long nextLong() { return Long.parseLong(next()); } int nextInt() { return Integer.parseInt(next()); } double nextDouble() { return Double.parseDouble(next()); } int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } } }
Main.java:1: error: package javafx.scene.layout does not exist import javafx.scene.layout.Priority; ^ 1 error
s983292370
p03987
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a;i<b;i++) #define rep(i,b) FOR(i,0,b) #define INF mugen #define dump(x) cerr<<#x<<"="<<x<<endl #define all(a) (a).begin(),(a).end() typedef vector<int> vi; typedef vector<vi> vii; typedef vector<vii> viii; typedef pair<int,int> P; template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; } inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } using ll = long long; const ll mod = LLONG_MAX; #define int long long int a[212345]; signed main(){ int n; cin>>n; rep(i,n){ cin>>a[i]; pos[a[i]]=i; } set<int> s; s.insert(-1); s.insert(N); int ans=0; for(int i=1;i<=N;i++){ s.insert(pos[i]); auto it = s.find(pos[i]); --it; int left = *it; ++it; ++it; int right = *it; ans+=i*(pos[i]-left)*(right-pos[i]); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:24:5: error: 'pos' was not declared in this scope; did you mean 'pow'? 24 | pos[a[i]]=i; | ^~~ | pow a.cc:28:12: error: 'N' was not declared in this scope 28 | s.insert(N); | ^ a.cc:32:14: error: 'pos' was not declared in this scope; did you mean 'pow'? 32 | s.insert(pos[i]); | ^~~ | pow
s539832368
p03987
C++
#include <bits/stdc++.h> using namespace std; int n, w[201000], p[201000]; set<int>Set; long long res; int main(){ int i, a ,b; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&w[i]); p[w[i]] = i; } Set.insert(0); Set.insert(n+1); for(i=1;i<=n;i++){ set<int>::iterator it; it = Set.lower_bound(p[i]); b = *it; it--; a = *it; res += 1ll * (p[i]-a)*(b-p[i])*i; Set.insert(p[i]); } printf("%lld\n",res); } #include<stdio.h> #include<algorithm> #include<set> using namespace std; int n, w[201000], p[201000]; set<int>Set; long long res; int main(){ int i, a ,b; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&w[i]); p[w[i]] = i; } Set.insert(0); Set.insert(n+1); for(i=1;i<=n;i++){ set<int>::iterator it; it = Set.lower_bound(p[i]); b = *it; it--; a = *it; res += 1ll * (p[i]-a)*(b-p[i])*i; Set.insert(p[i]); } printf("%lld\n",res); }
a.cc:31:5: error: redefinition of 'int n' 31 | int n, w[201000], p[201000]; | ^ a.cc:4:5: note: 'int n' previously declared here 4 | int n, w[201000], p[201000]; | ^ a.cc:31:8: error: redefinition of 'int w [201000]' 31 | int n, w[201000], p[201000]; | ^ a.cc:4:8: note: 'int w [201000]' previously declared here 4 | int n, w[201000], p[201000]; | ^ a.cc:31:19: error: redefinition of 'int p [201000]' 31 | int n, w[201000], p[201000]; | ^ a.cc:4:19: note: 'int p [201000]' previously declared here 4 | int n, w[201000], p[201000]; | ^ a.cc:32:9: error: redefinition of 'std::set<int> Set' 32 | set<int>Set; | ^~~ a.cc:5:9: note: 'std::set<int> Set' previously declared here 5 | set<int>Set; | ^~~ a.cc:33:11: error: redefinition of 'long long int res' 33 | long long res; | ^~~ a.cc:6:11: note: 'long long int res' previously declared here 6 | long long res; | ^~~ a.cc:34:5: error: redefinition of 'int main()' 34 | int main(){ | ^~~~ a.cc:7:5: note: 'int main()' previously defined here 7 | int main(){ | ^~~~
s523935667
p03987
C++
#include<stdio.h> #include<string.h> #include<algorithm> #include<iostream> #include<math.h> #include<queue> #define mem(a,b) memset(a,b,sizeof(a)) #define mod 20123 #define inf 123456789 #define LL long long #define big 1e18 using namespace std; int max(int a,int b){ return a>b?a:b;} int maxn (int a,int b,int c){return max(max(a,b),max(b,c));} LL min(LL a,LL b){return a<b?a:b;} LL minn,a[200005],pre[200005],sum1=0; LL dfs(LL l,LL r) { if(r==l){ minn=min(a[l],min(minn,a[r])); sum1+=minn; return ; } else { LL mid=(r+l)/2; dfs(mid+1,r); dfs(l,mid); } } int main() { LL n,i,j; scanf("%lld",&n); for(i=1;i<=n;i++) scanf("%lld",&a[i]); for(i=n;i>0;i--) { minn=big; sum1=0; dfs(1,i); pre[i]=sum1; } LL sum=0; for(i=1;i<=n;i++) sum+=pre[i]; printf("%lld\n",sum); return 0; }
a.cc: In function 'long long int dfs(long long int, long long int)': a.cc:22:9: error: return-statement with no value, in function returning 'long long int' [-fpermissive] 22 | return ; | ^~~~~~ a.cc:27:12: warning: control reaches end of non-void function [-Wreturn-type] 27 | dfs(l,mid); | ~~~^~~~~~~
s815931145
p03987
C++
#include<bits/stdc++.h> using namespace std; #define inf 1e9 #define ll long long #define M 1000000007 #define P pair<int,int> #define FOR(i,m,n) for(int i=m;i<n;i++) #define rep(i,n) FOR(i,0,n) const int vx[4] = {0,1,0,-1}; const int vy[4] = {1,0,-1,0}; #define PI 3.14159265 int n; ll b[210000]; set<int> s; ll ans; int main(){ cin>>n; rep(i,n){ int a; cin>>a; b[a]=i; } s.insert(0); s.insert(n+1); for(ll i=1;i<=n;i++){ auto it = s.upper_bound(b[i]); ans+=i*(*it-b[i])*(b[i]-*(it-1)); s.insert(b[i]); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:30:33: error: no match for 'operator-' (operand types are 'std::_Rb_tree_const_iterator<int>' and 'int') 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ~~^~ | | | | | int | std::_Rb_tree_const_iterator<int> In file included from /usr/include/c++/14/bits/stl_algobase.h:67, 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.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::move_iterator<_IteratorL>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::complex<_Tp>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::complex<_Tp>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:30:34: note: mismatched types 'const std::complex<_Tp>' and 'int' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:34: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:34: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::valarray<_Tp>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:30:34: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::valarray<_Tp>' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:30:34: note: mismatched types 'const std::valarray<_Tp>' and 'int' 30 | ans+=i*(*it-b[i])*(b[i]-*(it-1)); | ^
s513661038
p03987
C++
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <cmath> #include <stack> #include <string> #include <fstream> #define FOR(i,a,b) for(int i=a;i<b;i++) #define ROF(i,a,b) for(int i=b-1;i>=a;i--) #define FI first #define SE second #define VE vector<int> #define PB push_back #define LL long long #define YES(i) cout<<(i?"YES":"NO")<<endl #define Yes(i) cout<<(i?"Yes":"No")<<endl using namespace std; // const int INF=1e9+7; const int MOD=1e9+7; // int N; int A[200000]; int L[200000]; int R[200000]; int main(){ cin>>N; FOR(i,0,N){ cin>>A[i]; } VE V; FOR(i,0,N){ while(!V.empty()&&A[V.back()]>A[i]){ V.pop_back(); } if(V.empty()){ L[i]=0; }else{ L[i]=V.back()+1; } V.PB(i); } V.clear(); ROF(i,0,N){ while(!V.empty()&&A[V.back()]>A[i]){ V.pop_back(); } if(V.empty()){ R[i]=N-1; }else{ R[i]=V.back()-1; } V.PB(i); } LL ans=0; FOR(i,0,N){ ans+=(ll)A[i]*(i-L[i]+1)*(R[i]-i+1); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:59:11: error: 'll' was not declared in this scope; did you mean 'LL'? 59 | ans+=(ll)A[i]*(i-L[i]+1)*(R[i]-i+1); | ^~ | LL
s886176337
p03987
C++
#include <iostream> #include <algorithm> #include <string> #include <queue> #include <vector> #include <set> #include <bitset> #include <stack> #include <cmath> #define FOR(i,a,b) for(int i=a;i<b;i++) #define ROF(i,a,b) for(int i=b-1;i>=a;i--) #define FI first #define SE second #define MA(i,j) make_pair(i,j) #define PA pair<int,int> #define PB push_back #define PQ priority_queue<int> #define PGQ priority_queue<int,vector<int>,greater<int> > #define VE vector<int> #define VP vector<PA> #define YES(i) cout<<(i?"YES":"NO")<<endl #define Yes(i) cout<<(i?"Yes":"No")<<endl #define MOD 1000000007 #define INF 1000000007 #define PI 3.141592653589793238462643383279 using namespace std; // const int MAX_N=1<<17; // int N,DAT[2*MAX_N-1]; // void init(int N_){ N=1; while(N<N_){ N*=2; } FOR(i,0,2*N-1){ DAT[i]=INT_MAX; } } // void update(int K,int A){ K+=N-1; DAT[K]=A; while(K>0){ K=(K-1)/2; DAT[K]=min(DAT[K*2+1],DAT[K*2+2]); } } // int query(int A,int B,int K,int L,int R){ if(R<=A||B<=L){ return INT_MAX; }else if(A<=L&&R<=B){ return DAT[K]; }else{ int VL=query(A,B,K*2+1,L,(L+R)/2); int VR=query(A,B,K*2+2,(L+R)/2,R); return min(VL,VR); } } int main(){ int M,P; cin>>M; N=M; init(N); FOR(i,0,M){ cin>>P; update(i,P); } int sum=0; FOR(i,1,M+1){ FOR(j,0,M-i+1){ sum+=query(j,j+i,0,0,N); } } cout<<sum<<endl; return 0; }
a.cc: In function 'void init(int)': a.cc:38:12: error: 'INT_MAX' was not declared in this scope 38 | DAT[i]=INT_MAX; | ^~~~~~~ a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 9 | #include <cmath> +++ |+#include <climits> 10 | #define FOR(i,a,b) for(int i=a;i<b;i++) a.cc: In function 'int query(int, int, int, int, int)': a.cc:53:12: error: 'INT_MAX' was not declared in this scope 53 | return INT_MAX; | ^~~~~~~ a.cc:53:12: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s628410558
p03987
C++
#include <iostream> #include <set> #include <vector> using namespace std; int main(){ long sum = 0; int n; set<int> data; cin >> n; int a[n + 1]; int pos[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; pos[a[i]] = i; } data.insert(0); data.insert(n + 1); for (int i = 1; i <= n; i++) { int l, r; data.insert(pos[i]); set<int>::iterator it = data.find(pos[i]); r = *(it++) - pos[i]; it--; l = pos[i] - *(it--); sum += long i * r * l; } cout << sum; }
a.cc: In function 'int main()': a.cc:31:16: error: expected primary-expression before 'long' 31 | sum += long i * r * l; | ^~~~
s734693480
p03987
C++
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define INF 1e9+7 #define pf2 pop_front #define pb2 pop_back #define pb push_back #define pf push_front #define fi first #define se second #define sz size #define eps 1e-7 #define fod find_by_order #define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); #define ofk order_of_key #define val(x) cout << "Value dari "<< #x << " adalah " << x << "\n" #define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> typedef long long ll; using namespace __gnu_pbds; using namespace std; int dx[8] = {1,0,-1,0,1,1,-1,-1}; int dy[8] = {0,1,0,-1,1,-1,1,-1}; void readf(string x){ freopen((x+".in").c_str(),"r",stdin); freopen((x+".out").c_str(),"w",stdout); } void pr(string x){ freopen((x+".in").c_str(),"w",stdout); } int read() { bool min = 0; int result = 0; char ch; ch = getchar(); while(1) { if(ch == '-') break; if(ch >='0' && ch <= '9') break; ch = getchar(); } if(ch == '-') min = 1;else result = ch-'0'; while(1) { ch =getchar(); if(ch< '0' || ch>'9') break; result = result * 10 + (ch-'0'); } if(min) return -result; return result; } //Reynaldo's Template int main(){ ll N; cin >> N; ll x[N+5],pref[N+5]; vector<pair<int,int> > v; for(int i=1;i<=N;i++) { cin >> x[i]; v.pb({x[i],i}); } memset(pref,0,sizeof pref); sort(v.begin(),v.end()); set<int> st; st.insert(N+1); st.insert(0); ll sum = 0; for(int i=0;i<v.size();i++){ ll r = v[i].fi,t = v[i].se; set<int>::iterator it = st.upper_bound(t); ll val = *it; it--; int gg = (*it); sum l+= r * (t - gg) * (val - t); st.insert(t); } cout << sum << "\n"; }
a.cc: In function 'int main()': a.cc:81:20: error: expected ';' before 'l' 81 | sum l+= r * (t - gg) * (val - t); | ^~ | ;
s154468493
p03987
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int N; ll ans; ll a[200001]; int main() { cin >> N; for(int i = 0; i < N; i++) cin >> a[i]; for(int i = 0; i < N; i++) { ll m = a[i]; ans += m; for(int j = i+1; j < N; j++) { if(m > a[j]) { m = a[j]; ans += m;h } else ans += m; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:19:18: error: 'h' was not declared in this scope 19 | ans += m;h | ^
s288181763
p03987
C++
#include<string> #include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<functional> using namespace std; typedef long long int llint; #define pub push_back #define mp make_pair #define fir first #define sec second #define res resize const int big=((llint)1<<30); int main(void){ int q,n,i,gen=0; llint ans=0;vector<int> let;vector<int> doc;set<int> used; scanf("%d",&n);let.resize(n);doc.resize(n+1); for(i=0;i<n;i++){ scanf("%d",&q);doc[q]=i; } used.insert(-1);used.insert(n); for(i=1;i<=n;i++){ ans+=(doc[i]-*(--used.lower_bound(doc[i])))*(*(used.lower_bound(doc[i]))-doc[i])*i; used.insert(doc[i]); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:19:53: error: 'set' was not declared in this scope 19 | llint ans=0;vector<int> let;vector<int> doc;set<int> used; | ^~~ a.cc:7:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>' 6 | #include<functional> +++ |+#include <set> 7 | using namespace std; a.cc:19:57: error: expected primary-expression before 'int' 19 | llint ans=0;vector<int> let;vector<int> doc;set<int> used; | ^~~ a.cc:22:9: error: 'used' was not declared in this scope 22 | used.insert(-1);used.insert(n); | ^~~~
s142038242
p03987
C++
#include <iostream> #include <vector> using namespace std; typedef long long ll; struct para { int m, M; }; vector<para> T; int l, size; void Stworz(int n) { int p = 1; while (p < n) p *= 2; l = p; size = 2 * p - 1; for (int i = 0; i <= size; ++i) T.push_back({1e9, -1e9}); } void Dodaj(int a, int x) { a += l; T[a] = {x, x}; a /= 2; while (a != 0) { T[a].m = min(T[2 * a].m, T[2 * a + 1].m); T[a].M = max(T[2 * a].M, T[2 * a + 1].M); a /= 2; } } int Min(int a, int b) { if (a > b) return 1e9; a += l; b += l; int odp = min(T[a].m, T[b].m); while (a / 2 != b / 2) { if (a % 2 == 0) odp = min(odp, T[a + 1].m); if (b % 2 == 1) odp = min(odp, T[b - 1].m); a /= 2; b /= 2; } return odp; } int Max(int a, int b) { if (a > b) return -1e9; a += l; b += l; int odp = max(T[a].M, T[b].M); while (a / 2 != b / 2) { if (a % 2 == 0) odp = max(odp, T[a + 1].M); if (b % 2 == 1) odp = max(odp, T[b - 1].M); a /= 2; b /= 2; } return odp; } int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; --a[i]; } Stworz(n); vector<int> L(n); for (int i = 0; i < n; ++i) { L[i] = Max(0, a[i] - 1); if (L[i] == -1e9) L[i] = 0; else ++L[i]; Dodaj(a[i], i); } T.clear(); Stworz(n); vector<int> P(n); for (int i = n - 1; i >= 0; --i) { P[i] = Min(0, a[i] - 1); if (P[i] == 1e9) P[i] = n - 1; else --P[i]; Dodaj(a[i], i); } ll odp = 0; for (int i = 0; i < n; ++i) { ll l = i - L[i] + 1; ll p = P[i] - i + 1; odp += l * p * (a[i] + 1); } cout << odp; return 0; }
a.cc: In function 'void Stworz(int)': a.cc:22:5: error: reference to 'size' is ambiguous 22 | size = 2 * p - 1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:14:8: note: 'int size' 14 | int l, size; | ^~~~ a.cc:23:26: error: reference to 'size' is ambiguous 23 | for (int i = 0; i <= size; ++i) | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:14:8: note: 'int size' 14 | int l, size; | ^~~~ a.cc:24:22: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing] 24 | T.push_back({1e9, -1e9}); | ^~~
s861462098
p03987
C++
file:///home/nikita/for-practice/minsum.c
a.cc:1:1: error: 'file' does not name a type 1 | file:///home/nikita/for-practice/minsum.c | ^~~~
s582250931
p03987
C++
#include <string.h> #include <string> #include <vector> #include <deque> #include <list> #include <stack> #include <queue> #include <map> #include <set> #include <iterator> #include <functional> #include <algorithm> #include <numeric> #include <iostream> #include <sstream> #include <iomanip> #include <cmath> #include <cstdlib> #include <cstdio> using namespace std; #define sz(a) int((a).size()) #define all(a) a.begin(), a.end() #define pb push_back #define mp make_pair #define CLR(a) memset((a), 0, sizeof(a)) #define INF (1 << 31) - 1 const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1}; const int dw[8] = {0, 0, 1, -1,1,-1,1,-1}; typedef long long ll; typedef pair<int, int> p; typedef vector <int> VI; typedef vector <string> VS; int main(){ int n; cin >> n; VI vec(n+1); for(int i = 1; i <= n; i++){ int num; cin >> num; vec[num] = i; } ll ans = 0; vector <int> oldh; vector <int> oldw; oldh.pb(0); oldw.pb(n + 1); for(int i = 1; i <= n; i++){ oldh.insert(-vec[i]); oldw.insert(vec[i]); vector<int>::iterator ith = upper_bound(oldh.begin(), oldh.end(), -vec[i]); vector<int>::iterator itw = upper_bound(oldw.begin(), oldw.end(), vec[i]); int h = vec[i] + *ith; int w = *itw - vec[i]; ans += h * w * i; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:28: error: no matching function for call to 'std::vector<int>::insert(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)' 52 | oldh.insert(-vec[i]); | ~~~~~~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 1484 | insert(const_iterator __position, _InputIterator __first, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/vector:72: /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 133 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 1395 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]' 1413 | insert(const_iterator __position, initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; size_type = long unsigned int; value_type = int]' 1439 | insert(const_iterator __position, size_type __n, const value_type& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate expects 3 arguments, 1 provided a.cc:53:28: error: no matching function for call to 'std::vector<int>::insert(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 53 | oldw.insert(vec[i]); | ~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 1484 | insert(const_iterator __position, _InputIterator __first, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 133 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 1395 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]' 1413 | insert(const_iterator __position, initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; size_type = long unsigned int; value_type = int]' 1439 | insert(const_iterator __position, size_type __n, const value_type& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate expects 3 arguments, 1 provided
s357814057
p03987
C++
#include <string.h> #include <string> #include <vector> #include <deque> #include <list> #include <stack> #include <queue> #include <map> #include <set> #include <iterator> #include <functional> #include <algorithm> #include <numeric> #include <iostream> #include <sstream> #include <iomanip> #include <cmath> #include <cstdlib> #include <cstdio> using namespace std; #define sz(a) int((a).size()) #define all(a) a.begin(), a.end() #define pb push_back #define mp make_pair #define CLR(a) memset((a), 0, sizeof(a)) #define INF (1 << 31) - 1 const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1}; const int dw[8] = {0, 0, 1, -1,1,-1,1,-1}; typedef long long ll; typedef pair<int, int> p; typedef vector <int> VI; typedef vector <string> VS; int main(){ int n; cin >> n; VI vec(n+1); for(int i = 1; i <= n; i++){ int num; cin >> num; vec[num] = i; } ll ans = 0; vector <int> oldh; vector <int> oldw; oldh.insert(0); oldw.insert(n + 1); for(int i = 1; i <= n; i++){ oldh.insert(-vec[i]); oldw.insert(vec[i]); vector<int>::iterator ith = upper_bound(oldh.begin(), oldh.end(), -vec[i]); vector<int>::iterator itw = upper_bound(oldw.begin(), oldw.end(), vec[i]); int h = vec[i] + *ith; int w = *itw - vec[i]; ans += h * w * i; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:48:20: error: no matching function for call to 'std::vector<int>::insert(int)' 48 | oldh.insert(0); | ~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 1484 | insert(const_iterator __position, _InputIterator __first, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/vector:72: /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 133 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 1395 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]' 1413 | insert(const_iterator __position, initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; size_type = long unsigned int; value_type = int]' 1439 | insert(const_iterator __position, size_type __n, const value_type& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate expects 3 arguments, 1 provided a.cc:49:20: error: no matching function for call to 'std::vector<int>::insert(int)' 49 | oldw.insert(n + 1); | ~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 1484 | insert(const_iterator __position, _InputIterator __first, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 133 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 1395 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]' 1413 | insert(const_iterator __position, initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; size_type = long unsigned int; value_type = int]' 1439 | insert(const_iterator __position, size_type __n, const value_type& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate expects 3 arguments, 1 provided a.cc:52:28: error: no matching function for call to 'std::vector<int>::insert(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)' 52 | oldh.insert(-vec[i]); | ~~~~~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 1484 | insert(const_iterator __position, _InputIterator __first, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 133 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 1395 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]' 1413 | insert(const_iterator __position, initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; size_type = long unsigned int; value_type = int]' 1439 | insert(const_iterator __position, size_type __n, const value_type& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1439:7: note: candidate expects 3 arguments, 1 provided a.cc:53:28: error: no matching function for call to 'std::vector<int>::insert(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 53 | oldw.insert(vec[i]); | ~~~~~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]' 1484 | insert(const_iterator __position, _InputIterator __first, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1484:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 133 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:133:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator; value_type = int]' 1395 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:1395:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_vector.h:1413:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert
s763637512
p03987
C++
a #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i,a,b) for(int i=a;i<b;++i) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define all(a) begin(a),end(a) #define ifnot(a) if(not (a)) #define dump(x) cerr << #x << " = " << (x) << endl using namespace std; // #define int ll int dx[] = { 0,1,0,-1 }; int dy[] = { 1,0,-1,0 }; #define LINF ((ll)1 << 60) #define INF (1 << 28) template<typename T> void chmax(T& a, T b) { if (a < b) a = b; } template<typename T> void chmin(T& a,T b) { if (a > b) a = b; } bool debug = false; //..................... ull mod = (int)1e9 + 7; const int MAX = (int)2e5 + 5; int N; vector<int> a; set<int> set1; map<int, int> m; void solve() { cin >> N; a.resize(N); rep(i, N) { cin >> a[i]; a[i]--; m[a[i]] = i; set1.insert(i); } set1.insert(-1); set1.insert(N); ll res = 0; for (int v = N - 1; v > -1; v--) { auto i = m[v]; auto itr = set1.lower_bound(i-1); ll l = *itr; itr++; itr++; ll r = *itr; if (debug) { cerr << "set : "; for (auto v : set1) { cerr << v << " "; } cerr << endl; dump(i-1); dump(l); dump(r); cerr << endl; } ll tmp = (i - l) * (r - i) * (v + 1); dump(tmp); res += tmp; set1.erase(i); } cout << res << endl; } signed main(int argc, char *argv[]) { int T = 1; cout << fixed << setprecision(20); rep(i, argc) { if (argv[i] == "-debug"s) { debug = true; } } rep(i, T) { solve(); } return 0; }
a.cc:1:1: error: 'a' does not name a type 1 | a | ^ 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:6: /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] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/1
s959564869
p03987
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<queue> #include<map> #include<set> #include<algorithm> #include<complex> #include<string> #include<cstring> using namespace std; #define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++) #define rep(x,to) rep2(x,0,to) #define INF 100000000 #define debug(x) cout<<#x<<": "<<x<<endl #define all(x) x.begin(),x.end() typedef pair<int,int> P; typedef pair<int,P> PP; int input_n; int ans; int n; int a[200005]; set<int> st; int index[200005]; int l[200005]; int r[200005]; int main() { cin>>n; rep(i,n) { cin>>a[i]; index[a[i]-1]=i; } rep(i,n) { st.insert(index[i]); set<int>::iterator it=st.find(index[i]); set<int>::iterator iit=it; set<int>::iterator itt=it; iit--; itt++; if(it==st.begin()) { l[index[i]]=0; } else { l[index[i]]=(*iit)+1; } if(itt==st.end()) { r[index[i]]=n-1; } else { //if(index[i]==0)cout<<"a"; r[index[i]]=(*itt)-1; } } rep(i,n) { //cout<<l[i]<<" "<<r[i]<<endl; ans+=a[i]*(i-l[i]+1)*(r[i]-i+1); } cout<<ans<<endl; return 0; }
a.cc:26:17: error: 'int index [200005]' redeclared as different kind of entity 26 | int index[200005]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from a.cc:11: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'int main()': a.cc:35:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 35 | index[a[i]-1]=i; | ^ a.cc:39:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 39 | st.insert(index[i]); | ^ a.cc:40:52: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 40 | set<int>::iterator it=st.find(index[i]); | ^ a.cc:47:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 47 | l[index[i]]=0; | ^ a.cc:51:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 51 | l[index[i]]=(*iit)+1; | ^ a.cc:55:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 55 | r[index[i]]=n-1; | ^ a.cc:60:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 60 | r[index[i]]=(*itt)-1; | ^
s954654009
p03987
C++
#include <algorithm> #include <iostream> #include <cstdio> #include <map> #include <numeric> #include <cmath> #include <set> #include <sstream> #include <string> #include <vector> #include <queue> #include <stack> #include <complex> #include <string.h> #include <unordered_set> #include <unordered_map> #include <bitset> #include <iomanip> #include <sys/time.h> #include <random> using namespace std; #define endl '\n' #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef long double ld; typedef pair<ll, int> P; typedef complex<double> comp; typedef vector< vector<ld> > matrix; struct pairhash { public: template<typename T, typename U> size_t operator()(const pair<T, U> &x) const { size_t seed = hash<T>()(x.first); return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; const int inf = 1e9 + 9; const ll mod = 1e9 + 7; const double eps = 1e-8; const double pi = acos(-1); int n; ll a[200010]; // Range Mininum Query template<typename T> class SegmentTree { private: int n; T dat[2000100]; public: SegmentTree(int n_) { n = 1; while (n < n_) n *= 2; for (int i = 0; i < 2*n-1; i++) dat[i] = INT_MAX; } void update(int k, T a) { k += n - 1; dat[k] = a; while (k > 0) { k = (k - 1) / 2; dat[k] = min(dat[k*2+1], dat[k*2+2]); } } // call query(a, b) // return min value for [a, b) T query(int a, int b) { return query(a, b, 0, 0, n); } T query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return INT_MAX; if (a <= l && r <= b) return dat[k]; else { T vl = query(a, b, k*2+1, l, (l+r)/2); T vr = query(a, b, k*2+2, (l+r)/2, r); return min(vl, vr); } } }; int idx[200010]; SegmentTree<ll> st(200010); ll calc(int l, int r) { if (l >= r) return 0; ll v = st.query(l, r); int i = idx[v]; return (v+1) * (i - l + 1) * (r - i) + calc(l, i) + calc(i+1, r); } ll solve() { for (int i = 0; i < n; i++) { idx[a[i]] = i; st.update(i, a[i]); } return calc(0, n); } void input() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; a[i]--; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); input(); cout << solve() << endl; }
a.cc: In constructor 'SegmentTree<T>::SegmentTree(int)': a.cc:59:50: error: 'INT_MAX' was not declared in this scope 59 | for (int i = 0; i < 2*n-1; i++) dat[i] = INT_MAX; | ^~~~~~~ a.cc:21:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 20 | #include <random> +++ |+#include <climits> 21 | using namespace std; a.cc: In member function 'T SegmentTree<T>::query(int, int, int, int, int)': a.cc:75:38: error: 'INT_MAX' was not declared in this scope 75 | if (r <= a || b <= l) return INT_MAX; | ^~~~~~~ a.cc:75:38: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s601951127
p03987
Java
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner in = new Scanner(System.in)) { int N = in.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; i++) { A[i] = in.nextInt(); } System.out.println(solve(0, A.length - 1, new RMQ(A))); } } private static long solve(int l, int r, RMQ rmq){ if (l > r) return 0; if (l == r) return rmq.queryValue(l, r); int p = rmq.queryPosition(l, r); int key = rmq.queryValue(l, r); return (long)key * (p - l + 1) * (r - p + 1) + solve(l, p - 1, rmq) + solve(p + 1, r, rmq); } }
Main.java:20: error: cannot find symbol private static long solve(int l, int r, RMQ rmq){ ^ symbol: class RMQ location: class Main Main.java:16: error: cannot find symbol System.out.println(solve(0, A.length - 1, new RMQ(A))); ^ symbol: class RMQ location: class Main 2 errors
s111838600
p03987
Java
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner in = new Scanner(System.in)) { int N = in.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; i++) { A[i] = in.nextInt(); } System.out.println(solve(0, A.length - 1, new RMQ(A))); } } private static long solve(int l, int r, RMQ rmq){ if (l > r) return 0; if (l == r) return rmq.queryValue(l, r); int p = rmq.queryPosition(l, r); int key = rmq.queryValue(l, r); return (long)key * (p - l + 1) * (r - p + 1) + solve(l, p - 1, rmq) + solve(p + 1, r, rmq); } }
Main.java:20: error: cannot find symbol private static long solve(int l, int r, RMQ rmq){ ^ symbol: class RMQ location: class Main Main.java:16: error: cannot find symbol System.out.println(solve(0, A.length - 1, new RMQ(A))); ^ symbol: class RMQ location: class Main 2 errors
s097501641
p03987
Java
import java.io.*; import java.util.*; public final class minimum_sums_dsu { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static int[] parent,depth,size; static int getParent(int u) { if(u==parent[u]) return u; int val=getParent(parent[u]);parent[u]=val;return parent[u]; } static void merge(int u,int v) { if(depth[u]>depth[v]) { size[u]+=size[v];parent[v]=u; } else if(depth[v]>depth[u]) { size[v]+=size[u];parent[u]=v; } else { depth[u]++;size[u]+=size[v];parent[v]=u; } } public static void main(String args[]) throws Exception { int n=sc.nextInt();Pair[] a=new Pair[n];TreeSet<Integer> ts=new TreeSet<Integer>();parent=new int[n];depth=new int[n];size=new int[n]; for(int i=0;i<n;i++) { a[i]=new Pair(i,sc.nextLong());parent[i]=i;depth[i]=1;size[i]=1; } Arrays.sort(a);long res=0; for(int i=n-1;i>=0;i--) { long l=1,r=1;Integer val1=ts.lower(a[i].idx),val2=ts.higher(a[i].idx); if(val1!=null && val1==a[i].idx-1) { int x=getParent(a[i].idx-1);l+=size[x];merge(x,a[i].idx); } if(val2!=null && val2==a[i].idx+1) { int x=getParent(a[i].idx+1);r+=size[x];merge(x,getParent(a[i].idx)); } res=res+(a[i].val*l*r);ts.add(a[i].idx); } out.println(res);out.close(); } } class Pair implements Comparable<Pair> { int idx;long val; public Pair(int idx,long val) { this.idx=idx;this.val=val; } public int compareTo(Pair x) { return Long.compare(this.val,x.val); } } class FastScanner { BufferedReader in; StringTokenizer st; public FastScanner(BufferedReader in) { this.in = in; } public String nextToken() throws Exception { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(in.readLine()); } return st.nextToken(); } public String next() throws Exception { return nextToken().toString(); } public int nextInt() throws Exception { return Integer.parseInt(nextToken()); } public long nextLong() throws Exception { return Long.parseLong(nextToken()); } public double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } }
Main.java:3: error: class minimum_sums_dsu is public, should be declared in a file named minimum_sums_dsu.java public final class minimum_sums_dsu ^ 1 error
s013868353
p03987
C++
#include <iostream> #include <unordered_map> #include <set> #include <vector> static const int INF = 100000000; using namespace std; int main() { int N(8); int res(0); vector<int> v{5,4,8,1,2,6,7,3}; int min = v[0]; for (int j = 0; j < N; ++j){ for (int r = j; r < N; ++r){ if (r == j){ mat[j][r] = v[j]; min = v[j]; res += v[j]; continue; } if (v[r] < min){ min = v[r]; res += min; }else{ res += min; } } } cout << res; }
a.cc: In function 'int main()': a.cc:20:17: error: 'mat' was not declared in this scope 20 | mat[j][r] = v[j]; | ^~~
s112537251
p03987
C++
#include<stdio.h> long long int n, a[200100],sum; int main(){ int i,j; scanf("%lld",&n); a[0]=0; for(i=1;i<=n;i++){ scanf("%lld",a+i); j=i-1; while(a[i]<a[j]){ a[j]=a[i]; j--; s=s-a[i]+a[j]; } sum=sum+s; } printf("%lld",sum); }
a.cc: In function 'int main()': a.cc:13:25: error: 's' was not declared in this scope 13 | s=s-a[i]+a[j]; | ^ a.cc:15:25: error: 's' was not declared in this scope 15 | sum=sum+s; | ^
s631239395
p03987
C++
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<queue> #include<cmath> #include<map> #include<set> using namespace std; const int INF = 1 << 29; const double EPS = 1e-9; typedef long long ll; #define SORT(c) sort((c).begin(),(c).end()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) class RMQ{ private: static const int MAX_N = 1 << 17; int n, dat[2*MAX_N -1]; //[a,b)の最小値を返す //kは節点の番号l,rはその節点が[l,r)を保持している int rec(int a,int b,int k,int l,int r){ if(b <= l || r <= a){ return INT_MAX; } if(a<=l && r<=b){ return dat[k]; }else{ int rl = rec(a,b,2*k+1,l,(l+r)/2); int rr = rec(a,b,2*k+2,(l+r)/2,r); return min(rl,rr); } } public: void init(int n_){ n=1; while(n < n_) n*=2; for(int i=0;i<2*n-1;i++){ dat[i] = INT_MAX; } } //kをaに変更 void update(int k, int a){ int reaf = k+n-1; dat[reaf]=a; while(reaf>0){ reaf = (reaf-1)/2; dat[reaf]=min(dat[reaf*2+1],dat[2*reaf+2]); } } //query[a,b]の範囲内の最小値を返す int query(int a,int b){ return rec(a,b+1,0,0,n); } }; int N; int a[200001]; int main(int argc, char * argv[]) { ios::sync_with_stdio(false); RMQ r; cin >> N; r.init(N); int x; rep(i,N){ cin >> x; r.update(i,x); } ll sum = 0; rep(i,N) { for (int j=i; j<N; j++) { sum += r.query(i,j); } } cout << sum << endl; return 0; }
a.cc: In member function 'int RMQ::rec(int, int, int, int, int)': a.cc:27:16: error: 'INT_MAX' was not declared in this scope 27 | return INT_MAX; | ^~~~~~~ a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include<set> +++ |+#include <climits> 9 | using namespace std; a.cc: In member function 'void RMQ::init(int)': a.cc:45:16: error: 'INT_MAX' was not declared in this scope 45 | dat[i] = INT_MAX; | ^~~~~~~ a.cc:45:16: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s751916414
p03987
C++
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a[200000]; int N; int i, j; unsigned long long ans = 0; unsigned long long *minwa; int prev; minwa = (unsigned long long *)calloc(200000, sizeof(unsigned long long)); scanf("%d", &N); for (i = 0; i < N; i++) { std::cin >> a[i]; } prev = a[0]; for (i = 0; i < N; i++) { unsigned long long wa = 0; int min = a[i]; for (j = 0; j < N - i; j++) { if (min > a[i + j]) { min = a[i + j]; } if (prev < min) { if (minwa[prev] != 0) { minwa[prev] -= prev; } } else if (minwa[prev] != 0) { wa += minwa[prev]; break; } wa += min; } prev = a[i]; minwa[prev] = wa - a[i]; ans += wa; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:57:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 57 | cout << ans << endl; | ^~~~ | std::cout In file included from a.cc:1: /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:57:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 57 | cout << ans << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s120167358
p03987
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; const ll INF = 1000000000ll; const ll MOD = 1000000007ll; const double EPS = 1e-8; int main(void) { //ios_base::sync_with_stdio(false); //cin.tie(0); int n; vector<int> a; set<int> p; int pos[200005]; long long ans = 0; cin >> n; for(int i=0; i<n; i++){ int t; cin >> t; pos[t] = i; a.push_back(t); } p.insert(-1); p.insert(n); for(int i=1; i<=n; i++){ //printf("%d %d %d\n", lpos[i], rpos[i], i* ((abs(lpos[i] + 1 - pos[i]) + 1) * (abs(rpos[i] - 1 - pos[i]) + 1))); auto l = --p.lower_bound(pos[i]); auto r = p.upper_bound(pos[i]); //cout << (*l) << ' ' << (*r) << endl; ans += (long long)i* (long long)(abs((*l) - pos[i])) * (long long)(abs((*r) - pos[i]) )); //cout << ((abs((*l) - pos[i])) * (abs((*r) - pos[i]) )) << endl; p.insert(pos[i]); } cout << ans<< endl; return 0; }
a.cc: In function 'int main()': a.cc:36:104: error: expected ';' before ')' token 36 | ans += (long long)i* (long long)(abs((*l) - pos[i])) * (long long)(abs((*r) - pos[i]) )); | ^ | ;
s476439515
p03987
C++
#include <algorithm> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define SREP(s,i,m) for(unsigned int i = s; i < m; ++i) #define REP(i,m) SREP(0,i,m) using namespace std; #ifdef _MSC_VER using LONG = __int64; using ULONG = unsigned __int64; #else using LONG = long long int; //using ULONG = unsigned long long int; using ULONG = unsigned __int64; #endif int N; vector<int> a; set<int> used; map<int, int> pos; ULONG result = 0; void calculate() { for (int num = 1; num <= N; num++) { auto prev = used.lower_bound(pos[num]); if (prev == used.begin()) prev = used.end(); else prev--; auto next = used.upper_bound(pos[num]); int left, right; if (prev == used.end()) { left = pos[num]; } else { left = pos[num] - *prev - 1; } if (next == used.end()) { right = N - pos[num] - 1; } else { right = *next - pos[num] - 1; } if (right < 0) throw runtime_error("bug 1"); if (left < 0) throw runtime_error("bug 2"); if (right >= N) throw runtime_error("bug 3"); if (left >= N) throw runtime_error("bug 4"); result += (ULONG)num * (ULONG)(right * left + right + left + 1); used.insert(pos[num]); } } int main(void) { cin >> N; a.resize(N); REP(i, N) { cin >> a[i]; pos[a[i]] = i; } calculate(); cout << result << endl; return 0; }
a.cc:21:23: error: expected ';' before '__int64' 21 | using ULONG = unsigned __int64; | ^~~~~~~~ | ; a.cc:28:1: error: 'ULONG' does not name a type; did you mean 'LONG'? 28 | ULONG result = 0; | ^~~~~ | LONG a.cc: In function 'void calculate()': a.cc:51:5: error: 'result' was not declared in this scope 51 | result += (ULONG)num * (ULONG)(right * left + right + left + 1); | ^~~~~~ a.cc:51:16: error: 'ULONG' was not declared in this scope; did you mean 'LONG'? 51 | result += (ULONG)num * (ULONG)(right * left + right + left + 1); | ^~~~~ | LONG a.cc: In function 'int main()': a.cc:64:11: error: 'result' was not declared in this scope 64 | cout << result << endl; | ^~~~~~
s215318737
p03987
C++
#include <algorithm> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define SREP(s,i,m) for(unsigned int i = s; i < m; ++i) #define REP(i,m) SREP(0,i,m) using namespace std; #ifdef _MSC_VER using LONG = __int64; using ULONG = unsigned __int64; #else using LONG = long long int; //using ULONG = unsigned long long int; using ULONG = unsigned __int128; #endif int N; vector<int> a; set<int> used; map<int, int> pos; ULONG result = 0; void calculate() { for (int num = 1; num <= N; num++) { auto prev = used.lower_bound(pos[num]); if (prev == used.begin()) prev = used.end(); else prev--; auto next = used.upper_bound(pos[num]); int left, right; if (prev == used.end()) { left = pos[num]; } else { left = pos[num] - *prev - 1; } if (next == used.end()) { right = N - pos[num] - 1; } else { right = *next - pos[num] - 1; } if (right < 0) throw runtime_error("bug 1"); if (left < 0) throw runtime_error("bug 2"); if (right >= N) throw runtime_error("bug 3"); if (left >= N) throw runtime_error("bug 4"); result += (ULONG)num * (ULONG)(right * left + right + left + 1); used.insert(pos[num]); } } int main(void) { cin >> N; a.resize(N); REP(i, N) { cin >> a[i]; pos[a[i]] = i; } calculate(); cout << result << endl; return 0; }
a.cc: In function 'int main()': a.cc:64:8: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'ULONG' {aka '__int128 unsigned'}) 64 | cout << result << endl; | ~~~~ ^~ ~~~~~~ | | | | | ULONG {aka __int128 unsigned} | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/bits/quoted_string.h:38, from /usr/include/c++/14/iomanip:50, from a.cc:3: /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char) [with _CharT = char; _Traits = char_traits<char>]' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char) [with _Traits = char_traits<char>]' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char) [with _Traits = char_traits<char>]' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char) [with _Traits = char_traits<char>]' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~
s516052825
p03987
C++
#include <iostream> using namespace std; // int main(){ // long long int sum = 0; // int n; // int a[200001]; // cin >> n; // for (int i = 0; i < n; ++i) // { // cin >> a[i]; // } // for (int l = 0; l < n; ++l) // { // int min = 200001; // for (int r = l; r < n; ++r) // { // if(min > a[r]) min = a[r]; // sum += min; // } // } // cout << sum << endl; // } int main(){ long long int sum = 0; int n; int a[200001][200001]; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i][i]; } for (int l = n-1; l >= 0; --l) { // int min = 200001; for (int r = l; r < n; ++r) { if(l == r){ }else if(a[l][r-1] > a[r][r]){ a[l][r] = a[r][r]; }else{ a[l][r] = a[l][r-1]; } sum += a[l][r] } } cout << sum << endl; }
a.cc: In function 'int main()': a.cc:52:39: error: expected ';' before '}' token 52 | sum += a[l][r] | ^ | ; 53 | } | ~
s090800074
p03987
C++
#include <iostream> #include <vector> #include <string> #include <stack> #include <queue> #include <cmath> #include <set> #include <algorithm> #include <functional> #include <cstring> #include <iterator> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) int main() { int N; cin >> N; vector<int>a(N); rep(i, N)cin >> a[i]; ll ans = 0; queue<vector<int>> que; que.push(a); while (!que.empty()) { vector<int> v = que.front(); que.pop(); if (v.size() == 0)continue; auto mn = min_element(v.begin(), v.end()); vector<int>w, x; copy(v.begin(), mn, back_inserter(w)); copy(mn+1, v.end(), back_inserter(x)); que.push(w); que.push(x); ans += (*mn)*(distance(v.begin(), mn)+1)*(distance(mn + 1, v.end())+1); } cout << ans << endl; retu
a.cc: In function 'int main()': a.cc:39:9: error: 'retu' was not declared in this scope 39 | retu | ^~~~ a.cc:39:13: error: expected '}' at end of input 39 | retu | ^ a.cc:17:1: note: to match this '{' 17 | { | ^
s625512166
p03987
C++
#include<bits/stdc++.h> using namespace std; long long index1[200005]; map<long long ,long long > mp; int main() { int n; cin>>n; long long i,j,a; for(i=1;i<=n;i++) { cin>>a; index1[a]=i; } mp[0]=1; mp[n+1]=1; long long l,r; map<long long ,long long> ::iterator it; long long left,right,this_index,k,ans = 0; for(i=1;i<=n;i++) { it = mp.upper_bound(index[i]); r=it->first; it--; l=it->first; k=index1[i]; this_index=(r-(l+1)); if(k!=l+1&&k!=r-1) this_index++; ans+=this_index*i; mp[index1[i]]=1; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:22:43: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 22 | it = mp.upper_bound(index[i]); | ^
s320957561
p03987
C++
#include<bits/stdc++.h> using namespace std; long long index[200005]; map<long long ,long long > mp; int main() { int n; cin>>n; long long i,j,a; for(i=1;i<=n;i++) { cin>>a; index[a]=i; } mp[0]=1; mp[n+1]=1; long long l,r; map<long long ,long long> ::iterator it; long long left,right,this_index,k,ans = 0; for(i=1;i<=n;i++) { it = mp.upper_bound(index[i]); r=it->first; it--; l=it->first; k=index[i]; this_index=(r-(l+1)); if(k!=l+1&&k!=r-1) this_index++; ans+=this_index*i; mp[index[i]]=1; } cout<<ans; return 0; }
a.cc:3:24: error: 'long long int index [200005]' redeclared as different kind of entity 3 | long long index[200005]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'int main()': a.cc:13:23: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 13 | index[a]=i; | ^ a.cc:22:43: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 22 | it = mp.upper_bound(index[i]); | ^ a.cc:26:25: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 26 | k=index[i]; | ^ a.cc:31:26: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript 31 | mp[index[i]]=1; | ^
s954839192
p03987
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<int> a(N); vector<pair<int,int> > ord(N); for(int i = 0; i < N; ++i){ cin >> a[i]; ord[i].first = a[i]; ord[i].second = i; } sort(ord.begin(), ord.end()); vector<int> len(N, 1); long long ans = 0; for(int i = N-1; i >= 0; --i){ int cur = ord[i].second; int left = 0; int right = 0; if(cur > 0 && a[cur-1] > a[cur]){ left = len[cur-1]; } if(cur < N-1 && a[cur+1] > a[cur]){ right = len[cur+1]; } ans += (long long)(ord[i].first) * (left+1) * (right+1); len[cur - left] = left+right+1; a[cur -left] = ord[i].first; len[cur + right] = left+right+1; a[cur + right] = ord[i].first; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:5: error: 'sort' was not declared in this scope; did you mean 'short'? 16 | sort(ord.begin(), ord.end()); | ^~~~ | short
s299249530
p03987
C++
#include<iostream> #include<algorithm> #include<cstdio> #include<vector> using namespace std; struct rmqsegtree{ vector< pair<int, int> > t; //<data, at> pair<int, int> re; int n; void dflt(void){ re.first = INT_MAX; re.second = -1; return; } void use(void){ int i; dflt(); for(i = 0;;++i)if((1 << i) >= n)break; ++i; t.resize(1 << i); t[0].first = 1 << (i - 1); t[0].second = 1 << i; for(i = 1;i < t[0].second;++i)t[i] = re; for(i = 0;i < n;++i)t[i + t[0].first].second = i; return; } void build(vector<int> a){ for(n = 1;;n <<= 1)if(n >= a.size())break; t.resize(n << 1); dflt(); t[0].first = n; t[0].second = t[0].first << 1; n = a.size(); for(int i = 1;i < t[0].second;++i)t[i] = re; for(int i = 0;i < n;++i){ t[t[0].first + i].first = a[i]; t[t[0].first + i].second = i; } for(int i = t[0].first - 1;i >= 1;--i) t[i] = (t[i << 1] <= t[(i << 1) + 1]) ? t[i << 1] : t[(i << 1) + 1]; return; } void update(int at, int data){ t[t[0].first + at].first = data; for(int x = t[0].first + at;x > 1;){ x >>= 1; if(t[x << 1].first < t[(x << 1) + 1].first)t[x] = t[x << 1]; else t[x] = t[(x << 1) + 1]; } return; } pair<int, int> query(int l, int r, int k, int kl, int kr){ //printf("%d %d %d %d %d\n", l, r, k, kl, kr); if(l <= t[k].second && t[k].second < r)return t[k]; if(k >= t.size())return re; if(kl >= r || kr <= l)return re; if(l <= kl && kr <= r)return t[k]; pair<int, int> a = query(l, r, k << 1, kl, (kl + kr) >> 1); pair<int, int> b = query(l, r, k * 2 + 1, (kl + kr) >> 1, kr); return (a.first < b.first) ? a : b; } pair<int, int> find(int l, int r){ return query(l, r, 1, 0, t[0].first); } void deb(void){ int x = 1; printf("t[0] = (%d, %d)\n", t[0].first, t[0].second); for(int i = 1;i < t[0].second;++i){ printf("%11d", t[i].first); if(i == (1 << x) - 1){ puts(""); ++x; } } return; } }; typedef long long ll; vector<int> aa; int where[200001] = {0}; int n; rmqsegtree R; ll solve(int mi, int l, int r){ if(r - l == 1)return mi; if(r - l == 2)return aa[l] + aa[l + 1] + min(aa[l], aa[l + 1]); int qwe = min(where[mi] - l + 1, r - where[mi]), rty = max(where[mi] - l + 1, r - where[mi]); ll res = (ll)qwe * (ll)(qwe + 1); res += (ll)(1 + r - l - rty - 1) * (ll)(1 + r - l - rty); res >>= 1; res += (ll)qwe * (ll)(rty - qwe); res *= (ll)mi; bool isl = (where[mi] - l > 0), isr = (r - where[mi] > 1); if(isl)res += solve(R.find(l, where[mi]).first, l, where[mi]); if(isr)res += solve(R.find(where[mi] + 1, r).first, where[mi] + 1, r); return res; } signed main(void){ scanf("%d", &n); aa.resize(n); for(int i = 0;i < n;++i){ scanf("%d", &aa[i]); where[aa[i]] = i; } R.build(aa); printf("%lld\n", solve(1, 0, n)); return 0; }
a.cc: In member function 'void rmqsegtree::dflt()': a.cc:12:31: error: 'INT_MAX' was not declared in this scope 12 | void dflt(void){ re.first = INT_MAX; re.second = -1; return; } | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<vector> +++ |+#include <climits> 5 |
s416706252
p03987
C++
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <sstream> #include <vector> #include <map> #include <set> #include <deque> #include <list> #include <stack> #include <queue> #include <complex> #include <ctime> #include<cstdlib> #define _USE_MATH_DEFINES #include <math.h> #include<cmath> #include <cstdarg> #include <iomanip> #include<unordered_map> #include<unordered_set> //#include <arra.y> //#define NDEBUG #include <assert.h> using namespace std; #define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);} #define printe(...) fprintf(stderr, __VA_ARGS__); #define PrtExp(_Exp) cerr<< #_Exp <<" = "<< (_Exp) #define PrtExpN(_Exp) cerr<< #_Exp <<" = "<< (_Exp) <<"\n" #define SINT(n) scanf("%d",&n); #define SINT2(n,m) scanf("%d %d",&n,&m); #define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o); #define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p); #define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q); //#define SLL(n) scanf("%I64d",&n); #define SLL(n) scanf("%lld",&n); #define SLL2(n,m) scanf("%lld %lld",&n,&m); #define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o); #define SST(s) scanf("%s",s); #define SCH(c) scanf("%c",&c); #define GC() getchar(); #define PINT(n) printf("%d",(int)(n)); #define PINT2(n,m) printf("%d %d",(int)(n),(int)(m)); #define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l)); //#define PLL(n) printf("%I64d",(long long)(n)); #define PLL(n) printf("%lld",(long long)(n)); #define PST(s) printf("%s",(s)); #define PCH(s) printf("%c",(s)); #define PINTN(n) printf("%d\n",(int)(n)); #define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m)); #define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l)); //#define PLLN(n) printf("%I64d\n",(long long)(n)); #define PLLN(n) printf("%lld\n",(long long)(n)); #define PSTN(s) printf("%s\n",(s)); #define PCHN(s) printf("%c\n",(s)); #define PSP() printf(" "); #define PN() printf("\n"); #define PC(c) putchar(c); #define CSP (' ') #define SN ("\n") #define rep(i,a) for(i=0;i<a;i++) #define reP(i,a) for(i=0;i<=a;i++) #define Rep(i,a) for(i=a-1;i>=0;i--) #define ReP(i,a) for(i=a;i>=0;i--) #define rEp(i,a) for(int i=0;i<a;i++) #define rEP(i,a) for(int i=0;i<=a;i++) #define REp(i,a) for(int i=a-1;i>=0;i--) #define REP(i,a) for(int i=a;i>=0;i--) #define repft(i,a,b) for(i=a;i<b;i++) #define repfT(i,a,b) for(i=a;i<=b;i++) #define Repft(i,a,b) for(i=a-1;i>=b;i--) #define RepfT(i,a,b) for(i=a;i>=b;i--) #define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it) #define FILL(a,v) fill(begin(a),end(a), v) #define FILL0(a) memset(a,0,sizeof(a)) #define FILL1(a) memset(a,-1,sizeof(a)) typedef long long ll; typedef unsigned long ul; typedef pair<int, int> Pi; typedef pair<ll, ll> Pl; const int INF = 0x1f1f1f1f;//522,133,279 const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863 template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; }; template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); }; template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); }; ll bitcount(ll bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff); } // A utility function to get minimum of two numbers int minVal(int x, int y) { return (x < y) ? x : y; } // A utility function to get the middle index from corner indexes. int getMid(int s, int e) { return s + (e - s) / 2; } /* A recursive function to get the minimum value in a given range of array indexes. The following are parameters for this function. st --> Pointer to segment tree index --> Index of current node in the segment tree. Initially 0 is passed as root is always at index 0 ss & se --> Starting and ending indexes of the segment represented by current node, i.e., st[index] qs & qe --> Starting and ending indexes of query range */ int RMQUtil(int *st, int ss, int se, int qs, int qe, int index) { // If segment of this node is a part of given range, then return // the min of the segment if (qs <= ss && qe >= se) return st[index]; // If segment of this node is outside the given range if (se < qs || ss > qe) return INT_MAX; // If a part of this segment overlaps with the given range int mid = getMid(ss, se); return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1), RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2)); } // Return minimum of elements in range from index qs (quey start) to // qe (query end). It mainly uses RMQUtil() int RMQ(int *st, int n, int qs, int qe) { // Check for erroneous input values if (qs < 0 || qe > n - 1 || qs > qe) { printf("Invalid Input"); return -1; } return RMQUtil(st, 0, n - 1, qs, qe, 0); } // A recursive function that constructs Segment Tree for array[ss..se]. // si is index of current node in segment tree st int constructSTUtil(int arr[], int ss, int se, int *st, int si) { // If there is one element in array, store it in current node of // segment tree and return if (ss == se) { st[si] = arr[ss]; return arr[ss]; } // If there are more than one elements, then recur for left and // right subtrees and store the minimum of two values in this node int mid = getMid(ss, se); st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1), constructSTUtil(arr, mid + 1, se, st, si * 2 + 2)); return st[si]; } /* Function to construct segment tree from given array. This function allocates memory for segment tree and calls constructSTUtil() to fill the allocated memory */ int *constructST(int arr[], int n) { // Allocate memory for segment tree //Height of segment tree int x = (int)(ceil(log2(n))); // Maximum size of segment tree int max_size = 2 * (int)pow(2, x) - 1; int *st = new int[max_size]; // Fill the allocated memory st constructSTUtil(arr, 0, n - 1, st, 0); // Return the constructed segment tree return st; } int a[200010]; int A[200010]; int main() { int N; ll ret = 0; cin >> N; int i, j; a[0] = 0; rep(i, N) { SINT(a[i + 1]); } a[N + 1] = 0; rep(i, N + 2)A[i] = a[i]; reverse(A, A + N + 2); int *st = constructST(a, N + 2); int *ST = constructST(A, N + 2); repfT(i, 1, N) { ll llen,rlen; int l = 0, r = i-1, m, v; //cerr << a[i] << endl; while (l + 1 < r) { m = (l + r) / 2; v = RMQ(st, N + 2, m, i-1); //cout << "Min[" << m << "," << (i-1) << "]=" << v << endl; if (v > a[i]) r = m; else l = m; } if (RMQ(st, N + 2, r, i - 1) < a[i]) l = r; llen = i - l; //cout << " "<< llen << endl; int I = N + 1 - i; l = 0, r = I - 1, m, v; //cerr << A[I] << endl; while (l + 1 < r) { m = (l + r) / 2; v = RMQ(ST, N + 2, m, I - 1); //cout << "Min[" << m << "," << (I-1) << "]=" << v << endl; if (v > A[I]) r = m; else l = m; } if (RMQ(ST, N + 2, r, I - 1) < A[I]) l = r; rlen = I - l; //cout << " "<< rlen << endl; ret += a[i] * llen*rlen; } cout << ret << endl; return 0; } /* 2 1 3 1 1 1 0 1 3 2 4 0 0 1 2 2 0 0 1 2 0 0 1 0 0 0 0 */
a.cc: In function 'int RMQUtil(int*, int, int, int, int, int)': a.cc:143:24: error: 'INT_MAX' was not declared in this scope 143 | return INT_MAX; | ^~~~~~~ a.cc:28:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 27 | #include <assert.h> +++ |+#include <climits> 28 |
s698827159
p03987
C
#include<stdio.h> #include<stdlib.h> int main() { int minx; int sum = 0; int n; int *a; int loop; int loop1, loop2; scanf("%d", &n); a = malloc(sizeof(int)*n); for (loop = 0; loop < n; loop++)scanf("%d", &a[loop]); for (loop1 = 0; loop1 < n; loop1++) { minx = a[loop1]; for (loop2 = loop1; loop2 < n; loop2++) { minx = min(minx, a[loop2]); sum += minx; } } printf("%d\n", sum); return 0; }
main.c: In function 'main': main.c:19:32: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration] 19 | minx = min(minx, a[loop2]); | ^~~ | main
s230371911
p03987
C++
#include <iostream> #include <thread> #include <vector> using namespace std; int main(int argc, char const *argv[]) { int N; cin >> N; vector<int> v; for(int i = 0; i < N; i++) { int t; cin >> t; v.push_back(t); } atomic<unsigned long long> total(0); int tr = 0; thread a = thread([&]{ for(int i = 0; i < N / 2; i++) { int r = i - 1, l = i + 1; if(i != 0 && v[r] > v[i]) r = tr; while(r != -1 && v[r] > v[i]) { r--; } while(l != N && v[l] > v[i]) { l++; } tr = r; total += (unsigned long long)(i - r) * (l - i) * v[i]; } }); thread b = thread([&]{ for(int i = N / 2; i < N; i++) { int r = i - 1, l = i + 1; if(i != 0 && v[r] > v[i]) r = tr; while(r != -1 && v[r] > v[i]) { r--; } while(l != N && v[l] > v[i]) { l++; } tr = r; total += (unsigned long long)(i - r) * (l - i) * v[i]; } }); cout << total << endl; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:19:3: error: 'atomic' was not declared in this scope 19 | atomic<unsigned long long> total(0); | ^~~~~~ a.cc:4:1: note: 'std::atomic' is defined in header '<atomic>'; this is probably fixable by adding '#include <atomic>' 3 | #include <vector> +++ |+#include <atomic> 4 | a.cc:19:10: error: expected primary-expression before 'unsigned' 19 | atomic<unsigned long long> total(0); | ^~~~~~~~ a.cc: In lambda function: a.cc:34:7: error: 'total' was not declared in this scope 34 | total += (unsigned long long)(i - r) * (l - i) * v[i]; | ^~~~~ a.cc: In lambda function: a.cc:50:7: error: 'total' was not declared in this scope 50 | total += (unsigned long long)(i - r) * (l - i) * v[i]; | ^~~~~ a.cc: In function 'int main(int, const char**)': a.cc:54:11: error: 'total' was not declared in this scope 54 | cout << total << endl; | ^~~~~
s013309269
p03987
C++
#include <iostream> #include <array> #include <vector> #include <map> #include <utility> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <queue> #include <stack> #include <deque> #include <set> #include <string> #include <limits> using namespace std; int n_; int n; //int height; int *pt; void makeTable(int size_){ int size=1; while(size < size_) size*=2; pt = new int [2*size-1]; for (int i = 0; i < 2*size-1; i++) { pt[i] = INT_MAX; } n = size; } void load(int index, int val){ int index2 = index + n -1; pt[index2] = val; while (index2 > 0) { index2 = (index2-1)/2; pt[index2] = min(pt[index2 * 2 +1], pt[2*index2 + 2]); } } int getMin(int start, int end,int k, int l, int r){ if (end <= l || r <= start) { return INT_MAX; } if (start <= l && r <= end) { return pt[k]; }else{ int rl = getMin(start, end, 2*k+1, l, (l+r)/2); int rr = getMin(start, end, 2*k+2, (l+r)/2, r); return min(rl, rr); } } int main(int argc, const char * argv[]) { cin >>n_; makeTable(n_); for (int i = 0 ; i < n_; i ++) { int a; cin >>a; load(i, a); } long long sum = 0; for (int i = 0 ; i < n_; i++) { for (int j = i; j < n_; j++) { int min =getMin(i, j+1, 0, 0, n); sum +=min; } } cout << sum <<endl; return 0; }
a.cc: In function 'void makeTable(int)': a.cc:30:17: error: 'INT_MAX' was not declared in this scope 30 | pt[i] = INT_MAX; | ^~~~~~~ a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 13 | #include <set> +++ |+#include <climits> 14 | #include <string> a.cc: In function 'int getMin(int, int, int, int, int)': a.cc:46:16: error: 'INT_MAX' was not declared in this scope 46 | return INT_MAX; | ^~~~~~~ a.cc:46:16: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s777561867
p03987
C++
#include <iostream> #include <array> #include <vector> #include <map> #include <utility> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <queue> #include <stack> #include <deque> #include <set> #include <string> using namespace std; int n_; int n; int height; vector<int> st; int *pt; void makeTable(int size_){ int size=1; while(size < size_) size*=2; pt = new int [2*size-1]; for (int i = 0; i < 2*size-1; i++) { pt[i] = INT_MAX; } n = size; } void load(int index, int val){ int index2 = index + n -1; pt[index2] = val; while (index2 > 0) { index2 = (index2-1)/2; pt[index2] = min(pt[index2 * 2 +1], pt[2*index2 + 2]); } } int getMin(int start, int end,int k, int l, int r){ if (end <= l || r <= start) { return INT_MAX; } if (start <= l && r <= end) { return pt[k]; }else{ int rl = getMin(start, end, 2*k+1, l, (l+r)/2); int rr = getMin(start, end, 2*k+2, (l+r)/2, r); return min(rl, rr); } } long long getSum(){ makeTable(n_); for (int i = 0 ; i < n_; i ++) { load(i, st[i]); } // for (int i = 0 ; i < 2*n ; i ++) { // cout << pt[i] <<endl; // } long long sum = 0; for (int i = 0 ; i < n_; i++) { for (int j = i; j < n_; j++) { int min =getMin(i, j+1, 0, 0, n); // cout << "min;" << i << " " << j <<" " << min << endl; sum +=min; } } return sum; } int main(int argc, const char * argv[]) { cin >>n_; int a; for (int i = 0; i<n_; i++) { cin >>a; st.push_back(a); } cout << getSum() <<endl; return 0; }
a.cc: In function 'void makeTable(int)': a.cc:31:17: error: 'INT_MAX' was not declared in this scope 31 | pt[i] = INT_MAX; | ^~~~~~~ a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 13 | #include <set> +++ |+#include <climits> 14 | #include <string> a.cc: In function 'int getMin(int, int, int, int, int)': a.cc:47:16: error: 'INT_MAX' was not declared in this scope 47 | return INT_MAX; | ^~~~~~~ a.cc:47:16: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s668521122
p03987
C++
#include<iostream> #include<string> #include<cstring> #include<cstdio> #include<cmath> #include <utility> #include<cstdlib> #include<vector> #include<set> #include<map> #include<list> #include<queue> #include<functional> #include<algorithm> #define ms0(a) memset(a,0,sizeof(a)) #define ms1(a) memset(a,-1,sizeof(a)) #define pb(a) push_back(a) using namespace std; //typedef long long ll; typedef __int64 ll; const double Eps = (double)0.5; const int M = 1e9 + 7; const int N = 2e5+ 5 ; const double PI = acos(-1.0); int a[N]; int pos[N]; int STEP; int c[N]; int lowbit(int x) { return x&(-x); } void update(int i, int x) { while(i <= STEP) { c[i] += x; i += lowbit(i); } } int getsum( int x ) { int sum = 0; while( x > 0 ) { sum += c[x]; x -= lowbit(x); } return sum; } int getl( int step ) { int l = 0, r = step - 1, mid; int sm = getsum(step); while(l <= r) { mid = (l + r)/2; if( sm - getsum(mid) == 1) r = mid - 1; else l = mid + 1; } return l + 1; } int getr( int step ) { int l = step, r = STEP, mid; int sm = getsum(step); while(l <= r) { mid = (l + r)/2; if(getsum(mid) - sm == 0) l = mid + 1; else r = mid - 1; } return l - 1; } int main() { int n; cin>>n; for(int i=1; i<=n; i++) { scanf("%d",&a[i]); pos[a[i]] = i; } STEP = n; ll asr = 0; for(int i=1; i<=n; i++) { update(pos[i], 1); int l = getl(pos[i]); int r = getr(pos[i]); asr += (ll)(pos[i] - l) * (r - pos[i]) * i; asr += (pos[i] - l + 1 + r - pos[i]) * i; } printf("%I64d\n",asr); //cout<<asr<<endl; return 0; }
a.cc:20:9: error: '__int64' does not name a type; did you mean '__int64_t'? 20 | typedef __int64 ll; | ^~~~~~~ | __int64_t a.cc: In function 'int main()': a.cc:99:5: error: 'll' was not declared in this scope 99 | ll asr = 0; | ^~ a.cc:105:9: error: 'asr' was not declared in this scope 105 | asr += (ll)(pos[i] - l) * (r - pos[i]) * i; | ^~~ a.cc:108:22: error: 'asr' was not declared in this scope 108 | printf("%I64d\n",asr); | ^~~
s570387548
p03987
C++
//C++14 (Clang 3.8.0) #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <string> #define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i) using namespace std; typedef long long ll; using namespace std; class RMQ{ private: static const int MAX_N = 1 << 17; int n, dat[2*MAX_N -1]; int rec(int a,int b,int k,int l,int r){ if(b <= l || r <= a){ return INT_MAX; } if(a<=l && r<=b){ return dat[k]; }else{ int rl = rec(a,b,2*k+1,l,(l+r)/2); int rr = rec(a,b,2*k+2,(l+r)/2,r); return min(rl,rr); } } public: void init(int n_){ n=1; while(n < n_) n*=2; for(int i=0;i<2*n-1;i++){ dat[i] = INT_MAX; } } //kをaに変更 void update(int k, int a){ int reaf = k+n-1; dat[reaf]=a; while(reaf>0){ reaf = (reaf-1)/2; dat[reaf]=min(dat[reaf*2+1],dat[2*reaf+2]); } } //query[a,b]の範囲内の最小値を返す int query(int a,int b){ return rec(a,b+1,0,0,n); } }; int main(){ int N; vector<int> a; cin>>N; rp(i,0,N){int A;cin>>A;a.push_back(A);} int ans=0; RMQ r; r.init(200001); rp(i,0,N) r.update(i,a[i]); rp(i,0,N){ rp(j,i,N){ //int min=200001; //rp(k,i,j+1) {if(min>a[k]) min=a[k];} int min=r.query(i,j); rp(k,i,j+1) cout<<a[k]<<" "; cout<<"min"<<min; cout<<endl; min=r.query(i,j); ans+=min; } } cout<<ans<<endl; return 0; };
a.cc: In member function 'int RMQ::rec(int, int, int, int, int)': a.cc:37:16: error: 'INT_MAX' was not declared in this scope 37 | return INT_MAX; | ^~~~~~~ a.cc:22:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 21 | #include <ctime> +++ |+#include <climits> 22 | #include <string> a.cc: In member function 'void RMQ::init(int)': a.cc:55:16: error: 'INT_MAX' was not declared in this scope 55 | dat[i] = INT_MAX; | ^~~~~~~ a.cc:55:16: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s535175989
p03987
C++
#include <string> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <queue> #include <iostream> #include <sstream> #include <cstdio> #include <cmath> #include <ctime> #include <cstring> #include <cctype> #include <cassert> #include <limits> #include <functional> #include <complex> #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL-1 double EPS=1e-9; using namespace std; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll; typedef complex<double> P; template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; } int n; vector<ll> a; const int BT = 1 << 18 ; struct segtree {//BT = size vector<int> seg; void init() { seg.resize(BT * 2); rep(i, BT * 2 - 1) seg[i] = INT_MAX; } void add(int pos, int x) {//posにxを追加,0-index nodeも0-index pos += BT - 1; seg[pos] = x; while (pos > 0) { pos = (pos - 1) / 2; seg[pos] = min(seg[pos * 2 + 1], seg[pos * 2 + 2]); } } int minQ(int a, int b, int k = 0, int l = 0, int r = BT) {//[a,b)に対するクエリ if (b <= l || r <= a) return INT_MAX;//交差しない if (a <= l && r <= b) return seg[k];//被覆する return min(minQ(a, b, k * 2 + 1, l, (l + r) / 2), minQ(a, b, k * 2 + 2, (l + r) / 2, r)); } }segm; int main(){ cin>>n; int x; segm.init(); for(int i=0;i<n;i++){ cin>>x; a.pb((ll)x); segm.add(i,x); } ll ans=0; //cout<<segm.minQ(0,1)<<endl; for(int i=0;i<n;i++){ int l=0,r=n,p=i,q=i; int cnt=25; while(cnt--){ int rmid=(q+r)/2,lmid=(l+p)/2; if(segm.minQ(i,rmid+1)<a[i]){ r=rmid; }else{ q=rmid; } if(segm.minQ(lmid,i+1)<a[i]){ l=lmid; }else{ p=lmid; } } //cout<<p<<" "<<r<<endl; ll R,L; R=(ll)(r-i); L=(ll)(i-p+1); ans+=R*L*a[i]; } cout<<ans<<endl; } /*3 5 0 3 0 1 1 1 2 1 2 3 2 0 2 3 1 3 2*/
a.cc: In member function 'void segtree::init()': a.cc:48:37: error: 'INT_MAX' was not declared in this scope 48 | rep(i, BT * 2 - 1) seg[i] = INT_MAX; | ^~~~~~~ a.cc:19:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 18 | #include <complex> +++ |+#include <climits> 19 | #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) a.cc: In member function 'int segtree::minQ(int, int, int, int, int)': a.cc:62:46: error: 'INT_MAX' was not declared in this scope 62 | if (b <= l || r <= a) return INT_MAX;//交差しない | ^~~~~~~ a.cc:62:46: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s535074602
p03987
C++
#include <vector> #include <cassert> #include <algorithm> #ifdef _WIN32 inline unsigned int __builtin_clz(unsigned int x) { unsigned long r; _BitScanReverse(&r, x); return 31 - r; } #endif template<class Type> class SparseTable { private: std::vector<std::vector<Type> > st; public: void init(std::vector<Type> v) { int b = 0; for (; (1 << b) <= v.size(); b++); st.assign(b, std::vector<Type>(1 << b)); for (int i = 0; i < v.size(); i++) st[0][i] = v[i]; for (int i = 1; i < b; i++) { for (int j = 0; j + (1 << i) <= (1 << b); j++) { st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); } } } Type query(int l, int r) { assert(l < r); int b = 32 - __builtin_clz(r - l) - 1; return std::min(st[b][l], st[b][r - (1 << b)]); } SparseTable() {} SparseTable(std::vector<Type> v) { init(v); } }; #include <iostream> #include <algorithm> using namespace std; int n; vector<int> a; int main() { cin >> n; a.resize(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> b(a); reverse(b.begin(), b.end()); SparseTable<int> st(a), st2(b); vector<int> p(n), q(n); for (int i = 0; i < n; i++) { int l = 0, r = i + 1; while (r - l > 1) { int m = (l + r) / 2; if (st.query(m, i + 1) != a[i]) l = m; else r = m; } if(st.query(l, i + 1) == a[i]) p[i] = l; else p[i] = r; } for (int i = 0; i < n; i++) { int l = 0, r = i + 1; while (r - l > 1) { int m = (l + r) / 2; if (st2.query(m, i + 1) != b[i]) l = m; else r = m; } if (st2.query(l, i + 1) == b[i]) q[n - i - 1] = n - l; else q[n - i - 1] = n - r; } long long ret = 0; for (int i = 0; i < n; i++) ret += 1LL * (i - p[i] + 1) * (q[i] - i) * a[i]; cout << ret << endl; return 0; }
a.cc: In instantiation of 'void SparseTable<Type>::init(std::vector<Type>) [with Type = int]': a.cc:34:37: required from 'SparseTable<Type>::SparseTable(std::vector<Type>) [with Type = int]' 34 | SparseTable(std::vector<Type> v) { init(v); } | ^~~~ a.cc:45:23: required from here 45 | SparseTable<int> st(a), st2(b); | ^ a.cc:24:47: error: 'min' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] 24 | st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' declared here, later in the translation unit 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~
s925644664
p03987
C
#include <stdio.h> int N, a[212345], tmp = 0; __int64 ans; int main(void) { scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d", &a[i]); } for (int l = 0; l < N; ++l) { for (int r = l; r < N; ++r) { for (int i = l; i <= r; ++i) { if (i == l) { tmp = a[i]; } if (tmp > a[i]) { tmp = a[i]; } } ans += tmp; } } printf("%I64d", ans); return 0; }
main.c:4:1: error: unknown type name '__int64'; did you mean '__int64_t'? 4 | __int64 ans; | ^~~~~~~ | __int64_t
s105069073
p03987
C
#include <stdio.h> #include <algorithm> using namespace std; int N, a[212345], tmp = 0; __int64 ans; int main(void) { scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d", &a[i]); } for (int l = 0; l < N; ++l) { for (int r = l; r < N; ++r) { for (int i = l; i <= r; ++i) { if (i == l) { tmp = a[i]; } if (tmp > a[i]) { tmp = a[i]; } } ans += tmp; } } printf("%I64d", ans); return 0; }
main.c:2:10: fatal error: algorithm: No such file or directory 2 | #include <algorithm> | ^~~~~~~~~~~ compilation terminated.
s007165483
p03987
C++
#include <iostream> #include <vector> #include <cmath> using namespace std; const long long int MAX_N = 1<<17; long long int n, dat[2*MAX_N-1]; void init(long long int n_) { n = 1; while (n < n_) n *= 2; for (long long int i = 0; i < 2*n-1; i++) dat[i] = INT_MAX; } void update(long long int k, long long int a) { k += n-1; dat[k] = a; while (k > 0) { k = (k-1)/2; dat[k] = min(dat[k*2+1], dat[k*2+2]); } } long long int query(long long int a, long long int b, long long int k, long long int l, long long int r) { if (r <= a || b <= l) return INT_MAX; if (a <= l && r <= b) return dat[k]; else { long long int vl = query(a, b, k*2+1, l, (l+r)/2); long long int vr = query(a, b, k*2+2, (l+r)/2, r); return min(vl, vr); } } int main() { long long int nn; cin >> nn; init(nn); long long int a; for (long long int i = 0; i < nn; i++) { cin >> a; update(i, a); } long long int sum = 0; /*for (long long int i = 0; i < 8; i++) { cout << dat[i] << endl; }*/ for (long long int i = 0; i < nn; i++) { for (long long int j = i; j < nn; j++) { sum += query(i, j+1, 0, 0, n); //cout << i << ' ' << j << ' ' << query(i, j, 0, 0, n) << endl; } } cout << sum << endl; return 0; }
a.cc: In function 'void init(long long int)': a.cc:15:60: error: 'INT_MAX' was not declared in this scope 15 | for (long long int i = 0; i < 2*n-1; i++) dat[i] = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <cmath> +++ |+#include <climits> 4 | a.cc: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)': a.cc:28:38: error: 'INT_MAX' was not declared in this scope 28 | if (r <= a || b <= l) return INT_MAX; | ^~~~~~~ a.cc:28:38: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s923814799
p03987
C
#include<stdio.h> #define min(x, y) ((x > y)? y : x) int a[200000]; int N; void hoge(void){ int i; for(i = 0; i < N - 1; i++) a[i] = min(a[i], a[i+1]); N--; } int main(void){ __int64 ans = 0; int i; scanf("%ld", &N); for(i = 0; i < N; i++){ scanf("%ld", &(a[i])); } while(N >= 2){ for(i = 0; i < N; i++) ans += a[i]; hoge(); } printf("%I64d\n", ans + a[0]); return 0; }
main.c: In function 'main': main.c:18:5: error: unknown type name '__int64'; did you mean '__int64_t'? 18 | __int64 ans = 0; | ^~~~~~~ | __int64_t
s025740027
p03987
C++
/*input 8 5 4 8 1 2 6 7 3 */ #include <bits/stdc++.h> #include <stdio.h> #include <string.h> using namespace std; #define mod 1000000007 #define llu long long unsigned #define lld long long #define ld long #define sc(a) scanf("%lld",&a) #define sc2(a,b) scanf("%lld%lld",&a,&b) #define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define scf(a) scanf("%lf",&a) #define scf2(a,b) scanf("%lf%lf",&a,&b) #define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c) #define prL(a) printf("%lld\n",a) #define prS(a) printf("%lld ",a) #define prfL(a) printf("%lf\n",a) #define prfS(a) printf("%lf ",a) // #define swap(a,b,t) t=a;a=b;b=t #define PA pair <lld,pair<lld,lld> > #define lim 1000003 #define lim2 1005 lld A[lim],C[lim],nextP[lim],prev[lim],D[lim]; typedef struct node{ long long val; long long p; }nody; bool comp(nody i,nody j) { return i.val<j.val; } nody N[lim]; // lld bina1(lld A[],lld k,lld low,lld high){ // lld mid; // while(low<=high){ // mid=low+(high-low)/2; // if(A[mid]==k){ // if(mid==0) return C[0]; // else return C[mid]-C[mid-1]; // } // else if(A[mid]>k) high=mid-1; // else low=mid+1; // } // return 0; // } // lld bina2(lld A[],lld k,lld low,lld high){ // lld mid; // while(high-low>1){ // mid=low+(high-low)/2; // if(A[mid]<k) low=mid; // else high=mid-1; // } // if(A[high]<k) return C[high]; // else if(A[low]<k) return C[low]; // else return 0; // } // lld bina3(lld A[],lld k,lld low,lld high){ // lld mid; // while(high-low>1){ // mid=low+(high-low)/2; // if(A[mid]>k) high=mid; // else low=mid+1; // } // if(A[low]>k) return D[low]; // else if(A[high]>k) return D[high]; // else return 0; // } int main(){ lld t,T,i,h,k,j,pos,ans,count,sum,m,q,r,n,p,a,b; sc(n); for(i=0;i<n;i++){ sc(A[i]); A[i]=-A[i]; } stack<pair<lld,lld> > S; pair<lld,lld> P; S.push(make_pair(A[0],0)); for(i=1;i<n;i++){ if(S.empty()){ S.push(make_pair(A[i],i)); continue; } P=S.top(); if(P.first>A[i]) S.push(make_pair(A[i],i)); else{ nextP[P.second]=i; S.pop(); i--; } } while(!S.empty()){ P=S.top(); nextP[P.second]=n; S.pop(); } S.push(make_pair(A[n-1],n-1)); for(i=n-2;i>=0;i--){ if(S.empty()){ S.push(make_pair(A[i],i)); continue; } P=S.top(); if(P.first>=A[i]) S.push(make_pair(A[i],i)); else{ prev[P.second]=i; S.pop(); i++; } } while(!S.empty()){ P=S.top(); prev[P.second]=-1; S.pop(); } ans=0; for(i=0;i<n;i++){ lld a,b; // if(prev[i]==-1) a=i; // else a=i-prev[i]; // if(nextP[i]==n) b=n-1-i; // else b=nextP[i]-i+1; ans+=-A[i]*(nextP[i]-i)*(i-prev[i]); // ans+=-A[i]*a*b; // printf("ans=%lld i=%lld prev=%lld nextP=%lld\n",ans,i,a,b ); } prL(ans); // for(i=0;i<n;i++){ // N[i].val=A[i]; // N[i].p=(nextP[i]-i)*(i-prev[i]); // } // sort(N,N+n,comp); // A[0]=N[0].val; // C[0]=N[0].p; // k=1; // for(i=1;i<n;i++){ // if(N[i].val!=N[i-1].val){ // A[k]=N[i].val; // C[k]=N[i].p; // k++; // } // else C[k-1]+=N[i].p; // } // for(i=0;i<k;i++) D[i]=C[i]; // for(i=1;i<k;i++) C[i]=C[i]+C[i-1]; // for(i=k-2;i>=0;i--) D[i]=D[i]+D[i+1]; // // printf("%lld\n", k); // // for(i=0;i<k;i++) printf("%lld %lld\n",A[i],C[i]); // char play,rule,c1; // lld moveP; // scanf("%c",&c1); // while(m--){ // scanf("%c%lld\n",&play,&moveP ); // if(play=='='){ // ans=bina1(A,moveP,0,k-1); // // printf("%lld(%c)\n", ans,play); // } // else if(play=='>'){ // ans=bina3(A,moveP,0,k-1); // // printf("%lld(%c)\n", ans,play); // } // else{ // ans=bina2(A,moveP,0,k-1); // // printf("%lld(%c)\n", ans,play); // } // scanf("%c\n",&rule ); // // printf("\n%c[%c]\n",play,rule ); // if(ans%2==0) printf("%c",'C'+'D'-rule); // else printf("%c",rule ); // } return 0; }
a.cc: In function 'int main()': a.cc:116:13: error: reference to 'prev' is ambiguous 116 | prev[P.second]=i; | ^~~~ 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:6: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:30:30: note: 'long long int prev [1000003]' 30 | lld A[lim],C[lim],nextP[lim],prev[lim],D[lim]; | ^~~~ a.cc:123:9: error: reference to 'prev' is ambiguous 123 | prev[P.second]=-1; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:30:30: note: 'long long int prev [1000003]' 30 | lld A[lim],C[lim],nextP[lim],prev[lim],D[lim]; | ^~~~ a.cc:133:44: error: reference to 'prev' is ambiguous 133 | ans+=-A[i]*(nextP[i]-i)*(i-prev[i]); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:30:30: note: 'long long int prev [1000003]' 30 | lld A[lim],C[lim],nextP[lim],prev[lim],D[lim]; | ^~~~
s263650840
p03987
C++
/*input 8 5 4 8 1 2 6 7 3 */ #include <bits/stdc++.h> #include <stdio.h> #include <string.h> using namespace std; #define mod 1000000007 #define llu long long unsigned #define lld long long #define ld long #define sc(a) scanf("%lld",&a) #define sc2(a,b) scanf("%lld%lld",&a,&b) #define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define scf(a) scanf("%lf",&a) #define scf2(a,b) scanf("%lf%lf",&a,&b) #define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c) #define prL(a) printf("%lld\n",a) #define prS(a) printf("%lld ",a) #define prfL(a) printf("%lf\n",a) #define prfS(a) printf("%lf ",a) // #define swap(a,b,t) t=a;a=b;b=t #define PA pair <lld,pair<lld,lld> > #define lim 1000003 #define lim2 1005 lld A[lim],C[lim],next[lim],prev[lim],D[lim]; typedef struct node{ long long val; long long p; }nody; bool comp(nody i,nody j) { return i.val<j.val; } nody N[lim]; // lld bina1(lld A[],lld k,lld low,lld high){ // lld mid; // while(low<=high){ // mid=low+(high-low)/2; // if(A[mid]==k){ // if(mid==0) return C[0]; // else return C[mid]-C[mid-1]; // } // else if(A[mid]>k) high=mid-1; // else low=mid+1; // } // return 0; // } // lld bina2(lld A[],lld k,lld low,lld high){ // lld mid; // while(high-low>1){ // mid=low+(high-low)/2; // if(A[mid]<k) low=mid; // else high=mid-1; // } // if(A[high]<k) return C[high]; // else if(A[low]<k) return C[low]; // else return 0; // } // lld bina3(lld A[],lld k,lld low,lld high){ // lld mid; // while(high-low>1){ // mid=low+(high-low)/2; // if(A[mid]>k) high=mid; // else low=mid+1; // } // if(A[low]>k) return D[low]; // else if(A[high]>k) return D[high]; // else return 0; // } int main(){ lld t,T,i,h,k,j,pos,ans,count,sum,m,q,r,n,p,a,b; sc(n); for(i=0;i<n;i++){ sc(A[i]); A[i]=-A[i]; } stack<pair<lld,lld> > S; pair<lld,lld> P; S.push(make_pair(A[0],0)); for(i=1;i<n;i++){ if(S.empty()){ S.push(make_pair(A[i],i)); continue; } P=S.top(); if(P.first>A[i]) S.push(make_pair(A[i],i)); else{ next[P.second]=i; S.pop(); i--; } } while(!S.empty()){ P=S.top(); next[P.second]=n; S.pop(); } S.push(make_pair(A[n-1],n-1)); for(i=n-2;i>=0;i--){ if(S.empty()){ S.push(make_pair(A[i],i)); continue; } P=S.top(); if(P.first>=A[i]) S.push(make_pair(A[i],i)); else{ prev[P.second]=i; S.pop(); i++; } } while(!S.empty()){ P=S.top(); prev[P.second]=-1; S.pop(); } ans=0; for(i=0;i<n;i++){ lld a,b; // if(prev[i]==-1) a=i; // else a=i-prev[i]; // if(next[i]==n) b=n-1-i; // else b=next[i]-i+1; ans+=-A[i]*(next[i]-i)*(i-prev[i]); // ans+=-A[i]*a*b; // printf("ans=%lld i=%lld prev=%lld next=%lld\n",ans,i,a,b ); } prL(ans); // for(i=0;i<n;i++){ // N[i].val=A[i]; // N[i].p=(next[i]-i)*(i-prev[i]); // } // sort(N,N+n,comp); // A[0]=N[0].val; // C[0]=N[0].p; // k=1; // for(i=1;i<n;i++){ // if(N[i].val!=N[i-1].val){ // A[k]=N[i].val; // C[k]=N[i].p; // k++; // } // else C[k-1]+=N[i].p; // } // for(i=0;i<k;i++) D[i]=C[i]; // for(i=1;i<k;i++) C[i]=C[i]+C[i-1]; // for(i=k-2;i>=0;i--) D[i]=D[i]+D[i+1]; // // printf("%lld\n", k); // // for(i=0;i<k;i++) printf("%lld %lld\n",A[i],C[i]); // char play,rule,c1; // lld moveP; // scanf("%c",&c1); // while(m--){ // scanf("%c%lld\n",&play,&moveP ); // if(play=='='){ // ans=bina1(A,moveP,0,k-1); // // printf("%lld(%c)\n", ans,play); // } // else if(play=='>'){ // ans=bina3(A,moveP,0,k-1); // // printf("%lld(%c)\n", ans,play); // } // else{ // ans=bina2(A,moveP,0,k-1); // // printf("%lld(%c)\n", ans,play); // } // scanf("%c\n",&rule ); // // printf("\n%c[%c]\n",play,rule ); // if(ans%2==0) printf("%c",'C'+'D'-rule); // else printf("%c",rule ); // } return 0; }
a.cc: In function 'int main()': a.cc:97:13: error: reference to 'next' is ambiguous 97 | next[P.second]=i; | ^~~~ 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:6: /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:30:19: note: 'long long int next [1000003]' 30 | lld A[lim],C[lim],next[lim],prev[lim],D[lim]; | ^~~~ a.cc:104:9: error: reference to 'next' is ambiguous 104 | next[P.second]=n; | ^~~~ /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:30:19: note: 'long long int next [1000003]' 30 | lld A[lim],C[lim],next[lim],prev[lim],D[lim]; | ^~~~ a.cc:116:13: error: reference to 'prev' is ambiguous 116 | prev[P.second]=i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:30:29: note: 'long long int prev [1000003]' 30 | lld A[lim],C[lim],next[lim],prev[lim],D[lim]; | ^~~~ a.cc:123:9: error: reference to 'prev' is ambiguous 123 | prev[P.second]=-1; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:30:29: note: 'long long int prev [1000003]' 30 | lld A[lim],C[lim],next[lim],prev[lim],D[lim]; | ^~~~ a.cc:133:29: error: reference to 'next' is ambiguous 133 | ans+=-A[i]*(next[i]-i)*(i-prev[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:30:19: note: 'long long int next [1000003]' 30 | lld A[lim],C[lim],next[lim],prev[lim],D[lim]; | ^~~~ a.cc:133:43: error: reference to 'prev' is ambiguous 133 | ans+=-A[i]*(next[i]-i)*(i-prev[i]); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)' 244 | prev(_BidirectionalIterator __x, typename | ^~~~ a.cc:30:29: note: 'long long int prev [1000003]' 30 | lld A[lim],C[lim],next[lim],prev[lim],D[lim]; | ^~~~
s976352248
p03987
C++
#include<iostream> using namespace std; int main() { int n; cin>>n; int Array[n]; for(int i=0;i<n;i++) cin>>Array[i]; long long ans=0; for(int i=0;i<n;i++) { int x=INT_MAX; for(int j=i;j<n;j++) { x=min(x,Array[j]); ans+=x; } } cout<<ans<<"\n"; }
a.cc: In function 'int main()': a.cc:13:23: error: 'INT_MAX' was not declared in this scope 13 | int x=INT_MAX; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s687325364
p03987
C++
3#define DINGER_GISBAR #include <bits/stdc++.h> using namespace std; const long long MOD = static_cast<int>(1e9) + 7; //{{{TEMPLATE_BEGIN #include <unistd.h> using namespace std::rel_ops; #ifdef ZEROKUGI #include <dumper.hpp> #define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1) #define tick(...) dumper::tick(__VA_ARGS__) #pragma message "Compiling " __FILE__ #else #define dump(x) #define tick(...) #endif typedef long long lint; typedef unsigned long long ulint; typedef long double ldouble; typedef vector<int> vint; #define rep(i, n) \ for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++) #define all(c) begin(c), end(c) #define perm(c) \ sort(all(c)); \ for (bool c##p = 1; c##p; c##p = next_permutation(all(c))) #define uniquenize(v) (v).erase(unique(all(v)), end(v)) #define cauto const auto & #define memset(x, y) memset(x, y, sizeof(x)) #define popcount __builtin_popcount #define gcd __gcd inline lint bit(int x) { return 1LL << x; } template <class T> inline int size(const T& a) { return (int)a.size(); } template <class T> inline bool chmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <class T> inline int clamp(T v, T lo, T hi) { return (v > hi) - (v < lo); } template <class T> inline bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template <class T> inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) { return make_pair(v, c); } template <class T> inline istream& operator>>(istream& is, vector<T>& v) { #ifdef ZEROKUGI if (v.empty()) { cerr << "Error L" << __LINE__ << ": vector size is zero." << endl; exit(EXIT_FAILURE); } #endif for (auto& x : v) is >> x; return is; } template <class T> inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) { bool t = 0; for (const T& x : v.first) { if (t) os << v.second; os << x; t = 1; } return os; } template <class T> inline ostream& operator<<(ostream& os, vector<T>& v) { return os << v * ' '; } struct before_main { before_main() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); tick(0, 0); }; } __before_main; //}}}TEMPLATE_END int idx[202020]; int main() { int n; cin >> n; vector<int> a(n); cin >> a; rep(i, n){ idx[a[i]] = i; } lint ans = 0; set<int> S; S.insert(-1); S.insert(n); for(int x = 1; x <= n; x++){ int i = idx[x]; auto it = S.lower_bound(i); auto itt = prev(it); lint l = i - *itt; lint r = *it - i; ans += x * l * r; S.insert(i); } cout << ans << endl; }
a.cc:1:2: error: stray '#' in program 1 | 3#define DINGER_GISBAR | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3#define DINGER_GISBAR | ^ 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: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'; 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 [-fpermiss
s853636757
p03988
C++
#include <algorithm>    //STL 通用算法 #include <bitset>     //STL 位集容器 #include <cctype> //字符处理 #include <cerrno>      //定义错误码 #include <cfloat>     //浮点数处理 #include <ciso646> //对应各种运算符的宏 #include <climits>     //定义各种数据类型最值的常量 #include <clocale>     //定义本地化函数 #include <cmath>      //定义数学函数 #include <complex>     //复数类 #include <csignal> //信号机制支持 #include <csetjmp> //异常处理支持 #include <cstdarg> //不定参数列表支持 #include <cstddef> //常用常量 #include <cstdio>      //定义输入/输出函数 #include <cstdlib>     //定义杂项函数及内存分配函数 #include <cstring>     //字符串处理 #include <ctime>      //定义关于时间的函数 #include <cwchar>      //宽字符处理及输入/输出 #include <cwctype>     //宽字符分类 #include <deque>      //STL 双端队列容器 #include <exception>    //异常处理类 #include <fstream>     //文件输入/输出 #include <functional>   //STL 定义运算函数(代替运算符) #include <limits>      //定义各种数据类型最值常量 #include <list>      //STL 线性列表容器 #include <locale> //本地化特定信息 #include <map>       //STL 映射容器 #include <memory> //STL通过分配器进行的内存分配 #include<new> //动态内存分配 #include <numeric> //STL常用的数字操作 #include <iomanip>     //参数化输入/输出 #include <ios>       //基本输入/输出支持 #include <iosfwd>     //输入/输出系统使用的前置声明 #include <iostream>    //数据流输入/输出 #include <istream>     //基本输入流 #include <iterator> //STL迭代器 #include <ostream>     //基本输出流 #include <queue>      //STL 队列容器 #include <set>       //STL 集合容器 #include <sstream>     //基于字符串的流 #include <stack>      //STL 堆栈容器 #include <stdexcept>    //标准异常类 #include <streambuf>    //底层输入/输出支持 #include <string>     //字符串类 #include <typeinfo> //运行期间类型信息 #include <utility>     //STL 通用模板类 #include <valarray> //对包含值的数组的操作 #include <vector>     //STL 动态数组容器 #define ll long long using namespace std; const int N=1000010; ll n,x,mx; ll c[N]; int main(){ scanf("%d",&n); for(int i = 1; i <= n; i++) { scanf("%d",&x); ++c[x]; mx=max(mx,x); } int mi = (mx + 1) >> 1; for(int i = mx; i > mi; --i) { if(c[i] < 2) return puts("Impossible"), 0; n -= c[i]; } if(c[mi] != 1 + (mx & 1) || n != c[mi]) return puts("Impossible"), 0; puts("Possible"); }#include <algorithm>    //STL 通用算法 #include <bitset>     //STL 位集容器 #include <cctype> //字符处理 #include <cerrno>      //定义错误码 #include <cfloat>     //浮点数处理 #include <ciso646> //对应各种运算符的宏 #include <climits>     //定义各种数据类型最值的常量 #include <clocale>     //定义本地化函数 #include <cmath>      //定义数学函数 #include <complex>     //复数类 #include <csignal> //信号机制支持 #include <csetjmp> //异常处理支持 #include <cstdarg> //不定参数列表支持 #include <cstddef> //常用常量 #include <cstdio>      //定义输入/输出函数 #include <cstdlib>     //定义杂项函数及内存分配函数 #include <cstring>     //字符串处理 #include <ctime>      //定义关于时间的函数 #include <cwchar>      //宽字符处理及输入/输出 #include <cwctype>     //宽字符分类 #include <deque>      //STL 双端队列容器 #include <exception>    //异常处理类 #include <fstream>     //文件输入/输出 #include <functional>   //STL 定义运算函数(代替运算符) #include <limits>      //定义各种数据类型最值常量 #include <list>      //STL 线性列表容器 #include <locale> //本地化特定信息 #include <map>       //STL 映射容器 #include <memory> //STL通过分配器进行的内存分配 #include<new> //动态内存分配 #include <numeric> //STL常用的数字操作 #include <iomanip>     //参数化输入/输出 #include <ios>       //基本输入/输出支持 #include <iosfwd>     //输入/输出系统使用的前置声明 #include <iostream>    //数据流输入/输出 #include <istream>     //基本输入流 #include <iterator> //STL迭代器 #include <ostream>     //基本输出流 #include <queue>      //STL 队列容器 #include <set>       //STL 集合容器 #include <sstream>     //基于字符串的流 #include <stack>      //STL 堆栈容器 #include <stdexcept>    //标准异常类 #include <streambuf>    //底层输入/输出支持 #include <string>     //字符串类 #include <typeinfo> //运行期间类型信息 #include <utility>     //STL 通用模板类 #include <valarray> //对包含值的数组的操作 #include <vector>     //STL 动态数组容器 #define ll long long using namespace std; const int N=1000010; ll n,x,mx; ll c[N]; int main(){ scanf("%d",&n); for(int i = 1; i <= n; i++) { scanf("%d",&x); ++c[x]; mx=max(mx,x); } int mi = (mx + 1) >> 1; for(int i = mx; i > mi; --i) { if(c[i] < 2) return puts("Impossible"), 0; n -= c[i]; } if(c[mi] != 1 + (mx & 1) || n != c[mi]) return puts("Impossible"), 0; puts("Possible"); }
a.cc:1:10: error: extended character   is not valid in an identifier 1 | #include <algorithm>    //STL 通用算法 | ^ a.cc:1:10: error: extended character   is not valid in an identifier a.cc:1:10: error: extended character   is not valid in an identifier a.cc:1:10: fatal error: algorithm>  ��: No such file or directory 1 | #include <algorithm>    //STL 通用算法 | ^~~~~~~~~~~~~~~~~ compilation terminated.
s215925327
p03988
C++
#include<bits/stdc++.h> using namespace std; void ans(bool b) { cout << (b ? "Possible" : "Impossible") << endl; exit(0); } int main() { int64_t N; cin >> N; vector<int64_t> a(N); for (int64_t& A : a) { cin >> A; } int64_t one_num = count(a.begin(), a.end(), 1); if (one_num == 1) { //1のものが中心のスターグラフじゃないとダメ //1以外のものは全て2じゃないとおかしい //逆にそうであれば構築可能 int64_t two_num = count(a.begin(), a.end(), 2); ans(two_num == N - 1); } else if (one_num >= 2) { ans(N == 2); } int64_t max_value = *max_element(a.begin(), a.end()); int64_t max_num = count(a.begin(), a.end(), max_value); if (max_num == 1) { ans(false); } //ここまではとりあえず合っている //maxを両端にして一列に並べるようなものを考える int64_t min_value = (max_value + 1) / 2; int64_t ng_num = count_if(a.begin(), a.end(), [min_value](int64_t v) { v < min_value; }); if (ng_num > 0) { ans(false); } assert(false); }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_pred<_Predicate>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >; _Predicate = main()::<lambda(int64_t)>]': /usr/include/c++/14/bits/stl_algobase.h:2163:12: required from 'typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::__count_if(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Predicate = __gnu_cxx::__ops::_Iter_pred<main()::<lambda(int64_t)> >; typename iterator_traits< <template-parameter-1-1> >::difference_type = long int]' 2163 | if (__pred(__first)) | ~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4057:29: required from 'typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Predicate = main()::<lambda(int64_t)>; typename iterator_traits< <template-parameter-1-1> >::difference_type = long int]' 4057 | return std::__count_if(__first, __last, | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 4058 | __gnu_cxx::__ops::__pred_iter(__pred)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:38:30: required from here 38 | int64_t ng_num = count_if(a.begin(), a.end(), [min_value](int64_t v) { v < min_value; }); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:318:30: error: void value not ignored as it ought to be 318 | { return bool(_M_pred(*__it)); } | ~~~~~~~^~~~~~~
s521605620
p03988
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vec; typedef vector<vec> mat; typedef pair<ll,ll> pll; const ll mod=1e9+7; //const ll mod=998244353; const ll inf=1LL<<61; int main() { ll n; cin >> n; vec a(n); for(ll i=0;i<n;i++) cin >> a[i]; sort(a.begin(),a.end()); ll mx=a[n-1]; vec cnt(mx+1); for(ll i=0;i<n;i++) { cnt[a[i]]++; } ll f=1; for(ll i=0;i<=mx;i++) { if(cnt[i]&&i<mx/2) f=0; if(mx%2==0&&i==mx/2&&cnt[i]!=2) f=0; if(mx%2&&i=mx/2&&cnt[i]!=1) f=0; if(i>mx/2&&!cnt[i]) f=0; } if(f) cout << "Possible" << endl; else cout << "Impossible" << endl; }
a.cc: In function 'int main()': a.cc:26:12: error: lvalue required as left operand of assignment 26 | if(mx%2&&i=mx/2&&cnt[i]!=1) f=0; | ~~~~^~~
s827105941
p03988
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; using P = pair<int, int>; const int INF = 1e9; const long long LINF = 1e18; const long long MOD = 1e9 + 7; signed main() { int n; cin >> n; int mx = 0; int a[n]; rep(i, n) { cin >> a[i]; mx = max(mx, a[i]); } int mn = (mx + 1) / 2; sort(a, a + n); if (mx % 2 == 0) { if (a[0] != mn || a[1] == mn) { cout << "Impossible" << endl; return 0; } } else { if (a[0] != mn || a[1] != mn || a[2] == mn) { cout << "Impossible" << endl; return 0; } } int cnt[mx + 1] = {}; for (int i = (mx % 2 == 0 ? 1 : 2); i < n; i++) { cnt[a[i]]++; } for (int i = t + 1; i <= mx; i++){ if(cnt[i] < 2){ cout << "Impossible" << endl; return 0; } } cout << "Possible" << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:18: error: 't' was not declared in this scope 37 | for (int i = t + 1; i <= mx; i++){ | ^
s113831025
p03988
C++
#include <bits/stdc++.h> using namespace std; int o; int n, m; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> m; if (m == 1) o++; } if (o > 1 && n > 2) cout << "Impossible"; else cout << "Possible" return 0; }
a.cc: In function 'int main()': a.cc:18:23: error: expected ';' before 'return' 18 | cout << "Possible" | ^ | ; 19 | return 0; | ~~~~~~
s793307356
p03988
C++
#include <bits.stdc++.h> using namespace std; int main(){ int n; scanf("%d", &n); int arr[n+1]; for(int i = 0; i < n; i++){ scanf("%d", &arr[i]); } sort(arr, arr+n); arr[n] = 0; int top = arr[0] * 2; if(arr[1] == arr[0]) --top; if(arr[2] == arr[0]){ printf("Impossible"); return 0; } bool noo = false; int prev = arr[0]; for(int i = 1; i < n; i++){ if(arr[i] != prev){ if(noo){ printf("Impossible"); return 0; }else{ noo = true; prev = arr[i]; } }else{ noo = false; } } printf("Possible"); }
a.cc:1:10: fatal error: bits.stdc++.h: No such file or directory 1 | #include <bits.stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s241394119
p03988
C++
#include<bits/stdc++.h> using namespace std; const int N=105; int n,a[N],vi[N]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); ++vi[a[i]]; } sort(a+1,a+n+1); int k=a[n],res=INT_MAX; for(int i=0;i<=k;i++){ int d=max(k-i,i); res=min(res,d); if(!vi[d]){ puts("Impossible"); return 0; } else --vi[d]; } if(k&1) --res; for(int i=1;i<=res;i++) if(vi[i]){ puts("Impossible"); return 0; } puts("Possible"); return 0; } #include<bits/stdc++.h> using namespace std; const int N=105; int n,a[N],vi[N]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); ++vi[a[i]]; } sort(a+1,a+n+1); int k=a[n],res=INT_MAX; for(int i=0;i<=k;i++){ int d=max(k-i,i); res=min(res,d); if(!vi[d]){ puts("Impossible"); return 0; } else --vi[d]; } if(k&1) --res; for(int i=1;i<=res;i++) if(vi[i]){ puts("Impossible"); return 0; } puts("Possible"); return 0; }
a.cc:34:11: error: redefinition of 'const int N' 34 | const int N=105; | ^ a.cc:3:11: note: 'const int N' previously defined here 3 | const int N=105; | ^ a.cc:35:5: error: redefinition of 'int n' 35 | int n,a[N],vi[N]; | ^ a.cc:4:5: note: 'int n' previously declared here 4 | int n,a[N],vi[N]; | ^ a.cc:35:7: error: redefinition of 'int a [105]' 35 | int n,a[N],vi[N]; | ^ a.cc:4:7: note: 'int a [105]' previously declared here 4 | int n,a[N],vi[N]; | ^ a.cc:35:12: error: redefinition of 'int vi [105]' 35 | int n,a[N],vi[N]; | ^~ a.cc:4:12: note: 'int vi [105]' previously declared here 4 | int n,a[N],vi[N]; | ^~ a.cc:36:5: error: redefinition of 'int main()' 36 | int main(){ | ^~~~ a.cc:5:5: note: 'int main()' previously defined here 5 | int main(){ | ^~~~