submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s990720168
|
p03959
|
C++
|
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
int a[100000];
int b[100000];
int h[100000];
int ah[100000];
int bh[100000];
const ll MOD = ll(1e9 + 7);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
memset(ah, -1, sizeof ah);
memset(bh, -1, sizeof bh);
for(int i = 0; i < N; i++) {
cin >> a[i];
}
ah[0] = a[0];
for(int i = 1; i < N; i++) {
if(a[i - 1] != a[i]) ah[i] = a[i];
}
for(int i = 0; i < N; i++) {
cin >> b[i];
}
bh[N - 1] = b[N - 1];
for(int i = 0; i < N - 1; i++) {
if(b[i] != b[i + 1]) bh[i] = b[i];
}
ll ans = 1;
for(int i = 0; i < N; i++) {
if(ah[i] != -1 && bh[i] != -1) {
if(ah[i] != bh[i]) {
cout << 0 << endl;
return 0;
}
}
if(ah[i] == -1 && bh[i] == -1) {
ans *= min(a[i], b[i]);
ans %= MOD;
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:24:9: error: 'memset' was not declared in this scope
24 | memset(ah, -1, sizeof ah);
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include <algorithm>
+++ |+#include <cstring>
6 | using namespace std;
|
s992804352
|
p03959
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define MOD 1000000007
using namespace std;
ll N;
vector<ll> T;
vector<ll> A;
ll to[100001]={0};
ll hi[100001]={0}
int main(){
ll inp;
ll result=0;
T.push_back(0);
A.push_back(0);//0潰し
cin >> N;
for(ll i = 0 ;i<N;i++){
cin >> inp;
T.push_back(inp);
}
for(ll i =0;i<N;i++){
cin >> inp;
A.push_back(inp);
}
if(T[N]!=A[1]) {
cout << "0" << endl;
return 0;
}
for(ll i = 2;i<=N;i++){
if(T[i]!=T[i-1]){
to[i] = 1;
hi[i]=T[i];
}
if(A[N+1-i]!=A[N+2-i]){
if((to[N+1-i]!= 0)&&(to[N+1-i] != hi[N+1-i])){
cout << "0" << endl;
return 0;
}
else{
to[N-i+1] = 1;
}
}
}
to[1]=1;
to[N] = 1;
for(ll i = 1;i<=N;i++){
if(to[i] == 0){
to[i] = T[i];
}
}
for(ll i = 1;i<=N;i++){
if((to[i] == 0)||(to[i]>A[i])) to[i] = A[i];
}
result = 1;
for(ll i=1;i<=N;i++){
result*=to[i];
result %= MOD;
}
cout << result << endl;
return 0;
}
|
a.cc:17:1: error: expected ',' or ';' before 'int'
17 | int main(){
| ^~~
|
s783856505
|
p03959
|
C++
|
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n; cin >> n;
vector<ll> t(n), a(n);
for (int i = 0; i < n; i++) cin >> t[i];
for (int i = 0; i < n; i++) cin >> a[i];
if (n == 1 && t[0 != a[0]) {
cout << 0 << endl;
return 0;
}
vector<P> v(n, P(INF,0)); // max min;
v[0] = P(t[0], t[0]);
v[n - 1] = P(a[n - 1], a[n - 1]);
bool flag = false;
for (int i = 1; i < n; i++) {
if (t[i] != t[i - 1]) {
if (t[i] > v[i].first || v[i].second > t[i]) {
flag = true;
break;
}
else {
v[i] = P(t[i], t[i]);
}
}
else {
ll ma = min(v[i].first, t[i]);
ll mi = max(v[i].second, (ll)1);
v[i] = P(ma, mi);
}
}
if (flag) {
cout << 0 << endl;
return 0;
}
for (int i = n - 2; i >= 0; i--) {
if (a[i] != a[i + 1]) {
if (a[i] > v[i].first || v[i].second > a[i]) {
flag = true;
break;
}
else {
v[i] = P(a[i], a[i]);
}
}
else {
ll ma = min(v[i].first, a[i]);
ll mi = max(v[i].second, (ll)1);
v[i] = P(ma, mi);
}
}
if (flag) {
cout << 0 << endl;
return 0;
}
ll res = 1;
for (int i = 0; i < n; i++) {
if (v[i].first < v[i].second) {
cout << 0 << endl;
return 0;
}
res = res*(v[i].first - v[i].second + 1);
res %= MOD;
}
cout << res << endl;
}
|
a.cc: In function 'int main()':
a.cc:19:34: error: expected ']' before ')' token
19 | if (n == 1 && t[0 != a[0]) {
| ^
| ]
|
s290640062
|
p03959
|
C++
|
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n; cin >> n;
vector<ll> t(n), a(n);
for (int i = 0; i < n; i++) cin >> t[i];
for (int i = 0; i < n; i++) cin >> a[i];
vector<P> v(n, P(INF,0)); // max min;
v[0] = P(t[0], t[0]);
v[n - 1] = P(a[n - 1], a[n - 1]);
bool flag = false;
for (int i = 1; i < n; i++) {
if (t[i] != t[i - 1]) {
if (t[i] > v[i].first || v[i].second > t[i]) {
flag = true;
break;
}
else {
v[i] = P(t[i], t[i]);
}
}
else {
ll ma = min(v[i].first, t[i]);
ll mi = max(v[i].second, (ll)1);
v[i] = P(ma, mi);
}
}
if (flag) {
cout << 0 << endl;
return 0;
}
for (int i = n - 2; i >= 0; i--) {
if (a[i] != a[i + 1]) {
if (a[i] > v[i].first || v[i].second > a[i]) {
flag = true;
break;
}
else {
v[i] = P(a[i], a[i]);
}
}
else {
int ma = min(v[i].first, a[i]);
int mi = max(v[i].second, 1);
v[i] = P(ma, mi);
}
}
if (flag) {
cout << 0 << endl;
return 0;
}
ll res = 1;
for (int i = 0; i < n; i++) {
if (v[i].first < v[i].second) {
cout << 0 << endl;
return 0;
}
res = res*(v[i].first - v[i].second + 1);
res %= MOD;
}
cout << res << endl;
}
|
a.cc: In function 'int main()':
a.cc:55:37: error: no matching function for call to 'max(long long int&, int)'
55 | int mi = max(v[i].second, 1);
| ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:55:37: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
55 | int mi = max(v[i].second, 1);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:55:37: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
55 | int mi = max(v[i].second, 1);
| ~~~^~~~~~~~~~~~~~~~
|
s079981005
|
p03959
|
C++
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#define int long long
#define mod 1000000007
using namespace std;
int a[100002], b[100002];
signed main(){
int c; scanf("%lld", &c);
a[0] = 0; b[0] = LLONG_MAX / 3;
a[c + 1] = LLONG_MAX / 3; b[c + 1] = 0;
for (int d = 0; d < c; d++) {
scanf("%lld", &a[d+1]);
if (a[d + 1] < a[d]) { puts("0"); return 0; }
}
for (int d = 0; d < c; d++) {
scanf("%lld", &b[d+1]);
if (b[d + 1] > b[d]) { puts("0"); return 0; }
}
int ans = 1;
for (int i = 1; i <= c; i++) {
if (a[i - 1] != a[i]) {
if (b[i] != b[i + 1]) {
if (a[i] != b[i]) { puts("0"); return 0; }
}
}
else {
if (b[i] == b[i + 1]) {
ans *= min(a[i], b[i]);
ans %= mod;
}
}
}
printf("%lld\n", ans);
}
|
a.cc: In function 'int main()':
a.cc:12:26: error: 'LLONG_MAX' was not declared in this scope
12 | a[0] = 0; b[0] = LLONG_MAX / 3;
| ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include<algorithm>
+++ |+#include <climits>
4 | #include<string>
|
s407298356
|
p03959
|
C
|
#include<stdio.h>
#define M 1000000007
int N;
int flag;
void justify_T(int T[N], int jus_T[N][2])
{
jus_T[0][0] = T[0];
jus_T[0][1] = 0;
int i;
for(i=1;i<N;i++){
if(T[i]>T[i-1]){
jus_T[i][0] = T[i];
jus_T[i][1] = 0;
}else{
jus_T[i][0] = 0;
jus_T[i][1] = T[i-1];
}
}
return;
}
void justify_A(int A[N], int jus_A[N][2])
{
jus_A[N-1][0] = A[N-1];
jus_A[N-1][1] = 0;
int i;
for(i=N-2;i>=0;i--){
if(A[i]>A[i+1]){
jus_A[i][0] = A[i];
jus_A[i][1] = 0;
}else{
jus_A[i][0] = 0;
jus_A[i][1] = A[i+1];
}
}
return;
}
void compare(int combine[N], int jus_T[N][2], int jus_A[N][2])
{
int i;
flag = 1;
for(i=0;i<N;i++){
if(jus_A[i][0]!=0 & jus_T[i][0]!=0 & jus_A[i][0]!= jus_T[i][0]){
flag = 0;
return;
}else if(jus_A[i][0] ==0 & jus_T[i][0] ==0){
combine[i] = jus_A[i][1]<jus_T[i][1] ? jus_A[i][1] : jus_T[i][1];
}else{
combine[i] = 1;
}
}
return;
}
int main(void)
{
scanf("%d",&N);
int i,j,T[N],A[N];
for(i=0;i<N;i++){
scanf("%d",&T[i]);
}
for(i=0;i<N;i++){
scanf("%d",&A[i]);
}
int jus_T[N][2];
int jus_A[N][2];
justify_T(T,jus_T);
justify_A(A,jus_A);
int combine[N];
long int result;
compare(combine,jus_T,jus_A);
if(flag==0){
printf("0");
return 0;
}else{
result = 1;
for(i=0;i<N;i++){
] result = (result*combine[i])%M;
}
printf("%d",result);
return 0;
}
}
|
main.c: In function 'main':
main.c:84:1: error: expected statement before ']' token
84 | ] result = (result*combine[i])%M;
| ^
|
s551885118
|
p03959
|
C++
|
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(){
long long n,z[n],x,c;
x=1000000007;
cin>>n;
long long t[n],a[n],h[i];
for (int i = 0; i < n; ++i)
{
cin>>t[i];
h[i]=0;
}
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
for (int i = 0; i < n; ++i)
{
if (t[i]<t[i+1]){
h[i+1]=t[i+1];
}
}
for (int i = 0; i < n; ++i)
{
if (a[i]>a[i+1]){
h[i]=a[i];
}
}
h[0]=t[0];
h[n-1]=a[0];
for (int i = 0; i < n; ++i)
{
if (h[i]==t[i] && h[i]==a[i])
{
z[i]=1;
}
else if (h[i]==t[i] && h[i]<=a[i])
{
z[i]=1;
}
else if (h[i]<=t[i] && h[i]==a[i])
{
z[i]=1;
}
else if (h[i]<=t[i] && h[i]<=a[i])
{
if (t[i]<a[i])
{
z[i]=t[i];
}
else z[i]=a[i];
}
else z[i]=0;
}
for (int i = 0; i < n; ++i)
{
c=c*z[i];
}
cout<<c%x<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:23: error: 'i' was not declared in this scope
12 | long long t[n],a[n],h[i];
| ^
a.cc:16:9: error: 'h' was not declared in this scope
16 | h[i]=0;
| ^
a.cc:26:17: error: 'h' was not declared in this scope
26 | h[i+1]=t[i+1];
| ^
a.cc:32:17: error: 'h' was not declared in this scope
32 | h[i]=a[i];
| ^
a.cc:35:1: error: 'h' was not declared in this scope
35 | h[0]=t[0];
| ^
|
s607984287
|
p03959
|
C
|
#include<stdio.h>
#include<math.h>
int main()
{
int num, record[2][100000], i, j;
long long ans= 1;
scanf("%d", &num);
for(i= 0; i< 2; i++)
{
for(j= 0; j< num; j++)
scanf("%d", &record[i][j]);
}
if(record[0][num- 1]!= record[1][0])
{
printf("0\n");
return 0;
}
for(i= 1; i< num- 1; i++)
{
if(record[0][i]== record[0][i- 1] && record[1][i]== record[1][i+ 1])
(record[0][i]> record[1][i])? ans*= record[1][i]: ans*= record[0][i];
}
printf("%lld\n", ans% (long long)(pow(10, 9)+ 7));
return 0;
}
|
main.c: In function 'main':
main.c:25:78: error: lvalue required as left operand of assignment
25 | (record[0][i]> record[1][i])? ans*= record[1][i]: ans*= record[0][i];
| ^~
|
s390840852
|
p03959
|
C
|
#include <stdio.h>
int MIN(int a, int b){
return a<b?a:b;
}
int main(){
int n, i, a[100010], b[100010], f[100010]={};
long long s=1, M=(le9)+7;
scanf("%d", &n);
for(i=0;i<n;i++)
scanf("%d\n%d", &a[i], &b[i]);
for(i=0;i<n;i++){
if(i&&a[i-1]>a[i])
s=0;
if(i&&b[i-1]<b[i])
s=0;
if(i==0||a[i]-a[i-1]){
f[i]=1;
if(a[i]>b[i])
s=0;
}
if(i==n-1||b[i]-b[i+1]){
f[i]=1;
if(b[i]>a[i])
s=0;
}
}
if(a[n-1]-b[0])
s=0;
for(i=0;i<n;i++){
if(f[i])
continue;
s=(s*MIN(a[i], b[i]))%M;
}
printf("%lld\n", s);
return 0;
}
|
main.c: In function 'main':
main.c:9:27: error: 'le9' undeclared (first use in this function)
9 | long long s=1, M=(le9)+7;
| ^~~
main.c:9:27: note: each undeclared identifier is reported only once for each function it appears in
|
s809766711
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<(int)a;i++)
#define zero(x) memset(x, 0, sizeof x)
typedef long long ll;
int main() {
int N; cin >> N;
int A[N], B[N];
rep(i, N) cin >> A[i];
rep(i, N) cin >> B[i];
int L = -inf;
int pat[N]; zero(pat);
rep(i, N) {
if(L < A[i]) {
pat[i] = 1;
L = A[i];
}
}
int R = -inf;
rep(i, N) {
if(R < B[N-1-i]) {
if(pat[N-1-i] && A[N-1-i] != B[N-1-i]) { cout << 0 << endl; exit(0); }
pat[N-1-i] = 1;
R = B[N-1-i];
} else {
if(pat[N-1-i] && A[N-1-i] > B[N-1-i]) { cout << 0 << endl; exit(0); }
}
}
ll ans = 1;
rep(i, N) {
if(!pat[i]) {
pat[i] = min(A[i], B[i]);
}
ans *= pat[i];
ans %= MOD;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:12: error: 'inf' was not declared in this scope; did you mean 'ynf'?
14 | int L = -inf;
| ^~~
| ynf
a.cc:40:12: error: 'MOD' was not declared in this scope
40 | ans %= MOD;
| ^~~
|
s395719279
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N; cin >> N;
int A[N], B[N];
rep(i, N) cin >> A[i];
rep(i, N) cin >> B[i];
int L = -inf;
int pat[N]; zero(pat);
rep(i, N) {
if(L < A[i]) {
pat[i] = 1;
L = A[i];
}
}
int R = -inf;
rep(i, N) {
if(R < B[N-1-i]) {
if(pat[N-1-i] && A[N-1-i] != B[N-1-i]) { cout << 0 << endl; exit(0); }
pat[N-1-i] = 1;
R = B[N-1-i];
} else {
if(pat[N-1-i] && A[N-1-i] > B[N-1-i]) { cout << 0 << endl; exit(0); }
}
}
ll ans = 1;
rep(i, N) {
if(!pat[i]) {
pat[i] = min(A[i], B[i]);
}
ans *= pat[i];
ans %= MOD;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:7: error: 'i' was not declared in this scope
9 | rep(i, N) cin >> A[i];
| ^
a.cc:9:3: error: 'rep' was not declared in this scope
9 | rep(i, N) cin >> A[i];
| ^~~
a.cc:12:12: error: 'inf' was not declared in this scope; did you mean 'ynf'?
12 | int L = -inf;
| ^~~
| ynf
a.cc:13:15: error: 'zero' was not declared in this scope; did you mean 'bzero'?
13 | int pat[N]; zero(pat);
| ^~~~
| bzero
|
s987769185
|
p03959
|
C++
|
int main() {
int N; cin >> N;
ll A[N], B[N];
rep(i, N) cin >> A[i];
rep(i, N) cin >> B[i];
int L = -inf;
ll pat[N]; zero(pat);
rep(i, N) {
if(L < A[i]) {
pat[i] = 1;
L = A[i];
}
}
int R = -inf;
rep(i, N) {
if(R < B[N-1-i]) {
if(pat[N-1-i] && A[N-1-i] != B[N-1-i]) { cout << 0 << endl; exit(0); }
pat[N-1-i] = 1;
R = B[N-1-i];
} else {
if(pat[N-1-i] && A[N-1-i] > B[N-1-i]) { cout << 0 << endl; exit(0); }
}
}
ll ans = 1;
rep(i, N) {
if(!pat[i]) {
pat[i] = min(A[i], B[i]);
}
ans *= pat[i];
ans %= MOD;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:3:10: error: 'cin' was not declared in this scope
3 | int N; cin >> N;
| ^~~
a.cc:4:3: error: 'll' was not declared in this scope
4 | ll A[N], B[N];
| ^~
a.cc:5:7: error: 'i' was not declared in this scope
5 | rep(i, N) cin >> A[i];
| ^
a.cc:5:3: error: 'rep' was not declared in this scope
5 | rep(i, N) cin >> A[i];
| ^~~
a.cc:8:12: error: 'inf' was not declared in this scope; did you mean 'int'?
8 | int L = -inf;
| ^~~
| int
a.cc:9:5: error: expected ';' before 'pat'
9 | ll pat[N]; zero(pat);
| ^~~~
| ;
a.cc:9:19: error: 'pat' was not declared in this scope
9 | ll pat[N]; zero(pat);
| ^~~
a.cc:9:14: error: 'zero' was not declared in this scope
9 | ll pat[N]; zero(pat);
| ^~~~
a.cc:28:5: error: expected ';' before 'ans'
28 | ll ans = 1;
| ^~~~
| ;
a.cc:37:3: error: 'cout' was not declared in this scope
37 | cout << ans << endl;
| ^~~~
a.cc:37:11: error: 'ans' was not declared in this scope
37 | cout << ans << endl;
| ^~~
a.cc:37:18: error: 'endl' was not declared in this scope
37 | cout << ans << endl;
| ^~~~
|
s180140306
|
p03959
|
C++
|
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
int n;
long long t[100010],a[100010];
long long kaku[100010];
long long ans = 1;
int flag = 0;
cin >> n;
for(int i = 0;i < n;i++){
kaku[i] = -1;
}
for(int i = 0;i < n;i++){
cin >> t[i];
if(i == 0){
kaku[i] = t[i];
}
}
for(int i = 0;i < n;i++){
cin >> a[i];
if(i == n - 1){
kaku[n - 1] = a[i];
}
}
for(int i = 0;i < n; i++){
if((t[n - 1] != a[0]) || (t[n - 1] < a[n - 1]) || (t[0] > a[0])){
ans = 0;
break;
}
if(kaku[i] == -1){
if(t[i] - t[i - 1] != 0 && a[i] - a[i + 1] != 0)
}else if(t[i] - t[i - 1] != 0 && a[i] - a[i + 1] == 0){
if(t[i] <= a[i])kaku[i] = t[i];
else ans = 0;
}else if(t[i] - t[i - 1] == 0 && a[i] - a[i + 1] != 0){
if(a[i] <= t[i])kaku[i] = a[i];
else ans = 0;
}
}
}
if(ans == 1){
for(int i = 1;i < n - 1;i++){
if(kaku[i] == -1){
if(t[i] <= a[i]){
ans *= t[i];
}else if(t[i] > a[i]){
ans *= a[i];
}
}
}
ans %= 1000000007;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:61:13: error: expected primary-expression before '}' token
61 | }else if(t[i] - t[i - 1] != 0 && a[i] - a[i + 1] == 0){
| ^
a.cc: At global scope:
a.cc:70:5: error: expected unqualified-id before 'if'
70 | if(ans == 1){
| ^~
a.cc:84:5: error: 'cout' does not name a type
84 | cout << ans << endl;
| ^~~~
a.cc:85:1: error: expected declaration before '}' token
85 | }
| ^
|
s299736618
|
p03959
|
C++
|
// g++ temp.cpp
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
#define INF INT_MAX/3
#define MAX_N 1000
ll MAX_LIMIT=1000000007;
int main(){
int n;
int T[100000];
int A[100000];
cin >> n;
rep(i, 0, n) cin >> T[i];
rep(i, 0, n) cin >> A[i];
if (T[n - 1] != A[0]) {
cout << '0' << endl;
return 0;
}
if (n == 2 || n == 1) {
cout << '1' << endl;
return 0;
}
long long int re = 1;
rep(i, 1, n - 1) {
if (T[i-1] == T[i] && A[i] == A[i + 1]) {
re = re * min(T[i], A[i]) % 1000000007;
}
if (T[i] > A[i] && T[i - 1] != T[i]) {
cout << '0' << endl;
return 0;
}
if (T[i] < A[i] && A[i] != A[i + 1]) {
cout << '0' << endl;
return 0;
}
}
cout << re << endl;
return 0;
}
|
a.cc:144:14: error: macro "rep" passed 3 arguments, but takes just 2
144 | rep(i, 0, n) cin >> T[i];
| ^
a.cc:120:9: note: macro "rep" defined here
120 | #define rep(i,n) repl(i,0,n)
| ^~~
a.cc:145:14: error: macro "rep" passed 3 arguments, but takes just 2
145 | rep(i, 0, n) cin >> A[i];
| ^
a.cc:120:9: note: macro "rep" defined here
120 | #define rep(i,n) repl(i,0,n)
| ^~~
a.cc:159:18: error: macro "rep" passed 3 arguments, but takes just 2
159 | rep(i, 1, n - 1) {
| ^
a.cc:120:9: note: macro "rep" defined here
120 | #define rep(i,n) repl(i,0,n)
| ^~~
a.cc: In function 'int main()':
a.cc:144:3: error: 'rep' was not declared in this scope
144 | rep(i, 0, n) cin >> T[i];
| ^~~
a.cc:145:6: error: expected ';' before 'cin'
145 | rep(i, 0, n) cin >> A[i];
| ^ ~~~
| ;
a.cc:159:6: error: expected ';' before '{' token
159 | rep(i, 1, n - 1) {
| ^ ~
| ;
|
s781744725
|
p03959
|
C++
|
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1000000007
int main(){
int n;
cin >> n;
vector<unsigned long long int> v1;
vector<unsigned long long int> v2;
bool f[n];
unsigned long long int res = 1;
int tmp;
bool bf = false;
unsigned long long int b = 0;
for(int i=0;i<n;++i){
f[i] = false;
cin >> tmp;
v1.push_back(tmp);
if(b > tmp){
bf = true;
}
b =tmp;
// cout << bf <<" " << b <<" " << tmp <<endl;
}
for(int i=0;i<n;++i){
cin >> tmp;
v2.push_back(tmp);
if(b < tmp) bf = true;
b =tmp;
}
if(bf || v1[n-1] != v2[0]){
cout << 0 <<endl;
return 0;
}
for(int i=1;i<n-1;++i){
if(v1[i-1] == v1[i]){
f[i] = true;
if(v1[i] > v2[i]) res = 0;
}
}
for(int i= n-2 ; i>=0 ; --i){
if(v2[i] != v2[i+1] && f[i] == true){
f[i] = false;
}
if(v1[i] > v2[i]) res = 0;
}
unsigned long long int res = 1;
for(int i= 0;i < n;++i){
if(f[i] == true){
unsigned long long int a = min(v1[i],v2[i]);
res = (res * (a%N)%N);
}
}
cout << res << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:55:32: error: redeclaration of 'long long unsigned int res'
55 | unsigned long long int res = 1;
| ^~~
a.cc:15:32: note: 'long long unsigned int res' previously declared here
15 | unsigned long long int res = 1;
| ^~~
|
s830403245
|
p03959
|
C++
|
/*
安部NANA先輩大好き
*/
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
using namespace std;
const int INF = 1e18 + 9;
const int Mod = 1000000007;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int n,ya[100005],ma[100005],yama[100005];
bool ok[100005],k=false;
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n ;
int a=0,b=INF;
rep(i,0,n){
ok[i]=false;
yama[i]=0;
}
rep(i,0,n){
cin >> ya[i];
if(a<=ya[i]){
a=ya[i];
}else{
k=true;
break;
}
if(i==0){
ok[i]=true;
}
else if(ya[i-1]<ya[i]){
ok[i]=true;
}
yama[i]=ya[i];
}
rep(i,0,n){
cin >> ma[i];
if(ma[i]<=b){
b=ma[i];
}else{
k=false;
break;
}
if(i==(n-1)){
if(ok[i]){
if(ma[i]!=yama[i]){
k=true;
break;
}
}
yama[i]=ma[i];
ok[i]=true;
}
if(ma[i]<ma[i-1]){
// if(i==8){
// cout << "8 : " << ma[i] << " " << ma[i-1];
// }
if(ok[i-1]){
if(ma[i-1]=>yama[i-1]){
k=true;
break;
}
}
ok[i-1]=true;
}
if(yama[i-1]>ma[i-1]){
yama[i-1]=ma[i-1];
//cout << i-1 <<" a " << ma[i-1];
}
}
int ans = 1;
if(ya[n-1]!=ma[0]){
k=true;
}
else if(!k)rep(i,1,n-1){
if(!ok[i]){
// cout <<i << " a " << yama[i] << endl;
ans=(ans*yama[i])%Mod;
}
}
if(k){
cout << "0" << endl;
}else{
cout << ans%Mod << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:78:28: error: expected primary-expression before '>' token
78 | if(ma[i-1]=>yama[i-1]){
| ^
|
s306689152
|
p03959
|
C++
|
#include <vector>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <typeinfo>
#include <queue>
using namespace std;
typedef unsigned long long ll;
void ichi(){
string s;
cin >> s;
int tmp_c = 0;
int tmp_f = 0;
for(int i=0;i<s.size();i++){
if(s[i] == 'C'){
tmp_c = 1;
}
else if(s[i] == 'F'){
if(tmp_c == 1){
cout << "Yes" << endl;
tmp_f = 1;
break;
}
}
}
if(tmp_f == 0){
cout << "No" << endl;
}
}
void ni(){
int k,t;
cin >> k >> t;
//int num[t];
std::vector<int> num;
int tmp;
for(int i=0;i<t;i++){
cin >> tmp;
num.push_back(tmp);
}
sort(num.begin(),num.end(),greater<int>());
/*
int place = 0;
for(int i = 0;i<k;i++){
if(num[place] > 0){
num[place] = num[place] - 1;
}
}
*/
int maxnum = num[0];
int diff = 1;
for(int i=1;i<t;i++){
diff = diff + num[i];
}
int result = max(0,maxnum - diff);
cout << result << endl;
/*
for(int i=0;i<t;i++){
cout << num[i] << " ";
}
cout << endl;
*/
}
void san(){
int n;
std::vector<ll> t;
std::vector<ll> a;
ll tmp;
ll result = 1ll;
ll waru = 1000000000ll + 7ll;
cin >> n;
for(int i=0;i<n;i++){
cin >> tmp;
t.push_back(tmp);
}
for(int i=0;i<n;i++){
cin >> tmp;
a.push_back(tmp);
}
//result = 3776ll*8848ll*8848ll*8848ll;
ll tmp_t = 0ll;
ll tmp_a = 0ll;
std::vector<ll> t_val(n);
std::vector<ll> t_val_a(n);
bool miss_flg = false;
//t_val[0] = t[0];
//cout << t_val[0] << " " << t_val[1] << " " << t_val.size() << endl;
for(int i=0;i<n;i++){
if(tmp_t != t[i]){
t_val[i] = t[i];
tmp_t = t[i];
//break;
}
}
for(int i=n-1;i>=0;i--){
if(tmp_a != a[i]){
t_val_a[i] = a[i];
tmp_a = a[i];
//t_val[i] = t[i];
//break;
}
}
for(int i=0;i<n;i++){
if(t_val[i] != 0){
if(a[i] < t_val[i]){
miss_flg = true;
break;
}
if(t_val_a[i] !=0){
if(t_val_a[i]!=t_val[i]){
miss_flg = true;
break;
}
}
}
if(t_val_a[i] != 0){
if(t[i] < t_val_a[i]){
miss_flg = true;
break;
}
}
}
if(miss_flg){
cout << 0 << endl;
}
else{
for(int i=0;i<n;i++){
if(t_val[i] ==0 && t_val_a[i]==0){
result = result * ll(min(t[i],a[i]));
}
}
//cout << result << endl;
cout << result%waru << endl;
}
//cout << ll(a[0])%waru << endl;
//cout << result%waru << endl;
}
void san2(){
int n;
std::vector<int> t;
std::vector<int> a;
int tmp;
ll result = 1ll;
ll waru = 1000000000ll + 7ll);
cin >> n;
for(int i=0;i<n;i++){
cin >> tmp;
t.push_back(tmp);
}
for(int i=0;i<n;i++){
cin >> tmp;
a.push_back(tmp);
}
//result = 3776ll*8848ll*8848ll*8848ll;
int tmp_t = 0;
int tmp_a = 0;
std::vector<int> t_val(n);
std::vector<int> t_val_a(n);
bool miss_flg = false;
//t_val[0] = t[0];
//cout << t_val[0] << " " << t_val[1] << " " << t_val.size() << endl;
for(int i=0;i<n;i++){
if(tmp_t != t[i]){
t_val[i] = t[i];
tmp_t = t[i];
//break;
}
if(tmp_a != a[n-1-i]){
t_val_a[i] = a[i];
tmp_a = a[i];
}
if(t_val[t] != 0){
if(a[i] < t_val[i]){
miss_flg = true;
break;
}
}
if(t_val_a[t] !=0){
if(t[i] < t_val_a[i]){
miss_flg = true;
break;
}
}
}
if(miss_flg){
cout << 0 << endl;
}
else{
for(int i=0;i<n;i++){
if(t_val[i] ==0 && t_val_a[i]==0){
result = result * ll(min(t[i],a[i]));
}
}
//cout << result << endl;
//cout << result%waru << endl;
}
//cout << ll(a[0])%waru << endl;
//cout << result%waru << endl;
}
int main(){
//ichi();
//ni();
san();
return 0;
}
|
a.cc: In function 'void san2()':
a.cc:166:37: error: expected ',' or ';' before ')' token
166 | ll waru = 1000000000ll + 7ll);
| ^
a.cc:196:25: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
196 | if(t_val[t] != 0){
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: '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]'
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
a.cc:202:27: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
202 | if(t_val_a[t] !=0){
| ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: '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]'
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
|
s456010231
|
p03959
|
C++
|
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
int n;
long long t[100010],a[100010];
long long kaku[100010];
long long ans = 1;
int flag = 0;
cin >> n;
for(int i = 0;i < n;i++){
kaku[i] = -1;
}
for(int i = 0;i < n;i++){
cin >> t[i];
if(i == 0){
kaku[i] = t[i];
}
}
for(int i = 0;i < n;i++){
cin >> a[i];
if(i == n - 1){
kaku[n - 1] = a[i];
}
}
for(int i = 0;i < n; i++){
if((n == 1 && t[0] != a[0]) || (t[n - 1] != a[0])){
ans = 0;
break;
}
if(kaku[i] == -1){
if(t[i] - t[i - 1] != 0){
if(t[i] <= a[i]){
kaku[i] = t[i];
}else{
ans = 0;
}
}
if(a[i] - a[i + 1] != 0){
if(t[i] >= a[i]){
kaku[i] = a[i];
}else{
ans = 0;
}
}
if(t[i] == a[i]){
kaku[i] = t[i];
}
}
}
if(ans == 1){
for(int i = 1;i < n - 1;i++){
if(kaku[i] == -1){
if(t[i] =< a[i]){
ans *= t[i];
}else if(t[i] > a[i]){
ans *= a[i];
}
}
ans %= 1000000007;
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:82:26: error: expected primary-expression before '<' token
82 | if(t[i] =< a[i]){
| ^
|
s117386537
|
p03959
|
Java
|
#include <iostream>
#include <queue>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> left(n);
vector<int> right(n);
vector<int> m(n, -1);
int ans = 1;
for(int i=0; i<n; ++i)
cin >> left[i];
for(int i=0; i<n; ++i)
cin >> right[i];
for(int i=0; i<n; ++i){
if(i == 0 || left[i] > left[i-1])
m[i] = left[i];
}
for(int i=n-1; i>=0; --i){
if(m[i]>right[i] && m[i]!=-1) return 0;
if(m[i]==-1 && right[i]==right[i])
ans *= min(right[i], left[i]);
ans %= 1000000007;
}
cout << ans << endl;
return 0;
}
|
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <queue>
^
Main.java:10: error: not a statement
cin >> n;
^
Main.java:11: error: not a statement
vector<int> left(n);
^
Main.java:12: error: not a statement
vector<int> right(n);
^
Main.java:13: error: not a statement
vector<int> m(n, -1);
^
Main.java:17: error: not a statement
cin >> left[i];
^
Main.java:20: error: not a statement
cin >> right[i];
^
Main.java:37: error: not a statement
cout << ans << endl;
^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
int main()
^
(use --enable-preview to enable unnamed classes)
Main.java:11: error: ';' expected
vector<int> left(n);
^
Main.java:11: error: ';' expected
vector<int> left(n);
^
Main.java:12: error: ';' expected
vector<int> right(n);
^
Main.java:12: error: ';' expected
vector<int> right(n);
^
Main.java:13: error: ';' expected
vector<int> m(n, -1);
^
Main.java:13: error: ';' expected
vector<int> m(n, -1);
^
16 errors
|
s326001246
|
p03959
|
C++
|
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX
#define MAX_V
using namespace std;
bool tt[200000] = {false},aa[200000] = {false};
vector<bool> flag(200000,false);
int main(){
vector< pair<int,int> > m(200000);
int n;
cin >> n;
int t[200000],a[200000];
int maxt = 0;
for(int i = 0;i < n;i++){
cin >> t[i];
if(maxt < t[i])
maxt = t[i];
}
int maxa = 0;
for(int i = 0;i < n;i++){
cin >> a[i];
if(maxa < a[i])
maxa = a[i];
}
if(maxa != maxt){
cout << "0" << endl;
return 0;
}
flag[0] = true;
flagg = true;
for(int i = 1;i < n;i++){
if(a[i] != t[i])
flagg = false;
if(a[i+1] != a[i] || t[i] != t[i-1])
flag[i] = true;
}
flag[n-1] = true;
if(flagg){
cout << "0" << endl;
return 0;
}
long ans = 1;
for(int i = 0;i < n;i++){
long aaa = a[i],ttt = t[i];
if(!flag[i]){
if(aaa < ttt){
ans = (ans * aaa) % 1000000007;
}else{
ans = (ans * ttt) % 1000000007;
}
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:5: error: 'flagg' was not declared in this scope; did you mean 'flag'?
38 | flagg = true;
| ^~~~~
| flag
|
s389952041
|
p03959
|
C++
|
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX
#define MAX_V
using namespace std;
bool tt[200000] = {false},aa[200000] = {false};
vector<bool> flag(200000,false);
int main(){
vector< pair<int,int> > m(200000);
int n;
cin >> n;
int t[200000],a[200000];
int maxt = 0;
for(int i = 0;i < n;i++){
cin >> t[i];
if(maxt < t[i])
maxt = t[i];
}
int maxa = 0;
for(int i = 0;i < n;i++){
cin >> a[i];
if(maxa < a[i])
maxa = a[i];
}
if(maxa != maxt){
cout << "0" << endl;
return 0;
}else if(n == 1){
cout << "1" << endl;
return 0;
}
flag[0] = true;
flagg = true;
for(int i = 1;i < n;i++){
if(a[i] != t[i])
flagg = false;
if(a[i+1] != a[i] || t[i] != t[i-1])
flag[i] = true;
}
flag[n-1] = true;
if(flagg){
cout << "0" << endl;
return 0;
}
long ans = 1;
for(int i = 0;i < n;i++){
long aaa = a[i],ttt = t[i];
if(!flag[i]){
if(aaa < ttt){
ans = (ans * aaa) % 1000000007;
}else{
ans = (ans * ttt) % 1000000007;
}
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:41:5: error: 'flagg' was not declared in this scope; did you mean 'flag'?
41 | flagg = true;
| ^~~~~
| flag
|
s184467813
|
p03959
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> t;
int tmpV;
int tmp = n;
while(tmp--){
cin >> tmpV;
t.push_back(tmpV);
}
tmp = n;
vector<int> a;
while(tmp--){
cin >> tmpV;
a.push_back(tmpV);
}
vector<int> res(n, 0);
if(t.back() != a[0] || t.back() < a.back() || t[0] > a[0]){
cout << 0 << endl;
return 0;
}
for(int i = 0; i < n; i++){
if(i == 0)
res[i] = t[i];
else{
if(t[i] != t[i - 1]){
res[i] = t[i];
}
}
}
for(int i = n - 1; i >= 0; i--){
if(i == n - 1){
if(res[i] != 0 && res[i] != a[i]){
cout << 0 << end;
return 0;
}
res[i] = a[i];
}
else{
if(a[i] != a[i + 1]){
if(res[i] != 0 && res[i] != a[i]){
cout << 0 << endl;
return 0;
}
res[i] = a[i];
}
}
}
long res = 0;
long start = 0;
for(int i = 0; i < n; i++){
if(res[i] != 0){
for(int j = start + 1; j < i; i++){
res += min(res[start], res[i]);
}
start = i;
}
}
cout << res % (pow(10, 9) + 7)<< endl;
}
|
a.cc: In function 'int main()':
a.cc:39:43: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
39 | cout << 0 << end;
| ~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::nullptr_
|
s109620048
|
p03959
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> t;
int tmpV;
int tmp = n;
while(tmp--){
cin >> tmpV;
t.push_back(tmpV);
}
tmp = n;
vector<int> a;
while(tmp--){
cin >> tmpV;
a.push_back(tmpV);
}
vector<int> res(n, 0);
if(t.back() != a[0] || t.back() < a.back() || t[0] > a[0]){
cout << 0 << endl;
return 0;
}
for(int i = 0; i < n; i++){
if(i == 0)
res[i] = t[i];
else{
if(t[i] != t[i - 1]){
res[i] = t[i];
}
}
}
for(int i = n - 1; i >= 0; i--){
if(i == n - 1){
if(res[i] != 0 && res[i] != a[i]){
cout << 0 << end;
return 0;
}
res[i] = a[i];
}
else{
if(a[i] != a[i + 1]){
if(res[i] != 0 && res[i] != a[i]){
cout << 0 << end;
return 0;
}
res[i] = a[i];
}
}
}
long res = 0;
long start = 0;
for(int i = 0; i < n; i++){
if(res[i] != 0){
for(int j = start + 1; j < i; i++){
res += min(res[start], res[i]);
}
start = i;
}
}
cout << res % (pow(10, 9) + 7)<< endl;
}
|
a.cc: In function 'int main()':
a.cc:39:43: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
39 | cout << 0 << end;
| ~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::nullptr_
|
s402891308
|
p03959
|
C++
|
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<int MOD>
struct ModInt {
static const int Mod = MOD;
unsigned x;
ModInt() : x(0) {}
ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
int get() const { return (int) x; }
ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
ModInt inverse() const {
signed a = x, b = MOD, u = 1, v = 0;
while (b) {
signed t = a / b;
a -= t * b; std::swap(a, b);
u -= t * v; std::swap(u, v);
}
if (u < 0) u += Mod;
ModInt res; res.x = (unsigned) u;
return res;
}
};
signed main() {
int n;
scanf("%d", &n);
vector<ll> real(n);
int bef = 0;
REP(i, n) {
int a;
scanf("%d", &a);
if (a > bef) {
real[i] = a;
}
bef = a;
}
bef = 0;
REP(i, n) {
int a;
scanf("%d", &a);
if (a < bef) {
if (real[i-1] && real[i-1] != bef) {
printf("0\n");
return 0;
}
real[i - 1] = bef;
}
bef = a;
if (i == n - 1) {
if (real[i] && real[i] != a) {
printf("0\n");
return 0;
}
real[i] = a;
}
}
ModInt<MOD> ans = 1;
ll bpos = 0;
for (int i = 1; n > i; i++) {
if (real[i]) {
REP(j, i - bpos - 1) {
ans *= min(real[bpos], real[i]);
}
bpos = i;
}
}
printf("%d\n", ans.get());
return 0;
}
|
a.cc:21:13: error: expected '>' before numeric constant
21 | #define MOD 1000000007
| ^~~~~~~~~~
a.cc:25:14: note: in expansion of macro 'MOD'
25 | template<int MOD>
| ^~~
|
s895530327
|
p03959
|
C++
|
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<cstdio>
#include<unordered_set>
using namespace std;
struct mou{
long long int height;
long long int range;
};
int main()
{
int n, i, j;
long long int res = 1;
cin >> n;
vector<mou> mous(n);
vector<long long int> a(n);
vector<long long int> b(n);
for (i = 0; i < n; i++) {
mous[i].height = -1;
mous[i].range = INT_MAX;
cin >> a[i];
}
for (i = 0; i < n; i++) {
cin >> b[i];
}
mous[0].height = a[0];
mous[0].range = a[0];
for (i = 1; i < n; i++) {
if (a[i] > a[i - 1]) {
if (mous[i].height == -1) {
mous[i].height = a[i];
mous[i].range = a[i];
}
else {
cout << 0 << endl;
return 0;
}
}
else if (a[i] == a[i - 1] && mous[i].range > a[i]) {
mous[i].range = a[i];
}
else if (a[i] < a[i - 1]) {
cout << 0 << endl;
return 0;
}
}
mous[n - 1].height = b[n - 1];
mous[n - 1].range = b[n - 1];
if (mous[n - 1].height > mous[n - 1].range) {
cout << 0 << endl;
return 0;
}
for (i = n - 2; i >= 0; i--) {
if (b[i] > b[i + 1]) {
if (mous[i].height == -1 || b[i] <= mous[i].range) {
mous[i].height = b[i];
mous[i].range = b[i];
}
else {
cout << 0 << endl;
return 0;
}
}
else if (b[i] == b[i + 1] && mous[i].range > b[i]) {
mous[i].range = b[i];
}
else if (b[i] < b[i + 1]) {
cout << 0 << endl;
return 0;
}
}
for (i = 1; i < n - 1; i++) {
if (mous[i].height == -1) {
res *= mous[i].range;
res = res % 1000000007;
}
}
cout << res << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:26:33: error: 'INT_MAX' was not declared in this scope
26 | mous[i].range = INT_MAX;
| ^~~~~~~
a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
9 | #include<unordered_set>
+++ |+#include <climits>
10 | using namespace std;
|
s344729176
|
p03959
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define NNN 1000000007
int main()
{
long long int N;
cin >> N;
vector<long long int> T(N), A(N);
long long int MaxT = 0, MaxA = 0;
for(int i = 0; i < N; i++) {cin >> T[i]; MaxT = max(MaxT, T[i]);}
for(int i = 0; i < N; i++) {cin >> A[i]; MaxA = max(MaxA, A[i]);}
if(MaxT != MaxA) {cout << "0" << endl; return 0;}
vector<long long int> dp(N);
dp[0] = 1;
dp[N-1] = 1;
for(long long int i = 1; i < N-1; i++) {
if(T[i-1] != T[i]) dp[i] = 1;
else dp[i] = T[i];
}
dp[N-1] = 1;
for(long long int i = N-2; i >= 1; i--) {
if(A[i+1] != A[i]) dp[i] = 1;
else dp[i] = (min(A[i], dp[i]);
}
long long int ans = 1;
//for(auto u: dp) cout << u << endl;
for(long long int i = 0; i < dp.size(); i++) {
ans *= dp[i];
ans = ans % NNN;
}
cout << (ans%NNN) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:35: error: expected ')' before ';' token
38 | else dp[i] = (min(A[i], dp[i]);
| ~ ^
| )
|
s373775042
|
p03959
|
Java
|
import java.util.Scanner;
public class MainClimbMountain {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
int[] b = new int[N];
for (int i = 0; i < N; i++) {
a[i] = sc.nextInt();
}
for (int i = 0; i < N; i++) {
b[i] = sc.nextInt();
}
System.out.println(mountainSeqNum(a, b));
}
private static long mountainSeqNum(int[] a, int[] b) {
int c[] = new int[a.length];
int pre = 0;// 上一座
int zl[] = new int[a.length];
for (int i = 0; i < a.length; i++) {
if (a[i] > pre) {
c[i] = a[i];
pre = a[i];
} else {
zl[i] = pre;
}
}
int behind = 0;// 反序上一座
for (int i = b.length - 1; i > 0; i--) {
if (b[i] > behind) {
if (c[i] == 0) {
c[i] = b[i];
behind = b[i];
zl[i] = 0;
} else {
// 存在值
if (c[i] != b[i]) {// 不等于当前值
return 0;
}
}
} else {
if (c[i] == 0) {
if (zl[i] > behind) {
zl[i] = behind;
}
} else {
// 存在值时
if (c[i] > b[i]) {
return 0;
}
}
}
}
long sum = 1;
for (int i = 0; i < zl.length; i++) {
if (zl[i] != 0) {
sum = sum * zl[i];
if (sum >= 1000000007) {
sum %= 1000000007;
}
}
}
return sum;
}
}
|
Main.java:3: error: class MainClimbMountain is public, should be declared in a file named MainClimbMountain.java
public class MainClimbMountain {
^
1 error
|
s753756712
|
p03959
|
C++
|
int n;
cin >> n;
ll tm = -1, am = -1;
ll mod = 1000000007;
vector<ll> T, A;
rep(i, n) {
ll a;
cin >> a;
tm = max(a, tm);
T.push_back(a);
}
rep(i, n) {
ll a;
cin >> a;
am = max(a, am);
A.push_back(a);
}
if (tm != am) {
P(0);
}
else {
ll ans = 1;
ll mini = 1e12;
rep(i, n) {
if (i == 0 || i == n - 1) {
mini = T[0];
ans *= 1;
ans %= mod;
}
else {
if ((T[i] > T[i - 1]) || (A[i] > A[i + 1])) {
ans *= 1;
ans %= mod;
}
else {
ans = (((abs(mini - min(A[i], T[i])) + 1) % mod)* (ans%mod)) % mod;
}
}
}
ans = ans % mod;
P(ans%mod);
}
|
a.cc:2:1: error: 'cin' does not name a type
2 | cin >> n;
| ^~~
a.cc:3:1: error: 'll' does not name a type
3 | ll tm = -1, am = -1;
| ^~
a.cc:4:1: error: 'll' does not name a type
4 | ll mod = 1000000007;
| ^~
a.cc:5:1: error: 'vector' does not name a type
5 | vector<ll> T, A;
| ^~~~~~
a.cc:6:4: error: expected constructor, destructor, or type conversion before '(' token
6 | rep(i, n) {
| ^
a.cc:12:4: error: expected constructor, destructor, or type conversion before '(' token
12 | rep(i, n) {
| ^
a.cc:18:1: error: expected unqualified-id before 'if'
18 | if (tm != am) {
| ^~
a.cc:21:1: error: expected unqualified-id before 'else'
21 | else {
| ^~~~
|
s492305851
|
p03959
|
C++
|
#include<iostream>
using namespace std;
void main(){
cout << 0;
}
|
a.cc:3:1: error: '::main' must return 'int'
3 | void main(){
| ^~~~
|
s203063735
|
p03959
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t[];
t = new int[n];
int a[];
a = new int[n];
int maxt = 0;
int maxa = 0;
int mint = 0;
int mina = 0;
int answer = 0;
int c[];
c = new int[n];
for(int i = 0; i<n; i++){
t[i] = sc.nextInt();
if(maxt < t[i]){
maxt = t[i];
}
else if(mint > t[i]){
mint = t[i];
}
if(i>0 && t[i] != t[i-1]){
c[i] = t[i];
}
}
int cc = 1;
for(int i = 0; i<n; i++){
a[i] = sc.nextInt();
if(maxa < a[i]){
maxa = a[i];
}
else if(mina > a[i]){
mina = a[i];
}
if(i>0 && a[i] != a[i-1]){
c[i-1] = a[i-1];
}
}
for(int i=0; i<c.length; i++){
if(c[i] == null){
if(t[i]>a[i]){
cc = cc * a[i];
}
else{
cc = cc * t[i];
}
}
}
if(maxa != maxt){
System.out.println(answer);
}
else{
System.out.println(cc);
}
}
}
|
Main.java:43: error: bad operand types for binary operator '=='
if(c[i] == null){
^
first type: int
second type: <null>
1 error
|
s452705388
|
p03959
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t[];
t = new int[n];
int a[];
a = new int[n];
int maxt = 0;
int maxa = 0;
int mint = 0;
int mina = 0;
int answer = 0;
int c[];
c = new int[n]
for(int i = 0; i<n; i++){
t[i] = sc.nextInt();
if(maxt < t[i]){
maxt = t[i];
}
else if(mint > t[i]){
mint = t[i];
}
if(i>0 && t[i] != t[i-1]){
c[i] = t[i];
}
}
int cc = 1;
for(int i = 0; i<n; i++){
a[i] = sc.nextInt();
if(maxa < a[i]){
maxa = a[i];
}
else if(mina > a[i]){
mina = a[i];
}
if(i>0 && a[i] != a[i-1]){
c[i-1] = a[i-1];
}
}
for(int i=0; i<c.length; i++){
if(c[i] == null){
if(t[i]>a[i]){
cc = cc * a[i];
}
else{
cc = cc * t[i];
}
}
}
if(maxa != maxt){
System.out.println(answer);
}
else{
System.out.println(cc);
}
}
}
|
Main.java:16: error: ';' expected
c = new int[n]
^
1 error
|
s666565571
|
p03959
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
int main() {
int n_mountain;
std::cin >> n_mountain;
std::vector<long long> t_report(n_mountain), a_report(n_mountain), min_mountain(n_mountain);
std::vector<bool> changed(n_mountain, false);
changed[0] = changed[n_mountain - 1] = true;
for(int i = 0; i < n_mountain; ++i){
std::cin >> t_report[i];
if(i > 0){
if(t_report[i - 1] != t_report[i]){
changed[i] = true;
}
}
}
for(int i = 0; i < n_mountain; ++i){
std::cin >> a_report[i];
if(i > 0){
if(a_report[i - 1] != a_report[i]){
changed[i - 1] = true;
}
}
}
if(t_report[n_mountain - 1] != a_report[0]{
std::cout << 0 << std::endl;
return 0;
}
for(int i = 0; i < n_mountain; ++i){
min_mountain[i] = std::min(t_report[i], a_report[i]);
}
unsigned long long ans = 1;
for(int i = 0; i < n_mountain; ++i){
if(changed[i] == true) continue;
ans *= min_mountain[i];
ans %= 1000000007;
}
std::cout << ans % 1000000007 << std::endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:31:51: error: expected ')' before '{' token
31 | if(t_report[n_mountain - 1] != a_report[0]{
| ~ ^
| )
a.cc:36:24: error: 'i' was not declared in this scope
36 | for(int i = 0; i < n_mountain; ++i){
| ^
|
s792161729
|
p03959
|
C++
|
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >>n;
long long c=1;
vector<long long>mo((long long)n,0);
vector< long long > a ((long long )n,0);
vector< long long > b ((long long )n,0);
long long am=0,bm=0,ami=10000000000,bmi=1000000000;
for(int j=0;j<2;j++){
for(int i=0;i<n;i++){
if(j==0){
cin >> a[i];
am=max(am,a[i]);
ami = min(ami,a[i]);
}
else{
cin >> b[i];
bm=max(bm,b[i]);
bmi=min(bmi,b[i]);
}
}
}
for(int i=n/2+n%2;i<n;i++){
if(b[i]>a[i]){
cout << 0 <<endl;
return 0;
}
}
for(int i=0;i<n/2;i++){
if(a[i]>b[i]){
cout << 0 << endl;
return 0;
}
}
if(am!=bm){
cout << 0 << endl;
return 0;
}
for(int i=0;i<n;i++){
if(i==0)mo[i]=a[i];
else{
if(a[i-1]==a[i])mo[i]=-1;
else mo[i]=a[i];
}
}
for(int i=n-1;i>=0;i--){
if(i==n-1)mo[i]=b[i];
else{
if(mo[i]==-1){
if(b[i+1]==b[i])mo[i]=-1;
else mo[i]=b[i];
}
}
}
int ka;
for(int i=0;i<n;i++){
if(mo[i]!=-1)continue;
c*=min(a[i],b[i])
}
c%=(1000000000+7);
cout << c << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:63:22: error: expected ';' before '}' token
63 | c*=min(a[i],b[i])
| ^
| ;
64 | }
| ~
|
s018833006
|
p03959
|
C++
|
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
vector<ll> T,A;
int N;
cin >> N;
ll ans=1;
for(int i=0;i<N;i++){
ll in;
cin >> in;
T.push_back(in);
}
for(int i=0;i<N;i++){
ll in;
cin >> in;
A.push_back(in);
}
if(N==1){
if(A.at(0)==T.at(0){
cout << "1" << endl;}else{cout << "0" << endl;}
return 0;
}
if((A.at(0)!=A.at(1)&&A.at(0)!=T.at(0))||T.at(0)>A.at(0)){
cout << "0" << endl;
return 0;
}
for(int i=1;i<N-1;i++){
if(T.at(i-1)!=T.at(i)&&A.at(i)!=A.at(i+1)){
if(T.at(i)!=A.at(i)){
cout << "0" << endl;
return 0;
}
}else if(T.at(i-1)==T.at(i)&&A.at(i)!=A.at(i+1)){
if(T.at(i)<A.at(i)){
cout << "0" <<endl;
return 0;
}
}else if(T.at(i-1)!=T.at(i)&&A.at(i)==A.at(i+1)){
if(T.at(i)>A.at(i)){
cout <<"0" <<endl;
return 0;
}
}else{
if(T.at(i)<A.at(i)){
ans*=T.at(i);
ans%=1000000007;
}else{
ans*=A.at(i);
ans%=1000000007;
}
}
}
if((T.at(N-2)!=T.at(N-1)&&T.at(N-1)!=A.at(N-1))||T.at(N-1)<A.at(N-1)){
cout <<"0" << endl;
return 0;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:27:20: error: expected ';' before '{' token
27 | if(A.at(0)==T.at(0){
| ^
| ;
a.cc:28:30: error: expected primary-expression before 'else'
28 | cout << "1" << endl;}else{cout << "0" << endl;}
| ^~~~
a.cc:28:30: error: expected ')' before 'else'
28 | cout << "1" << endl;}else{cout << "0" << endl;}
| ^~~~
| )
a.cc:27:3: note: to match this '('
27 | if(A.at(0)==T.at(0){
| ^
|
s915281665
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vi;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second
const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
out << "{";
rep(i,v.size()) out << v[i] << ", " ;
return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
return out << "(" << p.fs << ", " << p.sc << ")";
}
#define MOD 1000000007
int main(){
int n;
cin >> n;
vi t(n), a(n);
ll ans = 1;
rep(i,n){
cin >> t[i];
if(i&&t[i]<t[i-1])ans=0;
}
rep(i,n){
cin >> a[i];
if(i&&a[i]>a[i-1])ams=0;
}
vi det(n);
det[0]=t[0];
det[n-1]=a[n-1];
int tmp = 0;
rep(i,n){
if(i && t[i]!=t[i-1]){
if(i==n-1&&t[i]!=a[i]) ans = 0;
det[i]=t[i];
if(tmp >= det[i])ans=0;
tmp = det[i];
}
if(det[i]&&det[i]>a[i]) ans = 0;
}
tmp=0;
rep(j,n){
int i=n-1-j;
if(i!=n-1 && a[i]!=a[i+1]){
if(det[i]!=0 && a[i]!=det[i])ans=0;
det[i] = a[i];
if(tmp >= det[i]) ans=0;
tmp = det[i];
}
}
int m;
rep(i,n){
int l = max(t[i],a[i]);
if(i&&m!=l)ans=0;
m=l;
}
rep(i,n){
if(!det[i]){
ans *= min(t[i],a[i]);
ans = ans % MOD;
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:39:35: error: 'ams' was not declared in this scope; did you mean 'ans'?
39 | if(i&&a[i]>a[i-1])ams=0;
| ^~~
| ans
|
s179882406
|
p03959
|
C++
|
int main()
{
cout << 0 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:3:1: error: 'cout' was not declared in this scope
3 | cout << 0 << endl;
| ^~~~
a.cc:3:14: error: 'endl' was not declared in this scope
3 | cout << 0 << endl;
| ^~~~
|
s987275814
|
p03959
|
C++
|
#include <iostream>
using namespace std;
int N;
int T[100005], A[100005];
int main() {
int i, max = 0, maxMt = 0;
ios_base::sync_with_stdio(0);
cin >> N;
for (i = 0; i < N; i++) {
cin >> T[i];
if (T[i] > max) {
max = T[i];
maxMt = i;
}
if (T[i] < max) {
cout << 0;
return 0;
}
}
for (i = 0; i < N; i++) {
cin >> A[i];
}
max = 0;
int maxMtA = 0;
for (i = N - 1; i >= 0; i--) {
if (max < A[i]) {
max = A[i];
maxMtA = i;
}
else if (max > A[i]) {
cout << 0;
return 0;
}
}
if (maxMt > maxMtA) {
cout << 0;
return 0;
}
for (i = 0; i < N; i++) {
if (A[i] < T[i]){
cout << 0;
return 0;
}
}
__int64 sum = 1;
max = 0;
for (i = 0; i < maxMt; i++) {
if (max < T[i]) {
max = T[i];
}
else
sum *= T[i];
sum %= 1000000007;
}
max = 0;
for (i = N - 1; i > maxMt; i--) {
if (max < A[i]) {
max = A[i];
}
else
sum *= A[i];
sum %= 1000000007;
}
cout << (sum % 1000000007) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:53:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
53 | __int64 sum = 1;
| ^~~~~~~
| __int64_t
a.cc:61:25: error: 'sum' was not declared in this scope
61 | sum *= T[i];
| ^~~
a.cc:62:17: error: 'sum' was not declared in this scope
62 | sum %= 1000000007;
| ^~~
a.cc:71:25: error: 'sum' was not declared in this scope
71 | sum *= A[i];
| ^~~
a.cc:72:17: error: 'sum' was not declared in this scope
72 | sum %= 1000000007;
| ^~~
a.cc:75:18: error: 'sum' was not declared in this scope
75 | cout << (sum % 1000000007) << endl;
| ^~~
|
s500790935
|
p03959
|
Java
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final int BASE = 1000000007;
int n = sc.nextInt();
int taka[] = new int [n];
int ao[] = new int [n];
for(int i=0;i<n;i++){
taka[i]= sc.nextInt();
}
for(int i=0;i<n;i++){
ao[i]= sc.nextInt();
}
long pattern = 1;
boolean flag = true;
for(int i=0;i<n&&flag;i++){
int max_t=0,min_t=0;
int max_a=0,min_a=0;
if(i==0){
max_t = taka[0];
min_t = taka[0];
}
else{
if(taka[i]==taka[i-1]){
max_t = taka[i];
min_t = 1;
}
else {
max_t = taka[i];
min_t = taka[i];
}
}
if(i==n-1){
max_a = ao[n-1];
min_a = ao[n-1];
}
else{
if(ao[i+1]==ao[i]){
min_a =1;
max_a = ao[i];
}
else {
max_a = ao[i];
min_a = ao[i];
}
}
if(max_t<min_a && max_a<min_t){
flag = false;
}
else{
int tmp = Math.min(max_a,max_t) - Math.max(min_a,min_t)+1;
pattern *= tmp;
pattern = pattern%BASE;
}
}
//if(!flag) pattern = 0;
System.out.println(pattern);
}
|
Main.java:72: error: reached end of file while parsing
}
^
1 error
|
s710564922
|
p03959
|
C++
|
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int determine[200000] = {};
int changed[200000] = {};
int main() {
int n;
cin >> n;
vector<int> a, t;
REP(i, n) {
int tmp;
cin >> tmp;
t.push_back(tmp);
}
REP(i, n) {
int tmp;
cin >> tmp;
a.push_back(tmp);
}
determine[0] = t[0];
for (int i = 1;i < n;++i) {
if (t[i] != determine[i - 1]) changed[i] = true;
determine[i] = t[i];
}
a.push_back(0);
for (int i = n-1;i >= 0;--i) {
if (a[i] != a[i + 1]) {
changed[i] = true;
if (a[i] > determine[i]) goto failed;
}
determine[i] = min(determine[i], a[i]);
}
long long ans = 1;
for (int i = 1;i < n;++i) {
if (changed[i] == false) {
ans *= determine[i];
ans %= MAX_MOD;
}
}
cout << ans << endl;
return 0;
failed:;
cout << "0" << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:65:1: error: jump to label 'failed'
65 | failed:;
| ^~~~~~
a.cc:52:55: note: from here
52 | if (a[i] > determine[i]) goto failed;
| ^~~~~~
a.cc:56:19: note: crosses initialization of 'long long int ans'
56 | long long ans = 1;
| ^~~
|
s414900218
|
p03959
|
C++
|
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;
#define MOD 1000000007
int main()
{
int N;
scanf("%d", &N);
vector<int> T(N), A(N);
int max = 0, max_index = 0;
REP (i, N) {
scanf("%d", &T[i]);
if (max < T[i]) {
max = T[i];
max_index = i;
}
}
REP (i, N) {
scanf("%d", &A[i]);
}
if (A[max_index] != max) {
printf("0\n");
return 0;
}
if (A[0] != T[N - 1]) {
printf("0\n");
return 0;
}
if (T.size() == 1) {
if (T[0] == A[0]) {
printf("1\n");
return 0:
} else {
printf("0\n");
return 0;
}
}
long long ans = 1;
for (int i = 1; i < max_index; i++) {
if (T[i] == T[i - 1]) {
ans *= T[i] % MOD;
ans %= MOD;
}
}
for (int i = N - 2; i > max_index; i--) {
if (A[i] == A[i + 1]) {
ans *= A[i] % MOD;
ans %= MOD;
}
}
printf("%lld\n", ans);
}
|
a.cc: In function 'int main()':
a.cc:35:21: error: expected ';' before ':' token
35 | return 0:
| ^
| ;
a.cc:35:21: error: expected primary-expression before ':' token
|
s825680834
|
p03959
|
C++
|
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
//負数の合同も考慮に入れるmod関数
inline long long imod(long long a, long long b)
{
return (a >= 0) ? (a % b) : (a % b + b);
}
//mintが引数の繰り返し2乗法
template <long long MOD> class mint;
template <long long MOD> mint<MOD> m_pow(mint<MOD> x, long long n);
//modの整数クラス
template <long long MOD = 1000000007>
class mint
{
public:
mint operator+(const mint &other)const
{
return mint(imod(a + other.a, MOD));
}
mint operator-(const mint &other)const
{
return mint(imod(a - other.a, MOD));
}
mint operator*(const mint &other)const
{
return mint(imod(a * other.a, MOD));
}
mint operator+=(const mint &other)
{
a = imod(a + other.a, MOD);
return mint(a);
}
mint operator-=(const mint &other)
{
a = imod(a - other.a, MOD);
return mint(a);
}
mint operator*=(const mint &other)
{
a = imod(a * other.a, MOD);
return mint(a);
}
mint operator+()const
{
return *this;
}
mint operator-()const
{
return mint(-a);
}
mint& operator++()
{
*this += 1;
return *this;
}
mint operator++(int)
{
auto tmp = *this;
*this += 1;
return tmp;
}
mint& operator--()
{
*this -= 1;
return *this;
}
mint operator--(int)
{
auto tmp = *this;
*this -= 1;
return tmp;
}
mint operator~()const
{
return pow(a, e_phi - 1);
}
mint& operator=(const mint &other)
{
a = other.a;
return *this;
}
operator long long()const
{
return a;
}
explicit operator int()const
{
return (int)a;
}
static long long getmod()
{
return mod;
}
mint(long long a_) :a(imod(a_, MOD))
{
//無効な値
static_assert(MOD >= 2, "MOD cannot be below 2.");
if (e_phi > 0)return;
//オイラー関数Φ(mod)を計算する
e_phi = MOD;
long long m_ = MOD;
for (int i = 2; i * i <= m_; ++i)
{
if (m_ % i == 0)
{
e_phi = e_phi / i * (i - 1);
for (; m_ % i == 0; m_ /= i);
}
}
if (m_ != 1)e_phi = e_phi / m_ * (m_ - 1);
}
mint() :a(0) {}
private:
static long long e_phi;
long long a;
};
//mintの累乗
//x^nを計算します
template<long long MOD>mint<MOD> pow(mint<MOD> x, long long n)
{
mint res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mintの階乗計算
//O(x)程度の時間がかかります
//非推奨、同時間でfact_setが計算可能
template<long long MOD>mint<MOD> fact(mint<MOD> x)
{
mint res(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
}
return res;
}
//mintの階乗計算のリスト
//setの末尾に0~xまでの階乗数の列挙をします
//O(x)程度の時間がかかります
template<long long MOD>void fact_set(std::vector<mint<MOD>> &set, mint<MOD> x = mint<MOD>(-1))
{
mint res(1);
set.push_back(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
set.push_back(res);
}
}
template<long long MOD>long long mint<MOD>::e_phi = -1;
//mint型のstreamへの入出力対応
template<long long MOD> std::ostream& operator<<(std::ostream& os, mint<MOD> i)
{
os << (long long)i;
return os;
}
template<long long MOD> std::istream& operator >> (std::istream& is, mint<MOD>& i)
{
long long tmp;
is >> tmp;
i = tmp;
return is;
}
mint<> ans(1);
int n;
mint<> t[123456];
mint<> a[123456];
mint<> tr[123456][2];
mint<> ar[123456][2];
mint<> res[123456][2];
mint<> total[123456];
int main(void)
{
cin >> n;
for (int i = 0; i < n; ++i)cin >> t[i];
for (int i = 0; i < n; ++i)cin >> a[i];
for (int i = 0; i < n; ++i)
{
if (i == 0)
{
tr[i][0] = tr[i][1] = t[i];
}
else if (t[i - 1] < t[i])
{
tr[i][0] = tr[i][1] = t[i];
}
else if(t[i - 1] == t[i])
{
tr[i][0] = 1;
tr[i][1] = t[i];
}
else
{
return 0 * printf("0\n");
}
}
for (int i = n - 1; i >= 0; --i)
{
if (i == n - 1)
{
ar[i][0] = ar[i][1] = a[i];
}
else if (a[i + 1] < a[i])
{
ar[i][0] = ar[i][1] = a[i];
}
else if (a[i + 1] == a[i])
{
ar[i][0] = 1;
ar[i][1] = a[i];
}
else
{
return 0 * printf("0\n");
}
}
for (int i = 0; i < n; ++i)
{
res[i][0] = max(tr[i][0], ar[i][0]);
res[i][1] = min(tr[i][1], ar[i][1]);
total[i] = res[i][1] - res[i][0] + mint<>(1);
if(res[i][1] < res[i][0])return 0 * printf("0\n");
ans *= total[i];
}
cout << ans << endl;
return 0;
}
|
a.cc: In static member function 'static long long int mint<MOD>::getmod()':
a.cc:114:24: error: 'mod' was not declared in this scope; did you mean 'modf'?
114 | return mod;
| ^~~
| modf
|
s194530516
|
p03959
|
C++
|
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
void Calc();
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
template<class A = string>A Next() { A a; cin >> a; return a; }
template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
string Line() { string s; getline(cin, s); return s; }
template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
template<class A>operator A() { return Next<A>(); }
}in;
/*---------------------------------------------------------------------*/
const ll mod = (ll)1e9 + 7;
template<ll MOD>struct Mint {
typedef const Mint&T;
ll x = 0;
Mint() {}
Mint(ll a) { x = a % MOD; if (x < 0) x += MOD; }
Mint&operator+=(T a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
Mint&operator-=(T a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
Mint&operator*=(T a) { x = x * a.x % MOD; return *this; }
Mint&operator/=(T a) { return *this *= a.Pow(MOD - 2); }
Mint operator+(T a)const { return Mint(*this) += a; }
Mint operator-(T a)const { return Mint(*this) -= a; }
Mint operator*(T a)const { return Mint(*this) *= a; }
Mint operator/(T a)const { return Mint(*this) /= a; }
bool operator<(T a)const { return x < a.x; }
bool operator==(T a)const { return x == a.x; }
Mint Pow(ll k)const {
if (k == 0) return 1;
Mint t = Pow(k / 2);
return t *= (k & 1) ? t * *this : t;
}
};
template<ll MOD>istream&operator >> (istream&i, Mint<MOD>&a) { return i >> a.x; }
template<ll MOD>ostream&operator<<(ostream&o, const Mint<MOD>&a) { return o << a.x; }
typedef Mint<mod>mint;
template<ll MOD = mod>Mint<MOD> CombMod(int n, int r) {
Mint<MOD> a = 1, b = 1;
rep(i, r) { a *= (n - i); }
rep(i, 2, r + 1) { b *= i; }
err(a, b);
return a / b;
}
void Calc() {
int n = in;
auto t = in.Array(n);
auto a = in.Array(n);
mint ans = 1;
const int INF = 1e9 - 1;
vector<int> v(n, INF);
bool flag = false;
int pos = -1;
rep(i, n) {
if (a[i] == t[i]) {
pos = i;
break;
}
}
assert(pos >= 0);
err(pos, t[pos]);
rep(i, pos, n) {
if (t[i] <= t[pos]) {
} else {
cout << (0) << endl;
return;
}
}
int maxi = 0;
rep(i, 0, pos + 1) {
if (maxi == t[i])
ans *= t[i];
maxi = t[i];
err(ans);
}
maxi = 0;
rrep(i, 0, pos) {
if (a[i] <= t[pos]) {
} else {
cout << (0) << endl;
return;
}
}
rrep(i, pos + 1, n) {
if (maxi == a[i])
ans *= a[i];
maxi = a[i];
err(ans);
}
cout << (ans) << endl;
}
|
a.cc: In function 'Mint<MOD> CombMod(int, int)':
a.cc:9:21: error: need 'typename' before 'std::make_signed<decltype (make_pair<int>(r).second)>::type' because 'std::make_signed<decltype (make_pair<int>(r).second)>' is a dependent scope
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:12:19: note: in expansion of macro 'REP'
12 | #define rep(t,...)REP(t,make_pair(__VA_ARGS__))
| ^~~
a.cc:64:3: note: in expansion of macro 'rep'
64 | rep(i, r) { a *= (n - i); }
| ^~~
a.cc:64:7: error: expected ';' before 'i'
64 | rep(i, r) { a *= (n - i); }
| ^
a.cc:9:59: note: in definition of macro 'REP'
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^
a.cc:64:3: note: in expansion of macro 'rep'
64 | rep(i, r) { a *= (n - i); }
| ^~~
a.cc:64:7: error: 'i' was not declared in this scope
64 | rep(i, r) { a *= (n - i); }
| ^
a.cc:9:84: note: in definition of macro 'REP'
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^
a.cc:64:3: note: in expansion of macro 'rep'
64 | rep(i, r) { a *= (n - i); }
| ^~~
a.cc:9:86: error: '_li' was not declared in this scope
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^~
a.cc:12:19: note: in expansion of macro 'REP'
12 | #define rep(t,...)REP(t,make_pair(__VA_ARGS__))
| ^~~
a.cc:64:3: note: in expansion of macro 'rep'
64 | rep(i, r) { a *= (n - i); }
| ^~~
a.cc:9:21: error: need 'typename' before 'std::make_signed<decltype (std::make_pair<int, int>(2, (r + 1)).second)>::type' because 'std::make_signed<decltype (std::make_pair<int, int>(2, (r + 1)).second)>' is a dependent scope
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:12:19: note: in expansion of macro 'REP'
12 | #define rep(t,...)REP(t,make_pair(__VA_ARGS__))
| ^~~
a.cc:65:3: note: in expansion of macro 'rep'
65 | rep(i, 2, r + 1) { b *= i; }
| ^~~
a.cc:65:7: error: expected ';' before 'i'
65 | rep(i, 2, r + 1) { b *= i; }
| ^
a.cc:9:59: note: in definition of macro 'REP'
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^
a.cc:65:3: note: in expansion of macro 'rep'
65 | rep(i, 2, r + 1) { b *= i; }
| ^~~
a.cc:65:7: error: 'i' was not declared in this scope
65 | rep(i, 2, r + 1) { b *= i; }
| ^
a.cc:9:84: note: in definition of macro 'REP'
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^
a.cc:65:3: note: in expansion of macro 'rep'
65 | rep(i, 2, r + 1) { b *= i; }
| ^~~
a.cc:9:86: error: '_li' was not declared in this scope
9 | #define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
| ^~
a.cc:12:19: note: in expansion of macro 'REP'
12 | #define rep(t,...)REP(t,make_pair(__VA_ARGS__))
| ^~~
a.cc:65:3: note: in expansion of macro 'rep'
65 | rep(i, 2, r + 1) { b *= i; }
| ^~~
|
s338014589
|
p03959
|
C++
|
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#define ll __int64
using namespace std;
const ll SUB=1000000007;
int main()
{
int n;
cin>>n;
int *t=new int[n];
int *a=new int[n];
for(int i=0;i<n;i++)cin>>t[i];
for(int i=0;i<n;i++)cin>>a[i];
if(t[n-1]!=a[0])
{
cout<<"0"<<endl;
return 0;
}
ll ans=1;
for(int i=1;i<n-1;i++)
{
if(t[i]!=t[i-1]||a[i]!=a[i+1])continue;
ans*=(min(t[i],a[i])%SUB);
ans%=SUB;
}
cout<<ans<<endl;
return 0;
}
|
a.cc:8:12: error: '__int64' does not name a type; did you mean '__int64_t'?
8 | #define ll __int64
| ^~~~~~~
a.cc:10:7: note: in expansion of macro 'll'
10 | const ll SUB=1000000007;
| ^~
a.cc: In function 'int main()':
a.cc:8:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
8 | #define ll __int64
| ^~~~~~~
a.cc:24:9: note: in expansion of macro 'll'
24 | ll ans=1;
| ^~
a.cc:28:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | ans*=(min(t[i],a[i])%SUB);
| ^~~
| abs
a.cc:28:38: error: 'SUB' was not declared in this scope
28 | ans*=(min(t[i],a[i])%SUB);
| ^~~
a.cc:31:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
31 | cout<<ans<<endl;
| ^~~
| abs
|
s891410877
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
#define clr(a,i) memset((a), (i) ,sizeof(a))
int main(){
int n;
std::cin >> n;
std::vector<long long> t(n), a(n);
long long temp=1;
rep(i,n) std::cin >> t[i];
rep(i,n) std::cin >> a[i];
if(t[t.size()-1]!=a[0]) {
std::cout << "0" << std::endl;
return 0;
}
long long ma=a[0];
bool b=false;
rep(i,n){
if(i==0||i==n-1) continue;
if(t[i]==ma&&a[i]==ma) b=true;
else if(t[i]==ma&&a[i]!=ma&&b=false){
std::cout << "0" << std::endl;
return 0;
}
if(t[i]==t[i-1]&&t[i]<=t[i+1]&&a[i]<=a[i-1]a[i]==a[i+1]){
tmp*=min(a[i],t[i])-1;
tmp%=1000000007;
}
}
std::cout << tmp << std::endl;
}
|
a.cc: In function 'int main()':
a.cc:46:31: error: lvalue required as left operand of assignment
46 | else if(t[i]==ma&&a[i]!=ma&&b=false){
a.cc:50:48: error: expected ')' before 'a'
50 | if(t[i]==t[i-1]&&t[i]<=t[i+1]&&a[i]<=a[i-1]a[i]==a[i+1]){
| ~ ^
| )
a.cc:51:7: error: 'tmp' was not declared in this scope; did you mean 'temp'?
51 | tmp*=min(a[i],t[i])-1;
| ^~~
| temp
a.cc:55:16: error: 'tmp' was not declared in this scope; did you mean 'temp'?
55 | std::cout << tmp << std::endl;
| ^~~
| temp
|
s575515706
|
p03959
|
C++
|
//ここからテンプレート
//#define PLASMA_NO_BOOST
#if 1
#include<iostream>
#include<list>
#include<algorithm>
#include<utility>
#include<type_traits>
#include<tuple>
#include<memory>
#include<iterator>
#include<string>
#include<functional>
#include<list>
#include<array>
#include<complex>
#include<numeric>
#include<iomanip>
#include<vector>
#include<queue>
#include<random>
#include<map>
#include<chrono>
#include<stack>
#include<set>
#ifndef PLASMA_NO_BOOST
#include<boost/optional.hpp>
#include<boost/optional/optional_io.hpp>
#include<boost/variant.hpp>
#include<boost/range/adaptor/transformed.hpp>
#include<boost/range/adaptor/indexed.hpp>
#include<boost/range/adaptor/filtered.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/irange.hpp>
#include<boost/multi_array.hpp>
#include<boost/preprocessor.hpp>
#endif
typedef long long int int64;
typedef unsigned long long uint64;
typedef long double double64;
#ifdef PLASMA_NO_BOOST
struct none_t {};
constexpr none_t none{};
template<class T>class optional
{
union inside_t
{
T value;
none_t ignore;
constexpr inside_t(T const& v) :value(v) {}
constexpr inside_t(T&& v) : value(std::move(v)) {}
constexpr inside_t(none_t) : ignore(none) {}
constexpr inside_t() : ignore(none) {}
constexpr inside_t(inside_t const&) = default;
inside_t(inside_t&&) = default;
inside_t& operator=(inside_t const&) = default;
inside_t& operator=(inside_t&&) = default;
~inside_t() = default;
};
inside_t inside;
bool flag;
public:
void swap(optional&& v)
{
std::swap(this->inside, v.inside);
std::swap(this->flag, v.flag);
}
void reset()
{
if (flag)
{
inside.value.~T();
inside.ignore = none;
flag = false;
}
}
constexpr optional(T const& v) :inside(v), flag(true) {}
constexpr optional(T&& v) : inside(std::move(v)), flag(true) {}
constexpr optional(none_t) : inside(), flag(false) {}
constexpr optional() : inside(), flag(false) {}
constexpr optional(optional const& v) : inside(v.inside), flag(v.flag) {}
optional(optional&& v) : optional()
{
swap(std::move(v));
}
optional& operator=(optional const& v)
{
this->inside = v.inside;
this->flag = v.flag;
return *this;
}
optional& operator=(optional&& v)
{
swap(std::move(v));
v.reset();
return *this;
}
optional& operator=(T const& v)
{
reset();
inside.value = v;
flag = true;
return *this;
}
optional& operator=(T&& v)
{
reset();
inside.value = std::move(v);
flag = true;
return *this;
}
optional& operator=(none_t)
{
reset();
return *this;
}
constexpr operator bool()const
{
return flag;
}
constexpr T const& operator*()const
{
return flag ? inside.value : throw std::domain_error("optional error: dont have value");
}
};
template<class T>constexpr optional<typename std::remove_reference<typename std::remove_const<T>::type>::type>make_optional(T&& v)
{
return optional<std::remove_reference_t<std::remove_const_t<T>>>(std::forward<T>(v));
}
#else
using boost::optional;
using boost::none_t;
using boost::none;
#endif
#ifndef PLASMA_NO_BOOST
namespace adaptor
{
using namespace boost::adaptors;
}
namespace algorithm
{
using namespace boost::range;
template<class SinglePassRange, class Pred>bool any_of(SinglePassRange const& range, Pred pred)
{
return std::any_of(std::begin(range), std::end(range), pred);
}
template<class SinglePassRange, class Pred>bool all_of(SinglePassRange const& range, Pred pred)
{
return std::all_of(std::begin(range), std::end(range), pred);
}
}
#endif
namespace math
{
template<class T>constexpr T pow(T p, int n)
{
return n == 0 ? T(1) : n == 1 ? p : n == 2 ? p*p : n % 2 == 0 ? pow(pow(p, n / 2), 2) : pow(pow(p, n / 2), 2)*p;
}
int log(long long int p, int n)
{
int64 t = n;
for (int i = 0;;++i)
{
if (t > p)
return i;
t *= n;
}
}
constexpr double pi = 3.141592653589793;
namespace detail
{
int gcd(int larger, int less)
{
return less == 0 ? larger : gcd(less, larger%less);
}
}
int gcd(int lhs, int rhs)
{
return lhs < rhs ? detail::gcd(rhs, lhs) : detail::gcd(lhs, rhs);
}
void fourier_transform(
std::vector<std::complex<double>>& vec, std::size_t N)
{
std::vector<std::complex<double>> butterfly;
vec.resize(N);
butterfly.resize(N);
std::complex<double> half(std::cos(pi), std::sin(pi));
for (uint64 i = 1, k = N / 2;i < N;[&]() {i *= 2;k /= 2;}())//i*k == N/4
{
std::complex<double> circle(std::cos(pi / i), std::sin(pi / i));
std::complex<double> c(1.0, 0);
for (auto count = 0ull; count < i;++count)
{
for (auto j = 0ull;j < k;++j)
{
butterfly[count*k + j] =
vec[2 * count*k + j] + vec[2 * count*k + j + k] * c;
butterfly[count*k + j + N / 2] =
vec[2 * count*k + j] + vec[2 * count*k + j + k] * c*half;
}
c *= circle;
}
std::swap(vec, butterfly);
}
}
class polynomial
{
std::vector<std::complex<double>> value;
void swap(polynomial&& p)
{
std::swap(value, p.value);
}
public:
polynomial() :value{ 0.0 } {}
polynomial(polynomial const&) = default;
polynomial(std::vector<std::complex<double>>&& vec) :value(std::move(vec)) {}
polynomial(polynomial&& p) :polynomial()
{
swap(std::move(p));
}
polynomial(std::initializer_list<std::complex<double>> lis) :value(lis) {}
polynomial(std::complex<double> c) :polynomial({ c }) {}
polynomial& operator=(polynomial const&) = default;
polynomial& operator=(polynomial&& p)
{
value = std::vector<std::complex<double>>{ 0.0 };
swap(std::move(p));
return *this;
}
~polynomial() = default;
std::complex<double> operator[](std::size_t deg)const
{
return deg >= value.size() ? 0.0 : value[deg];
}
std::size_t degree()const
{
return value.size() - 1;
}
void strict_degree_set()
{
std::size_t N = degree();
for (;N > 0;--N)
{
if (value[N] != 0.0)
break;
}
value.resize(N + 1);
}
void integer_degree_set()
{
std::size_t N = degree();
for (;N > 0;--N)
{
std::cout << value[N] << " " << (std::norm(value[N]) > (1.0e-20)) << std::endl;
if (std::norm(value[N]) > (1.0e-20))
break;
}
value.resize(N + 1);
}
friend polynomial operator*(polynomial const& lhs, polynomial const& rhs)
{
std::size_t N = 1;
while (true)
{
N *= 2;
if (N > (lhs.degree() + rhs.degree()))
break;
}
auto lhs_ = lhs.value;
auto rhs_ = rhs.value;
fourier_transform(lhs_, N);
fourier_transform(rhs_, N);
std::vector<std::complex<double>> vec;
vec.reserve(N);
for (std::size_t i = 0;i < N;++i)
{
vec.push_back(lhs_[i] * rhs_[i]);
}
for (auto& v : vec)
{
v = 2 * v.real() - v;
}
fourier_transform(vec, N);
for (auto& v : vec)
{
v = (2 * v.real() - v)*(1.0 / N);
}
std::size_t k = N;
for (;k > 0;--k)
{
if (std::norm(vec[k]) > 1.0e-23)
break;
}
vec.resize(k + 1);
return polynomial(std::move(vec));
}
};
int real_integer(std::complex<double> c)
{
int v = static_cast<int>(c.real());
double u = c.real() - v;
return v + static_cast<int>(2 * u);
}
template<class T>polynomial make_poly(std::vector<T> const& vec)
{
auto range = vec | adaptor::transformed([](T const& v) {return static_cast<std::complex<double>>(v);});
std::vector<std::complex<double>> ret(std::begin(range), std::end(range));
return polynomial(std::move(ret));
}
polynomial make_poly(std::initializer_list<double>init)
{
std::vector<std::complex<double>> vec;
for (auto v : init)
{
vec.emplace_back(v);
}
return polynomial(std::move(vec));
}
polynomial make_poly(std::initializer_list<int> init)
{
std::vector<std::complex<double>> vec;
for (auto v : init)
{
vec.emplace_back(v);
}
return polynomial(std::move(vec));
}
template<class T>class infinite_value
{
optional<T> val;
public:
infinite_value(T const& v) :val(v) {}
infinite_value(T&& v) :val(std::move(v)) {}
infinite_value(none_t = none) :val() {}
infinite_value(infinite_value const&) = default;
infinite_value(infinite_value&&) = default;
~infinite_value() = default;
infinite_value& operator=(T const& v)
{
val = v;
return *this;
}
infinite_value& operator=(T&& v)
{
val = std::move(v);
return *this;
}
infinite_value& operator=(none_t)
{
val = boost::none;
return *this;
}
infinite_value& operator=(infinite_value const&) = default;
infinite_value& operator=(infinite_value&&) = default;
operator bool()const
{
return static_cast<bool>(val);
}
T const& operator*()const
{
return *val;
}
friend infinite_value operator+(infinite_value const& lhs, infinite_value const& rhs)
{
return lhs&&rhs ? infinite_value<T>(*lhs + *rhs) : infinite_value<T>(none);
}
friend infinite_value operator+(infinite_value const& lhs, T const& rhs)
{
return lhs ? infinite_value<T>(*lhs + rhs) : infinite_value<T>(none);
}
friend infinite_value operator+(T const& lhs, infinite_value const& rhs)
{
return lhs&&rhs ? infinite_value<T>(*lhs + *rhs) : infinite_value<T>(none);
}
friend bool operator==(infinite_value const& lhs, infinite_value const& rhs)
{
return (!lhs && !rhs) || (lhs&&rhs && (*lhs == *rhs));
}
friend bool operator==(infinite_value const& lhs, T const& rhs)
{
return lhs && (*lhs == rhs);
}
friend bool operator==(T const& lhs, infinite_value const& rhs)
{
return rhs && (lhs == *rhs);
}
friend bool operator<(infinite_value const& lhs, infinite_value const& rhs)
{
return !lhs ? false : !rhs ? true : *lhs < *rhs;
}
friend bool operator<(infinite_value const& lhs, T const& rhs)
{
return !lhs ? false : *lhs < rhs;
}
friend bool operator<(T const& lhs, infinite_value const& rhs)
{
return !rhs ? true : lhs < *rhs;
}
friend bool operator<=(infinite_value const& lhs, infinite_value const& rhs)
{
return (lhs < rhs) || (lhs == rhs);
}
friend bool operator<=(infinite_value const& lhs, T const& rhs)
{
return (lhs < rhs) || (lhs == rhs);
}
friend bool operator<=(T const& lhs, infinite_value const& rhs)
{
return (lhs < rhs) || (lhs == rhs);
}
friend bool operator>(infinite_value const& lhs, infinite_value const& rhs)
{
return !rhs ? false : !lhs ? true : *lhs > *rhs;
}
friend bool operator>(infinite_value const& lhs, T const& rhs)
{
return !lhs ? true : *lhs > rhs;
}
friend bool operator>(T const& lhs, infinite_value const& rhs)
{
return !rhs ? false : lhs > *rhs;
}
friend bool operator>=(infinite_value const& lhs, infinite_value const& rhs)
{
return (lhs > rhs) || (lhs == rhs);
}
friend bool operator>=(infinite_value const& lhs, T const& rhs)
{
return (lhs > rhs) || (lhs == rhs);
}
friend bool operator>=(T const& lhs, infinite_value const& rhs)
{
return (lhs > rhs) || (lhs == rhs);
}
};
template<std::size_t Mod>class modulo_number
{
uint64 val = {};
static constexpr uint64 abs(int64 n)
{
return n <= -1 ? n + Mod : n;
}
public:
modulo_number(modulo_number const&) = default;
modulo_number(modulo_number&&) = default;
modulo_number& operator=(modulo_number const&) = default;
modulo_number& operator=(modulo_number&&) = default;
~modulo_number() = default;
constexpr modulo_number(uint64 num = {}) : val(num%Mod) {}
constexpr modulo_number(unsigned int num) : val(num%Mod) {}
constexpr modulo_number(int64 num) : val(abs(num%Mod)) {}
constexpr modulo_number(int num) : val(abs(num%Mod)) {}
modulo_number& operator=(uint64 num)
{
val = num%Mod;
return *this;
}
modulo_number& operator=(int64 num)
{
val = abs(num%Mod);
return *this;
}
modulo_number& operator=(unsigned int num)
{
val = num%Mod;
return *this;
}
modulo_number& operator=(int num)
{
val = abs(num%Mod);
return *this;
}
constexpr uint64 get()const
{
return val;
}
friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>((lhs.val + rhs.val) % Mod);
}
friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, int const& rhs)
{
return lhs + modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, unsigned int const& rhs)
{
return lhs + modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, int64 const& rhs)
{
return lhs + modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, uint64 const& rhs)
{
return lhs + modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator+(int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) + rhs;
}
friend constexpr modulo_number<Mod> operator+(unsigned int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) + rhs;
}
friend constexpr modulo_number<Mod> operator+(int64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) + rhs;
}
friend constexpr modulo_number<Mod> operator+(uint64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) + rhs;
}
friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>((lhs.val + Mod - rhs.val) % Mod);
}
friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, int const& rhs)
{
return lhs - modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, unsigned int const& rhs)
{
return lhs - modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, int64 const& rhs)
{
return lhs - modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, uint64 const& rhs)
{
return lhs - modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator-(int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) - rhs;
}
friend constexpr modulo_number<Mod> operator-(unsigned int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) - rhs;
}
friend constexpr modulo_number<Mod> operator-(int64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) - rhs;
}
friend constexpr modulo_number<Mod> operator-(uint64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) - rhs;
}
friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>((lhs.val*rhs.val) % Mod);
}
friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, int const& rhs)
{
return lhs * modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, unsigned int const& rhs)
{
return lhs * modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, int64 const& rhs)
{
return lhs * modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, uint64 const& rhs)
{
return lhs * modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator*(int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) * rhs;
}
friend constexpr modulo_number<Mod> operator*(unsigned int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) * rhs;
}
friend constexpr modulo_number<Mod> operator*(int64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) * rhs;
}
friend constexpr modulo_number<Mod> operator*(uint64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) * rhs;
}
friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs)
{
return lhs*math::pow(rhs, Mod - 2);
}
friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, int const& rhs)
{
return lhs / modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, unsigned int const& rhs)
{
return lhs / modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, int64 const& rhs)
{
return lhs / modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, uint64 const& rhs)
{
return lhs / modulo_number<Mod>(rhs);
}
friend constexpr modulo_number<Mod> operator/(int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) / rhs;
}
friend constexpr modulo_number<Mod> operator/(unsigned int const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) / rhs;
}
friend constexpr modulo_number<Mod> operator/(int64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) / rhs;
}
friend constexpr modulo_number<Mod> operator/(uint64 const& lhs, modulo_number<Mod>const& rhs)
{
return modulo_number<Mod>(lhs) / rhs;
}
template<class Rhs>decltype(auto) operator+=(Rhs const& rhs)
{
return *this = *this + rhs;
}
template<class Rhs>decltype(auto) operator*=(Rhs const& rhs)
{
return *this = *this * rhs;
}
template<class Rhs>decltype(auto) operator-=(Rhs const& rhs)
{
return *this = *this - rhs;
}
template<class Rhs>decltype(auto) operator/=(Rhs const& rhs)
{
return *this = *this / rhs;
}
};
template<class T>constexpr T factorial(std::size_t n, std::size_t goal = 1)
{
return n == goal ? T(n) : n == 0 ? T(1) : factorial<T>(n, (n + goal) / 2 + 1)*factorial<T>((n + goal) / 2, goal);
}
namespace detail
{
constexpr uint64 integral_sqrt_i(uint64 v, uint64 start, uint64 end)
{
return start == end ? start :
pow((start + end) / 2 + 1, 2) <= v ?
integral_sqrt_i(v, (start + end) / 2 + 1, end) :
integral_sqrt_i(v, start, (start + end) / 2);
}
}
constexpr uint64 integral_sqrt(uint64 v)
{
return v == 0 ? 0 :
v == 1 ? 1 :
detail::integral_sqrt_i(v, 1, 0b100000000000000000000000000000000ull);
}
namespace detail
{
constexpr bool is_prime_i(uint64 v, uint64 start, uint64 end)
{
return start == end ? v%end != 0 :
is_prime_i(v, start, (start + end) / 2) &&
is_prime_i(v, (start + end) / 2 + 1, end);
}
}
constexpr bool is_prime(uint64 v)
{
return v == 0 ? false :
v == 1 ? false :
v == 2 ? true :
v == 3 ? true : detail::is_prime_i(v, 2, integral_sqrt(v));
}
class dynamic_modulo
{
uint64 value;
uint64 mod;
static constexpr uint64 abs(int64 v, uint64 mod)
{
return v <= -1 ? v + mod : v;
}
public:
constexpr dynamic_modulo() :value(), mod(2) {}
constexpr dynamic_modulo(uint64 v, uint64 m) : value(v), mod(m) {}
dynamic_modulo(dynamic_modulo const&) = default;
dynamic_modulo(dynamic_modulo&&) = default;
dynamic_modulo& operator=(dynamic_modulo const&) = default;
dynamic_modulo& operator=(dynamic_modulo&&) = default;
~dynamic_modulo() = default;
constexpr uint64 get()const
{
return value;
}
constexpr friend auto operator+(dynamic_modulo const& lhs, dynamic_modulo const& rhs)
{
return lhs.mod != rhs.mod ?
throw std::logic_error("math::dynamic_modulo mod number error") :
dynamic_modulo((lhs.value + rhs.value) % lhs.mod, lhs.mod);
}
constexpr friend auto operator+(dynamic_modulo const& lhs, uint64 const& rhs)
{
return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator+(dynamic_modulo const& lhs, int64 const& rhs)
{
return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator+(dynamic_modulo const& lhs, unsigned int const& rhs)
{
return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator+(dynamic_modulo const& lhs, int const& rhs)
{
return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator+(uint64 const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator+(int64 const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator+(unsigned int const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator+(int const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator*(dynamic_modulo const& lhs, dynamic_modulo const& rhs)
{
return lhs.mod != rhs.mod ?
throw std::logic_error("math::dynamic_modulo mod number error") :
dynamic_modulo((lhs.value * rhs.value) % lhs.mod, lhs.mod);
}
constexpr friend auto operator*(dynamic_modulo const& lhs, uint64 const& rhs)
{
return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator*(dynamic_modulo const& lhs, int64 const& rhs)
{
return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator*(dynamic_modulo const& lhs, unsigned int const& rhs)
{
return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator*(dynamic_modulo const& lhs, int const& rhs)
{
return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator*(uint64 const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator*(int64 const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator*(unsigned int const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod);
}
constexpr friend auto operator*(int const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(dynamic_modulo const& lhs, dynamic_modulo const& rhs)
{
return lhs.mod != rhs.mod ?
throw std::logic_error("math::dynamic_modulo mod number error") :
dynamic_modulo(abs((lhs.value - rhs.value) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(dynamic_modulo const& lhs, uint64 const& rhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(dynamic_modulo const& lhs, int64 const& rhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(dynamic_modulo const& lhs, unsigned int const& rhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(dynamic_modulo const& lhs, int const& rhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(uint64 const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(int64 const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(unsigned int const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
constexpr friend auto operator-(int const& rhs, dynamic_modulo const& lhs)
{
return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod);
}
template<class Rhs>dynamic_modulo& operator+=(Rhs const& rhs)
{
return *this = *this + rhs;
}
template<class Rhs>dynamic_modulo& operator-=(Rhs const& rhs)
{
return *this = *this - rhs;
}
template<class Rhs>dynamic_modulo& operator*=(Rhs const& rhs)
{
return *this = *this * rhs;
}
};
}
namespace geometry
{
template<class Type>struct point
{
Type x, y;
};
template<class Type>auto make_point(Type x, Type y)
{
return point<Type>{x, y};
}
template<class Type>auto operator+(point<Type>const& lhs, point<Type>const& rhs)
{
return make_point(lhs.x + rhs.x, lhs.y + rhs.y);
}
template<class Type>auto operator-(point<Type>const& lhs, point<Type>const& rhs)
{
return make_point(lhs.x - rhs.x, lhs.y - rhs.y);
}
template<class Point>struct box
{
Point small, large;
};
template<class Point>auto make_box(Point a, Point b)
{
return box<Point>{
make_point(std::min(a.x, b.x), std::min(a.y, b.y)),
make_point(std::max(a.x, b.x), std::max(a.y, b.y))};
}
#ifndef PLASMA_NO_BOOST
template<class Point>boost::optional<box<Point>> hit_check(box<Point> a, box<Point> b)
{
if (a.small.x > b.small.x)
std::swap(a, b);
if (a.large.x < b.small.x)
return boost::none;
auto small_x = b.small.x;
auto large_x = std::min(b.large.x, a.large.x);
if (a.small.y < b.small.y)
{
if (b.small.y < a.large.y)
return make_box(
make_point(small_x, b.small.y),
make_point(large_x, std::min(a.large.y, b.large.y)));
else
return boost::none;
}
else
{
if (a.small.y < b.large.y)
return make_box(
make_point(small_x, a.small.y),
make_point(large_x, std::min(a.large.y, b.large.y)));
else
return boost::none;
}
}
#endif
}
namespace graph_traits
{
class graph
{
std::vector<int64> node_data;
std::vector<std::vector<std::pair<int, int64>>> edge_data;
public:
graph() = default;
graph(std::vector<int64>&& n) :node_data(std::move(n)), edge_data{}
{
edge_data.resize(node_data.size());
}
graph(std::size_t size) :node_data(size), edge_data{}
{
}
void resize(int size)
{
node_data.resize(size);
edge_data.resize(size);
}
void edge_reserve(int size)
{
for (auto& v : edge_data)
{
v.reserve(size);
}
}
void add_node(int64 data)
{
node_data.emplace_back(data);
edge_data.emplace_back();
}
void add_edge(int from, int to, int64 data)
{
edge_data[from].emplace_back(to, data);
}
std::vector<math::infinite_value<int64>> dijkstra(int from)const
{
struct compare
{
bool operator()(
std::pair<int, math::infinite_value<int64>>const& lhs,
std::pair<int, math::infinite_value<int64>>const& rhs)const
{
return lhs.second > rhs.second;
}
};
std::priority_queue<
std::pair<int, math::infinite_value<int64>>,
std::vector<std::pair<int, math::infinite_value<int64>>>,
compare>nodes;
std::vector<math::infinite_value<int64>> ret(node_data.size());
for (int i{};i < node_data.size();++i)
{
nodes.emplace(i, math::infinite_value<int64>());
}
nodes.emplace(from, int());
while (nodes.size())
{
auto p = nodes.top();
nodes.pop();
if (ret[p.first] <= p.second)
continue;
ret[p.first] = p.second;
for (auto const& d : edge_data[p.first])
{
nodes.emplace(d.first, std::min(ret[d.first], ret[p.first] + d.second));
}
}
return ret;
}
int64 operator[](int n)const
{
return node_data[n];
}
};
}
namespace container
{
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}
void Main(std::integral_constant<int, 1>);
void Main(std::integral_constant<int, 2>);
void Main(std::integral_constant<int, 3>);
void Main(std::integral_constant<int, 4>);
void Main(std::integral_constant<int, 5>);
#endif//テンプレートここまで
//ここを書き換える
constexpr int problem = 3;
//ここは書き換えない
int main()
{
std::cin.sync_with_stdio(false);
std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
Main(std::integral_constant<int, problem>{});
}
void Main(std::integral_constant<int, 1>)
{
std::string str;
std::cin >> str;
bool f{};
for (auto c : str)
{
if (!f&&c == 'C')
{
f = true;
}
else if (f&&c == 'F')
{
std::cout << "Yes" << std::endl;
return;
}
}
std::cout << "No" << std::endl;
}
void Main(std::integral_constant<int, 2>)
{
int K, T;
std::cin >> K >> T;
std::vector<int> a(T);
for (auto& v : a)
{
std::cin >> v;
}
int before = -1;
for (int i{};i < K;++i)
{
int max{};
int max2{};
int index = -1;
int index2 = -1;
for (int x{};x < T;++x)
{
if (max < a[x])
{
max2 = max;
index2 = index;
max = a[x];
index = x;
}
else if (max2 < a[x])
{
max2 = a[x];
index2 = x;
}
}
if (index == -1)
{
std::cout << 0 << std::endl;
return;
}
else if (index2 == -1)
{
std::cout << a[index] - 1 + (before == index) << std::endl;
return;
}
else if (index == before)
{
--a[index2];
before = index2;
}
else
{
--a[index];
before = index;
}
}
std::cout << 0 << std::endl;
}
void Main(std::integral_constant<int, 3>)
{
typedef math::modulo_number<1000000007> number;
int N;
std::cin >> N;
std::vector<number> left_max;
std::vector<number> right_max;
for (int i{};i < N;++i)
{
int64_t v;
std::cin >> v;
left_max.emplace_back(v);
}
for (int i{};i < N;++i)
{
int64_t v;
std::cin >> v;
right_max.emplace_back(v);
}
std::vector<number> max(N);
std::vector<bool> fix(N);
max[0] = left_max[0];
max[N - 1] = right_max[N - 1];
fix[0] = true;
fix[N - 1] = true;
for (int i = 1;i < N;++i)
{
if (left_max[i].get() == left_max[i - 1].get())
{
max[i] = left_max[i - 1];
}
else
{
max[i] = left_max[i];
fix[i] = true;
}
}
for (int i = N - 2;i > 0;--i)
{
if (right_max[i].get() == right_max[i + 1].get())
{
if (fix[i])
{
if (max[i].get() <= right_max[i].get())
{
continue;
}
else
{
std::cout << 0 << std::endl;
return;
}
}
else
{
max[i] = std::min(max[i].get(), right_max[i].get());
}
}
else if(fix[i])
{
if (max[i].get() == right_max[i].get())
{
continue;
}
else
{
std::cout << 0 << std::endl;
return;
}
}
else if (max[i].get() < right_max[i].get())
{
std::cout << 0 << std::endl;
return;
}
else
{
max[i] = right_max[i];
fix[i] = true;
}
}
number ret = 1;
for (int i{};i < N;++i)
{
if (!fix[i])
{
ret *= max[i];
}
}
std::cout << ret.get() << std::endl;
}
void Main(std::integral_constant<int, 4>)
{
}
void Main(std::integral_constant<int, 5>)
{
}
|
a.cc:29:9: fatal error: boost/optional.hpp: No such file or directory
29 | #include<boost/optional.hpp>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s093008296
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
#define clr(a,i) memset((a), (i) ,sizeof(a))
int main(){
int n;
std::cin >> n;
std::vector<long long> t(n), a(n);
long long temp=1;
rep(i,n) std::cin >> t[i];
rep(i,n) std::cin >> a[i];
if(t[t.size()-1]!=a[0]) {
std::cout << "0" << std::endl;
return 0;
}
long long ma=a[0];
bool t=false;
rep(i,n){
if(i==0||i==n-1) continue;
if(t[i]==ma&&a[i]==ma) t=true;
else if(t[i]==ma&&a[i]!=ma&&t=false){
std::cout << "0" << std::endl;
return 0;
}
if(t[i]==t[i-1]&&t[i]<=t[i+1]&&a[i]<=a[i-1]a[i]==a[i+1]){
tmp*=min(a[i],t[i])-1;
tmp%=1000000007;
}
}
std::cout << tmp << std::endl;
}
|
a.cc: In function 'int main()':
a.cc:42:8: error: conflicting declaration 'bool t'
42 | bool t=false;
| ^
a.cc:33:26: note: previous declaration as 'std::vector<long long int> t'
33 | std::vector<long long> t(n), a(n);
| ^
a.cc:45:30: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'bool')
45 | if(t[i]==ma&&a[i]==ma) t=true;
| ^~~~
In file included from /usr/include/c++/14/vector:72,
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/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'bool' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'bool' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'bool' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:46:31: error: no match for 'operator&&' (operand types are 'bool' and 'std::vector<long long int>')
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^~~
| |
| std::vector<long long int>
a.cc:46:31: note: candidate: 'operator&&(bool, bool)' (built-in)
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
a.cc:46:31: note: no known conversion for argument 2 from 'std::vector<long long int>' to 'bool'
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:415:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:46:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:46:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:46:33: note: 'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:46:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed:
a.cc:46:33: note: 'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const valarray<_Tp>&)'
1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed:
a.cc:46:33: note: mismatched types 'const std::valarray<_Tp>' and 'bool'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed:
a.cc:46:33: note: mismatched types 'const std::valarray<_Tp>' and 'bool'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
/usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed:
a.cc:46:33: note: 'std::vector<long long int>' is not derived from 'const std::valarray<_Tp>'
46 | else if(t[i]==ma&&a[i]!=ma&&t=false){
| ^
a.cc:50:48: error: expected ')' before 'a'
50 | if(t[i]==t[i-1]&&t[i]<=t[i+1]&&a[i]<=a[i-1]a[i]==a[i+1]){
| ~ ^
| )
a.cc:51:7: error: 'tmp' was not declared in this scope; did you mean 'temp'?
51 | tmp*=min(a[i],t[i])-1;
| ^~~
| temp
a.cc:55:16: error: 'tmp' was not declared in this scope; did you mean 'temp'?
55 | std::cout << tmp << std::endl;
| ^~~
| temp
|
s807099772
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL n,large=1000000007;
LL f(vector<LL>&d1,vector<LL>d2){
if(d1.back()!=d2[0])cout<<0<<endl;
LL res=1;
for(LL i=1;i<n-1;i++){
LL tmp=0;
if(d1[i]>d1[i-1])tmp=1;
else tmp=d[i];
if(d2[i]>d2[i+1]){if(tmp==1&&d2[i]!=d1[i])return 0;else tmp=1;}
else if(d1[i]>d2[i])return 0;
else tmp=min(tmp,d2[i]);
res=(res*tmp)%large;
}
return res;
}
int main(){
while(cin>>n){
vector<LL>d1(n),d2(n);
for(int i=0;i<n;i++)cin>>d1[i];
for(int i=0;i<n;i++)cin>>d2[i];
cout<<f(d1,d2)<<endl;
}
}
|
a.cc: In function 'LL f(std::vector<long long int>&, std::vector<long long int>)':
a.cc:11:10: error: 'd' was not declared in this scope
11 | else tmp=d[i];
| ^
|
s886597134
|
p03959
|
C++
|
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n) for(int i=0;i<(n);++i)
#define FB(i,n) for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed) for(int i=st;i<(ed);++i)
#define FC(i,n) for(int i=n;i;--i)
#define FZU(i,n) for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed) for(ust i=st;i<(ed);++i)
#define FCU(i,n) for(ust i=n;i;--i)
#define SZ(x) ((int)x.size())
#define ALL(x) std::begin(x),std::end(x)
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))
#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
lnt a[N],b[N];
constexpr lnt mod = 1000000007;
lnt ppp(lnt a,lnt x){
lnt ans = 1;
for(;x;x>>=1){
if(x&1){ans*=a;ans%=mod;}
a=a*a%mod;
}
return ans;
}
bool sol(){
int n;
if(RI(n)==EOF)return 0;
FZ(i,n){int x; RI(x); a[i] = x;}
FZ(i,n){int x; RI(x); b[i] = x;}
auto ml = *max_element(a,a+n);
auto mr = *max_element(b,b+n);
if(ml!=mr){
puts("0");
return 1;
}
auto l = find(a,a+n,ml)-a;
auto r = n;
FB(i,n)if(b[i]==mr){
r = i; break;
}
if(l>r){
puts("0");
return 1;
}
lnt ans = ppp(ml,max(r-l-1,0ll));
reverse(b,b+n);
for(auto c:{a,b}){
lnt last = 0;
FZ(i,n)if(i&&c[i]!=c[i-1]){
//printf("%d %d\n",int(c[i-1]),i-last-1);
ans*= ppp(c[i-1],i-last-1);
ans%=mod;
last = i;
}
}
printf("%d\n",int(ans));
return 1;
}
int main(){
while(sol());
return 0;
}
|
a.cc: In function 'bool sol()':
a.cc:74:25: error: no matching function for call to 'max(long int, long long int)'
74 | lnt ans = ppp(ml,max(r-l-1,0ll));
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906,
from a.cc:6:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:74:25: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
74 | lnt ans = ppp(ml,max(r-l-1,0ll));
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:74:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
74 | lnt ans = ppp(ml,max(r-l-1,0ll));
| ~~~^~~~~~~~~~~
|
s912628331
|
p03959
|
C++
|
#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define putans(x) std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "="; rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;}
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif
#pragma endregion
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion
int main() {
int n; put n;
vi t(n); rep(i, n) put t[i];
vi a(n); rep(i, n) put a[n-1-i];
ll ans = 1;
vi mint(n);
vi maxt(n);
mint[0] = t[0];
maxt[0] = t[0];
vi mina(n);
vi maxa(n);
mina[0] = a[0];
maxa[0] = a[0];
if (n == 1) {
if(t[0] == a[0])putans(1);
else putans(0);
goto END;
}
rep(i, n-1) {
if (t[i + 1] != t[i]) {
mint[i + 1] = t[i + 1];
maxt[i + 1] = t[i + 1];
}
else {
mint[i + 1] = 1;
maxt[i + 1] = t[i + 1];
}
}
rep(i, n - 1) {
if (a[i + 1] != a[i]) {
mina[i + 1] = a[i + 1];
maxa[i + 1] = a[i + 1];
}
else {
mina[i + 1] = 1;
maxa[i + 1] = a[i + 1];
}
}
rep(i, n) {
ll x = min(maxa[i], maxt[n - 1 - i]);
ll y = max(mina[i], mint[n - 1 - i]);
dbg2(x, y);
if (x < y) {
putans(0);
goto END;
}
ans = ( ans* ( x - y + 1 )) % MOD;
}
putans(ans);
END:
return 0;
}
//
//vi v;
//vi w; ;
//ll nz1() {
// return 0;
//}
//
//ll nz2() {
// ll dp[201][1000*200+1];
//
//}
//
//ll nz3() {
//
//}
// int n, wkazu; put n >> wkazu;
// v.resize(200);
// w.resize(200);
// rep(i, n) {
// put v[i] >> w[i];
// }
|
a.cc: In function 'int main()':
a.cc:69:17: error: expected '}' before 'else'
69 | else putans(0);
| ^~~~
a.cc:67:21: note: to match this '{'
67 | if (n == 1) {
| ^
a.cc:70:22: error: label 'END' used but not defined
70 | goto END;
| ^~~
a.cc: At global scope:
a.cc:8:20: error: expected unqualified-id before 'for'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^~~
a.cc:10:18: note: in expansion of macro 'REP'
10 | #define rep(i,n) REP(i,0,n)
| ^~~
a.cc:73:9: note: in expansion of macro 'rep'
73 | rep(i, n-1) {
| ^~~
a.cc:73:13: error: 'i' does not name a type; did you mean 'vi'?
73 | rep(i, n-1) {
| ^
a.cc:8:35: note: in definition of macro 'REP'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^
a.cc:73:9: note: in expansion of macro 'rep'
73 | rep(i, n-1) {
| ^~~
a.cc:73:13: error: 'i' does not name a type; did you mean 'vi'?
73 | rep(i, n-1) {
| ^
a.cc:8:47: note: in definition of macro 'REP'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^
a.cc:73:9: note: in expansion of macro 'rep'
73 | rep(i, n-1) {
| ^~~
a.cc:8:20: error: expected unqualified-id before 'for'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^~~
a.cc:10:18: note: in expansion of macro 'REP'
10 | #define rep(i,n) REP(i,0,n)
| ^~~
a.cc:83:9: note: in expansion of macro 'rep'
83 | rep(i, n - 1) {
| ^~~
a.cc:83:13: error: 'i' does not name a type; did you mean 'vi'?
83 | rep(i, n - 1) {
| ^
a.cc:8:35: note: in definition of macro 'REP'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^
a.cc:83:9: note: in expansion of macro 'rep'
83 | rep(i, n - 1) {
| ^~~
a.cc:83:13: error: 'i' does not name a type; did you mean 'vi'?
83 | rep(i, n - 1) {
| ^
a.cc:8:47: note: in definition of macro 'REP'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^
a.cc:83:9: note: in expansion of macro 'rep'
83 | rep(i, n - 1) {
| ^~~
a.cc:8:20: error: expected unqualified-id before 'for'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^~~
a.cc:10:18: note: in expansion of macro 'REP'
10 | #define rep(i,n) REP(i,0,n)
| ^~~
a.cc:93:9: note: in expansion of macro 'rep'
93 | rep(i, n) {
| ^~~
a.cc:93:13: error: 'i' does not name a type; did you mean 'vi'?
93 | rep(i, n) {
| ^
a.cc:8:35: note: in definition of macro 'REP'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^
a.cc:93:9: note: in expansion of macro 'rep'
93 | rep(i, n) {
| ^~~
a.cc:93:13: error: 'i' does not name a type; did you mean 'vi'?
93 | rep(i, n) {
| ^
a.cc:8:47: note: in definition of macro 'REP'
8 | #define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
| ^
a.cc:93:9: note: in expansion of macro 'rep'
93 | rep(i, n) {
| ^~~
a.cc:6:25: error: 'cerr' in namespace 'std' does not name a type
6 | #define putans(x) std::cerr << "[ answer ]: " ; cout << (x) << endl
| ^~~~
a.cc:103:9: note: in expansion of macro 'putans'
103 | putans(ans);
| ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:64:18: note: 'std::cerr' declared here
64 | extern ostream cerr; ///< Linked to standard error (unbuffered)
| ^~~~
a.cc:6:50: error: 'cout' does not name a type
6 | #define putans(x) std::cerr << "[ answer ]: " ; cout << (x) << endl
| ^~~~
a.cc:103:9: note: in expansion of macro 'putans'
103 | putans(ans);
| ^~~~~~
a.cc:105:1: error: 'END' does not name a type
105 | END:
| ^~~
a.cc:107:1: error: expected declaration before '}' token
107 | }
| ^
|
s142289000
|
p03959
|
C++
|
#ifndef __INTMOD_H__0001__
#define __INTMOD_H__0001__
template <unsigned int Modulus>
class IntMod {
typedef unsigned long long ULL;
private:
unsigned int value_m;
void Copy(const IntMod& other) { value_m = other.value_m; }
bool Modulus_is_valid() { return Modulus != 0; }
public:
IntMod() { value_m = 0; }
IntMod(unsigned int value) { value_m = value % Modulus; }
IntMod(const IntMod& other) { Copy(other); }
IntMod& operator=(const IntMod& other) { Copy(other); return *this; }
IntMod& operator==(const IntMod& right) const { return value_m == right.value_m; }
IntMod& operator!=(const IntMod& right) const { return value_m != right.value_m; }
IntMod& operator++() {
++value_m;
value_m %= Modulus;
return *this;
}
IntMod& operator--() {
if (value_m == 0) { value_m = Modulus - 1; }
else { --value_m; }
return *this;
}
IntMod operator-() const {
if (value_m == 0) return IntMod(0);
return IntMod(Modulus - value_m);
}
IntMod& operator+=(const IntMod& right) {
ULL sum = (ULL)value_m + right.value_m;
if (sum >= (ULL)Modulus) { value_m = (unsigned int)(sum - (ULL)Modulus); }
else { value_m = (unsigned int)sum; }
return *this;
}
IntMod& operator-=(const IntMod& right) {
(*this) += (-right);
return *this;
}
IntMod operator+(const IntMod& right) {
IntMod ret(*this);
ret += right;
return ret;
}
IntMod operator-(const IntMod& right) {
IntMod ret(*this);
ret -= right;
return ret;
}
IntMod& operator*=(const IntMod& right) {
ULL tmp = (ULL)value_m * right.value_m;
value_m = tmp % (ULL)Modulus;
return *this;
}
IntMod& operator/=(const IntMod& right) {
(*this) *= (right.Inverse());
return *this;
}
IntMod operator*(const IntMod& right) {
IntMod ret(*this);
ret *= right;
return ret;
}
IntMod operator/(const IntMod& right) {
IntMod ret(*this);
ret /= right;
return ret;
}
/* 素数判定は自分でしろ */
IntMod Inverse() const {
return (*this).Pow(Modulus - 2);
}
IntMod Pow(unsigned int exp) const {
unsigned int arr[32]; // 32じゃなくてもいい
ULL sum = 1;
arr[0] = value_m;
for (int i = 1; i < 32; ++i) {
arr[i] = ((ULL)arr[i - 1] * arr[i - 1]) % (ULL)Modulus;
}
for (int i = 0; i < 32; ++i) {
if (exp & (0x1 << i)) {
sum *= arr[i]; sum %= (ULL)Modulus;
}
}
return (unsigned int)sum;
}
unsigned int Get_value() {
return value_m;
}
};
#endif
#include "IntMod.h"
typedef IntMod<1000000007> MInt;
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;
typedef unsigned long long ULL;
int N;
int T[100001];
int A[100001];
bool DET[100001];
int LIM[100001];
bool err;
int main() {
cin >> N;
REP(i, 0, N) {
cin >> T[i];
}
REP(i, 0, N) {
cin >> A[i];
}
int cur = 0;
REP(i, 0, N) {
if (cur != T[i]) {
cur = T[i];
DET[i] = true;
LIM[i] = T[i];
} else {
LIM[i] = T[i];
}
}
cur = 0;
for (int i = N - 1; i >= 0; --i) {
if (cur != A[i]) {
if (A[i] > LIM[i]) {
err = true;
} else if (DET[i] == true && A[i] != LIM[i]) {
err = true;
}
cur = A[i];
DET[i] = true;
LIM[i] = A[i];
} else {
if (DET[i] == true && A[i] < LIM[i]) {
err = true;
}
LIM[i] = min(A[i], LIM[i]);
}
}
MInt product = 1;
REP(i, 0, N) {
product *= (DET[i] ? 1 : LIM[i]);
}
cout << (err ? 0 : product).Get_value() << endl;
return 0;
}
|
a.cc:99:10: fatal error: IntMod.h: No such file or directory
99 | #include "IntMod.h"
| ^~~~~~~~~~
compilation terminated.
|
s648191586
|
p03959
|
C++
|
// VSCF.cpp : Defines the entry point for the console application.
//
#include <cassert>
#include <functional>
#include <cmath>
#include <list>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define FOR(v,p,k) for(int v=p;v<=k;++v)
#define FORD(v,p,k) for(int v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define int long long
#define MAXN 1000010
typedef long double LD;
template <typename T>
T modpow(T base, T exp, T modulus) {
base %= modulus;
T result = 1;
while (exp > 0) {
if (exp & 1) result = (result * base) % modulus;
base = (base * base) % modulus;
exp >>= 1;
}
return result;
}
#undef int
int main() {
#define int long long
int n;
cin >> n;
vector<int> mtn(n);
vector<int> inp1(n);
vector<int> inp2(n);
REP(i, n) {
cin >> inp1[i];
}
REP(i, n) {
cin >> inp2[i];
}
mtn[0] = inp1[0];
mtn[n - 1] = inp2[n - 1];
REP(i, n - 1) {
if (inp1[i] < inp1[i + 1]) {
mtn[i + 1] = inp1[i + 1];
}
}
REP(i, n - 1) {
if (inp2[n - i - 2] > inp2[n - i - 1]) {
mtn[n - i - 2] = inp2[n - i - 2];
}
}
int mx = 0;
REP(i, n) {
mx = max(mx, mtn[i]);
if (mx != inp1[i]) {
goto no;
}
}
mx = 0;
REP(i, n) {
mx = max(mx, mtn[n - i - 1]);
if (mx != inp2[n - i - 1]) {
goto no;
}
}
int result = 1;
int mod = 1e9 + 7;
int lastSet = mtn[0];
int len = 0;
for (int i = 1; i < n; i++) {
if (mtn[i]) {
if (mtn[i] >= lastSet) {
result *= modpow(lastSet, len, mod);
result %= mod;
} else {
result *= modpow(mtn[i], len, mod);
result %= mod;
}
len = 0;
lastSet = mtn[i];
} else {
len++;
}
}
cout << result;
return 0;
no:
cout << 0;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:109:1: error: jump to label 'no'
109 | no:
| ^~
a.cc:85:30: note: from here
85 | goto no;
| ^~
a.cc:91:13: note: crosses initialization of 'long long int len'
91 | int len = 0;
| ^~~
a.cc:90:13: note: crosses initialization of 'long long int lastSet'
90 | int lastSet = mtn[0];
| ^~~~~~~
a.cc:89:13: note: crosses initialization of 'long long int mod'
89 | int mod = 1e9 + 7;
| ^~~
a.cc:88:13: note: crosses initialization of 'long long int result'
88 | int result = 1;
| ^~~~~~
a.cc:109:1: error: jump to label 'no'
109 | no:
| ^~
a.cc:78:30: note: from here
78 | goto no;
| ^~
a.cc:91:13: note: crosses initialization of 'long long int len'
91 | int len = 0;
| ^~~
a.cc:90:13: note: crosses initialization of 'long long int lastSet'
90 | int lastSet = mtn[0];
| ^~~~~~~
a.cc:89:13: note: crosses initialization of 'long long int mod'
89 | int mod = 1e9 + 7;
| ^~~
a.cc:88:13: note: crosses initialization of 'long long int result'
88 | int result = 1;
| ^~~~~~
|
s641651104
|
p03959
|
C++
|
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);
int main(){
int n;
cin>>n;
vi a(n),t(n);
rep(i,n) cin>>a[i];
rep(i, n) cin>>t[i];
vi m(n,0), M(n, 0);
M[0] = m[0] = a[0];
REP(i, 1, n){
if(a[i] == a[i-1]) m[i] = 1, M[i] = a[i];
else M[i] = m[i] = a[i];
}
if(M[n-1]<t[n-1] || m[n-1] > t[i]){
cout<<0<<endl;
return 0;
}
M[n-1] = m[n-1] = t[n-1];
for(int i = n -2; i >= 0; i--){
if(t[i]==t[i+1]) m[i] = max(m[i], 1), M[i] = min(M[i], t[i]);
else M[i] = m[i] = t[i];
}
ll ans = 1LL;
rep(i, n) {
(ans *= (M[i]-m[i]+1))%=MOD;
if(M[i]-m[i]<0) ans = 0LL;
}
// cout<<ans<<endl;
// rep(i, n) cout<<m[i]<<" ";
// cout<<endl;
// rep(i, n) cout<<M[i]<<" ";
// cout<<endl;
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:57:40: error: 'i' was not declared in this scope
57 | if(M[n-1]<t[n-1] || m[n-1] > t[i]){
| ^
|
s614837879
|
p03959
|
C++
|
#include <iostream>
using namespace std;
typedef unsigned long long ull;
#define MAX_N 100000
#define MOD 1000000007
int N;
ull T[MAX_N+2], A[MAX_N+2];
bool flagT[MAX_N] = {false}, flagA[MAX_N] = {false};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
T[0] = 0;
A[N+1] = 0;
for(int i=1; i<=N; i++) cin >> T[i];
for(int i=1; i<=N; i++) cin >> A[i];
for(int i=0; i<N; i++){
if(T[i+1] > T[i]) flagT[i+1] = true;
}
for(int i=2; i<N+2; i++){
if(A[i-1] > A[i]) flagA[i-1] = true;
}
for(int i=0; i<=N+1; i++){
cout << flagT[i] << " " << flagA[i] << endl;
}
ull ans = 1;
for(int i=1; i<=N; i++){
if(!flagT[i] && !flagA[i]) ans = (ans * min(A[i], T[i])) % MOD;
|
a.cc: In function 'int main()':
a.cc:33:72: error: expected '}' at end of input
33 | if(!flagT[i] && !flagA[i]) ans = (ans * min(A[i], T[i])) % MOD;
| ^
a.cc:32:28: note: to match this '{'
32 | for(int i=1; i<=N; i++){
| ^
a.cc:33:72: error: expected '}' at end of input
33 | if(!flagT[i] && !flagA[i]) ans = (ans * min(A[i], T[i])) % MOD;
| ^
a.cc:11:11: note: to match this '{'
11 | int main(){
| ^
|
s335242064
|
p03959
|
C++
|
#include<iostream>
#define min(a,b) a<b?a:b
#define MAX 1000000007
using namespace std;
int a[100005][4];
int main(){
__int64 s=1;
int n,m=0;
int i,j,k;
cin>>n;
for(i=0;i<100005;i++){
for(j=0;j<4;j++){
a[i][j]=MAX;
}
}
for(i=0;i<n;i++){
cin>>a[i][0];
}
for(i=0;i<n;i++){
cin>>a[i][1];
}
a[0][2]=a[0][0];
a[0][3]=1;
a[n-1][2]=a[n-1][1];
a[n-1][3]=1;
for(i=1;i<n;i++){
if(a[i-1][0]<a[i][0]){
if(a[i][0]>a[i][1])m=1;
a[i][2]=a[i][0];
a[i][3]=1;
}else if(a[i-1][0]==a[i][0]){
a[i][2]=min(a[i][2],a[i][0]);
}else{
m=1;
}
}
for(i=n-2;i>=0;i--){
if(a[i+1][1]<a[i][1]){
if(a[i][1]>a[i][0])m=1;
a[i][2]=a[i][1];
a[i][3]=1;
}else if(a[i+1][1]==a[i][1]){
a[i][2]=min(a[i][2],a[i][1]);
}else{
m=1;
}
}
if(m==1){
cout<<"0"<<endl;
return 0;
}
for(i=0;i<n;i++){
if(a[i][3]==1)continue;
s*=a[i][2];
s%=MAX;
}
cout<<s<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
7 | __int64 s=1;
| ^~~~~~~
| __int64_t
a.cc:54:17: error: 's' was not declared in this scope
54 | s*=a[i][2];
| ^
a.cc:57:15: error: 's' was not declared in this scope
57 | cout<<s<<endl;
| ^
|
s438130343
|
p03960
|
C++
|
// O(h^3 * w)
// rozwiązanie bazowane na `prog/tar.cpp`,
// ktore za wolno liczy koszty operacji
// autor: Jakub Wasilewski
#include <bits/stdc++.h>
using namespace std;
constexpr int max_h = 300, max_w = 300, none_value = -1, inf = 1e9;
int h, w, grid[max_h + 1][max_w + 1];
int solve(const int v)
{
int dp[max_h + 1][max_h + 1];
int cost[max_h + 1][max_h + 1];
for (int i = 0; i <= h; ++i)
for (int j = 0; j <= h; ++j)
dp[i][j] = cost[i][j] = none_value;
for (int dif = -h; dif <= h; ++dif)
for (int i = max(0, -dif); i + dif <= h and i <= h; ++i)
{
if (min(i, i + dif) == 0)
cost[i][i + dif] = 0;
else
{
assert(cost[i - 1][i + dif - 1] != none_value);
cost[i][i + dif] = 0;
for (int j = 0; j < min(i, i + dif); ++j)
cost[i][i + diff] += (grid[h - i + 1 + j][v] == grid[h - (i + dif) + j][v + 1]);
}
}
for (int i = 0; i <= h; ++i)
for (int j = 0; j <= h; ++j)
{
dp[i][j] = inf;
if (i == 0 and j == 0)
dp[i][j] = 0;
if (i > 0)
dp[i][j] = min(dp[i][j], dp[i - 1][j] + cost[i][j]);
if (j > 0)
dp[i][j] = min(dp[i][j], dp[i][j - 1] + cost[i][j]);
}
return dp[h][h];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> h >> w;
for (int i = h; i >= 1; --i)
{
string s; cin >> s;
for (int j = 1; j <= w; ++j)
grid[i][j] = (s[j - 1] - 'a');
}
int res = 0;
for (int j = 1; j + 1 <= w; ++j)
res += solve(j);
cout << res << '\n';
}
|
a.cc: In function 'int solve(int)':
a.cc:31:33: error: 'diff' was not declared in this scope; did you mean 'dif'?
31 | cost[i][i + diff] += (grid[h - i + 1 + j][v] == grid[h - (i + dif) + j][v + 1]);
| ^~~~
| dif
|
s001246714
|
p03960
|
C++
|
#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
_x = 0;
int _tmp = 1; char _tc = getchar();
while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
if(_tc == '-') _tc = getchar(), _tmp = -1;
while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
_x *= _tmp;
}
inline void output(int _x) {
char _buff[20]; int _f = 0;
if(_x == 0)putchar('0');
while(_x > 0)
{
_buff[_f++] = _x%10+'0';
_x /= 10;
}
for(_f-=1; _f >= 0; _f--)
putchar(_buff[_f]);
putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
s<<"[";
for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
s<<"]";
return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
return _out(s,c.begin(),c.end());
}
#ifdef erd1
#define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
#define pprint(x)
#endif
// code starts here
const int N = 300;
int dp[N+2][N+2]={}, rep[N*2][N+1]={};
vector<string> v;
signed main(){
int h, w;
cin >> h >> w;
for(int i = 0; i < h; i++){
string s;
cin >> s;
v.pb(s);
}
for(int i = 0; i < h; i++)dp[h+1][i] = dp[i][h+1] = 2000000000;
int ans = 0;
for(int i = 0; i < w-1; i++){
for(int diff = -h+1; diff<h; diff++){
for(int j = max(diff, 0); j < h+min(diff, 0); j++){
rep[diff+h][j+1] = rep[diff+h][j] + (v[j][i] == v[j-diff][i+1]);
assert(rep[diff+h][j+1] <= );
}
}
for(int l = h; l>=0; l--){
for(int r = h; r>=0; r--){
dp[l][r] = min(dp[l+1][r]+rep[l+1-r+h][l+1], dp[l][r+1]+rep[l-r-1+h][l]);
assert(rep[l+1-r+h][l+1] < INT_MAX-2000000000);
assert(rep[l-r-1+h][l]< INT_MAX-2000000000);
assert(dp[l][r] < 2000000000);
}
}
ans += dp[0][0];
}
cout << ans << endl;
}
|
In file included from /usr/include/c++/14/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
from a.cc:3:
a.cc: In function 'int main()':
a.cc:82:17: error: expected primary-expression before ')' token
82 | assert(rep[diff+h][j+1] <= );
| ^~~~~~
|
s157013384
|
p03960
|
C++
|
#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
_x = 0;
int _tmp = 1; char _tc = getchar();
while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
if(_tc == '-') _tc = getchar(), _tmp = -1;
while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
_x *= _tmp;
}
inline void output(int _x) {
char _buff[20]; int _f = 0;
if(_x == 0)putchar('0');
while(_x > 0)
{
_buff[_f++] = _x%10+'0';
_x /= 10;
}
for(_f-=1; _f >= 0; _f--)
putchar(_buff[_f]);
putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
s<<"[";
for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
s<<"]";
return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
return _out(s,c.begin(),c.end());
}
#ifdef erd1
#define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
#define pprint(x)
#endif
// code starts here
#define int lld
const int N = 300;
int dp[N+2][N+2], rep[N*2][N+1];
vector<string> v;
signed main(){
int h, w;
cin >> h >> w;
for(int i = 0; i < h; i++){
string s;
cin >> s;
v.pb(s);
}
for(int i = 0; i < h; i++)dp[h+1][i] = dp[i][h+1] = 1000000000;
int ans = 0;
for(int i = 0; i < w-1; i++){
for(int diff = -h+1; diff<h; diff++){
for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
rep[diff+h][j+1] = rep[diff+h][j] + (v[j][i] == v[j-diff][i+1]);
}
}
for(int l = h; l>=0; l--){
for(int r = h; r>=0; r--){
dp[l][r] = min(dp[l+1][r]+rep[l+1-r+h][l+1], dp[l][r+1]+rep[l-r-1+h][l]);
}
}
ans += dp[0][0];
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:81:28: error: no matching function for call to 'max(lld&, long long int)'
81 | for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:81:28: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
81 | for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:81:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
81 | for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
| ~~~^~~~~~~~~~~
a.cc:81:50: error: no matching function for call to 'min(lld&, long long int)'
81 | for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:81:50: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
81 | for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:81:50: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
81 | for(int j = max(diff, 0LL); j < h+min(diff, 0LL); j++){
| ~~~^~~~~~~~~~~
|
s859198636
|
p03960
|
C++
|
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
if(a<b)return b;
else return a;
}
ll lmin(ll a,ll b){
if(a<b)return a;
else return b;
}
ll gcd(ll a,ll b){
if(a<b)swap(a,b);
if(b==0)return a;
if(a%b==0)return b;
return gcd(b,a%b);
}
ll Pow(ll n,ll k){
ll ret=1;
ll now=n;
while(k>0){
if(k&1)ret*=now;
now*=now;
k/=2;
}
return ret;
}
int main(){
int h,w;cin>>h>>w;
string s[h];
rep(i,0,h)cin>>s[i];
ll ans=0;
rep(i,0,w-1){
ll dp[h+1][h+1];
rep(j,0,h+1){
rep(k,0,h+1)dp[j][k]=inf;
}
dp[h][h]=0;
ll sum[h+1][h+1];
ll sum2[h+1][h+1];
rep(j,0,h+1){
sum[j][0]=0;
sum2[j][0]=0;
rep(k,1,h-j+1){
sum[j][k]=sum[j][k-1];
sum2[j][k]=sum2[j][k-1]
if(s[k-1][i]==s[k-1+j][i+1])sum[j][k]++;
if(s[k-1][i+1]==s[k-1+j][i])sum2[j][k]++;
}
}
rrep(j,h,0){
rrep(k,h,0){
if(j>0){
if(j-1<=k){
ll sa=k-j+1;
dp[j-1][k]=min(dp[j-1][k],dp[j][k]+sum[sa][j-1]);
}
else{
ll sa=j-1-k;
dp[j-1][k]=min(dp[j-1][k],dp[j][k]+sum2[sa][k]);
}
}
if(k>0){
if(k-1<=j){
ll sa=j-k+1;
dp[j][k-1]=min(dp[j][k-1],dp[j][k]+sum2[sa][k-1]);
}
else{
ll sa=k-1-j;
dp[j][k-1]=min(dp[j][k-1],dp[j][k]+sum[sa][j]);
}
}
}
}
ans+=dp[0][0];
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:67:32: error: expected ';' before 'if'
67 | sum2[j][k]=sum2[j][k-1]
| ^
| ;
68 | if(s[k-1][i]==s[k-1+j][i+1])sum[j][k]++;
| ~~
|
s340419882
|
p03960
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e8, Nmax = 303;
int n, m, i, j, ans;
char a[Nmax][Nmax], ch[Nmax];
int solve(char a[], char b[])
{
int i, j, cost[Nmax][Nmax], dp[Nmax][Nmax];
for(i=0; i<=n; ++i) dp[i][n+1] = dp[n+1][i] = inf, cost[i][0] = cost[0][i] = 0;
for(i=1; i<=n; ++i)
for(j=1; j<=n; ++j)
cost[i][j] = cost[i-1][j-1] + (a[i]==b[j]);
for(i=n; i>=0; --i)
for(j=n; j>=0; --j)
{
if(i==n && j==n) dp[n][n] = 0;
else dp[i][j] = min(dp[i][j+1] + cost[i][j+1], dp[i+1][j] + cost[i+1][j]);
}
return dp[0][0];
}
int main()
{
// freopen("friction.in", "r", stdin);
// freopen("friction.out", "w", stdout);
scanf("%d %d\n", &n, &m);
for(i=1; i<=n; ++i)
{
gets(ch+1);
for(j=1; j<=m; ++j)
a[j][n-i+1] = ch[j];
}
for(i=1; i<m; ++i)
ans += solve(a[i], a[i+1]);
printf("%d\n", ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:39:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
39 | gets(ch+1);
| ^~~~
| getw
|
s818169331
|
p03960
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int ans, N, M, cst[609][309], dp[309][309];
char sir[309][309], A[309], B[309];
int solve ()
{
for (int i=0; i<=2 * N; i++)
for (int j=0; j<=N; j++)
cst[i][j] = 0;
for (int i=1; i<=N; i++)
for (int j=1; j<=N; j++)
cst[j - i + N][N - i] += (A[i] == B[j]);
///trebuie ca sa fie considerat in cost[i1][i2] ca: i1 - i2 = j - i
///si ca i + i1 <= N-> i1 <= N - i
for (int i=0; i<=2 * N; i++)
for (int j=N; j>0; j--)
cst[i][j - 1] += cst[i][j];
///dp[i1][i2] daca am dat de i1 in jos primul sir si de i2 in jos pe al doilea
dp[0][0] = cst[N][0];
for (int i=0; i<=N; i++)
for (int j=0; j<=N; j++)
if (i + j)
{
int curr = cst[i - j + N][i];
if (i == 0) dp[i][j] = dp[i][j - 1];
else
if (j == 0) dp[i][j] = dp[i - 1][j];
else dp[i][j] = min (dp[i][j - 1], dp[i - 1][j]);
dp[i][j] += curr;
}
return dp[N][N];
}
int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);
scanf ("%d %d\n", &N, &M);
for (int i=1; i<=N; i++)
gets (sir[i] + 1);
for (int j=1; j<M; j++)
{
for (int i=1; i<=N; i++)
A[i] = sir[i][j], B[i] = sir[i][j + 1];
ans += solve ();
}
printf ("%d\n", ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:44:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
44 | gets (sir[i] + 1);
| ^~~~
| getw
|
s758219666
|
p03960
|
C++
|
N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
for t in range(M-1):
for i in range(1,N+1):
for j in range(1,N+1):C[i][j]=C[i-1][j-1]+int(S[i-1][t]==S[j-1][t+1]);D[i][j]=min(D[i-1][j],D[i][j-1])+C[i][j]
r+=D[N][N]
print(r)
|
a.cc:1:1: error: 'N' does not name a type
1 | N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
| ^
a.cc:1:30: error: 'C' does not name a type
1 | N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
| ^
a.cc:1:62: error: 'D' does not name a type
1 | N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
| ^
a.cc:1:82: error: 'S' does not name a type
1 | N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
| ^
a.cc:1:111: error: 'r' does not name a type
1 | N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
| ^
a.cc:4:87: error: 'D' does not name a type
4 | for j in range(1,N+1):C[i][j]=C[i-1][j-1]+int(S[i-1][t]==S[j-1][t+1]);D[i][j]=min(D[i-1][j],D[i][j-1])+C[i][j]
| ^
|
s355010142
|
p03960
|
C++
|
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
using namespace std;
#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)
struct UnionFind {
vector<ll> data;
UnionFind(ll size) : data(size, -1) { }
bool unionSet(ll x, ll y) {
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool findSet(ll x, ll y) {
return root(x) == root(y);
}
ll root(ll x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
ll size(ll x) {
return -data[root(x)];
}
};
int cost[400][400];
int dp[400][400];
int main()
{
int h, w;
cin >> h >> w;
vector<string> cs(h);
for(int i = 0;i < h;i++)
{
cin >> cs[i];
}
ll costSum = 0;
for(int i = 0; i < w - 1; i++){
memset(cost, 0, sizeof(cost));
memset(dp, 0, sizeof(dp));
for(int j = 1; j <= h; j++){
for(int k = 1; k <= h; k++){
cost[j][k] = cost[j - 1][k - 1];
cost[j][k] += (cs[j - 1][i] == cs[k - 1][i + 1]);
dp[j][k] = 1e7;
}
}
for(int j = 1; j <= h; j++){
for(int k = 1; k <= h; k++){
dp[j][k] = min(dp[j][k], dp[j - 1][k]);
dp[j][k] = min(dp[j][k], dp[j][k - 1]);
dp[j][k] += cost[j][k];
}
}
costSum += dp[h][h];
}
cout << costSum << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:59:9: error: 'memset' was not declared in this scope
59 | memset(cost, 0, sizeof(cost));
| ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
13 | #include <unordered_set>
+++ |+#include <cstring>
14 | #include <sstream>
|
s953063517
|
p03960
|
C++
|
#include <iostream>
#include <cctype>
#include <cstdio>
#include <string>
#include <typeinfo>
#include <queue>
using namespace std;
int cost(int,int,int);
int min (int,int);
int h,w;
int d[301][301];
char c[][];
int z;
int main() {
cin>>h>>w;
for (int i = 0; i < h; ++i)
{
for (int j = 0; j < w; ++j)
{
cin>>c[i][j];
}
}
/*
cout<<cost(0,0)<<endl;
*/
for (int t = 0; t < w-1; ++t)
{
for (int i = 0; i <= h; ++i)
{
for (int j = 0; j <=w; ++j)
{
d[i][j]=0;
}
}
for (int i = 1; i <= h; ++i)
{
d[i][0]=d[i-1][0]+cost(i-1,0,t);
d[0][i]=d[0][i-1]+cost(0,i-1,t);
}
for (int i = 1; i <=h; ++i)
{
for (int j = 1; j <=h; ++j)
{
d[i][j]=min((d[i-1][j]+cost(i-1,j,t)),(d[i][j-1]+cost(i,j-1,t)));
}
}
z = z+d[h][h];
}
cout<<z<<endl;
return 0;
}
int cost(int x, int y,int t){
int f=0;
for (int j = h-1; j-x >=0 || j-y>=0 ; --j){
if (c[j-x][t]==c[j-y][t+1])
{
f=f+1;
}
}
return f;
}
int min(int x, int y){
if (x<y){
return x;
}
else return y;
}
|
a.cc:15:14: error: declaration of 'c' as multidimensional array must have bounds for all dimensions except the first
15 | char c[][];
| ^
a.cc: In function 'int main()':
a.cc:25:30: error: 'c' was not declared in this scope
25 | cin>>c[i][j];
| ^
a.cc: In function 'int cost(int, int, int)':
a.cc:73:45: error: 'c' was not declared in this scope
73 | if (c[j-x][t]==c[j-y][t+1])
| ^
|
s324070232
|
p03960
|
C++
|
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int maxn=1e5+2;
const LL MOD=1e9+7;
int h,w;
char C[310][310];
LL val[310][310],dp[310][310];
LL cl(int a,int b) {
for (int i=1;i<=h;i++)
for (int j=1;j<=h;j++) {
val[i][j]=val[i-1][j-1]+(C[i][a]==C[j][b]);
dp[i][j]=min(dp[i-1][j],dp[i][j-1])+val[i][j];
}
|
a.cc: In function 'LL cl(int, int)':
a.cc:21:18: error: expected '}' at end of input
21 | }
| ^
a.cc:16:20: note: to match this '{'
16 | LL cl(int a,int b) {
| ^
a.cc:21:18: warning: no return statement in function returning non-void [-Wreturn-type]
21 | }
| ^
|
s449368564
|
p03960
|
C++
|
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#define oo 987654321
using namespace std;
string a[330];
int h, w, ans, dt[330][330], dt2[330][330];
int c(int k, int x, int y)
{
if( x > h or y > h ) return 0;
if( x == h or y == h ) return 0;
if( ~dt2[x][y] ) return dt2[x][y];
int &ret = dt2[x][y] = 0;
for(int i = x, j = y ; i < h and j < h ; i++, j++ )
ret += a[i][k] == a[j][k+1];
return ret;
}
int dp(int k, int x, int y)
{
if( x > h or y > h ) return oo;
if( x == h or y == h ) return 0;
if(~dt[x][y]) return dt[x][y];
int &ret = dt[x][y] = oo;
return ret = min(dp(k, x+1, y)+c(k, x, y), dp(k,x,y+1)+c(k, x, y));
}
int main()
{
cin>>h>>w;
for(int i = 0 ; i < h ; i++ ) cin>>a[i];
for(int x = 0 ; x < w-1 ; x++ )
memset(dt, -1, sizeof(dt)), memset(dt2, -1, sizeof(dt2)), ans += dp(x, 0, 0);
cout<<ans<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:35:9: error: 'memset' was not declared in this scope
35 | memset(dt, -1, sizeof(dt)), memset(dt2, -1, sizeof(dt2)), ans += dp(x, 0, 0);
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 | #include <string>
|
s541166873
|
p03960
|
C++
|
test
|
a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s685047818
|
p03960
|
C++
|
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef long long LL;
const int SIZE=305;
const LL INF=1<<30;
int maps[SIZE][SIZE];
int CAL[SIZE][SIZE];
int DP[SIZE][SIZE];
int H,W;
LL calc(int a,int b,int x){
if(max(a,b)==H) return 0;
if(CAL[a][b]!=-1) return CAL[a][b];
return CAL[a][b]=calc(a+1,b+1,x)+(maps[a][x]==maps[b][x+1]);
}
LL solve3(int a,int b,int x){
if(max(a,b)==H) return 0;
if(DP[a][b]!=-1) return DP[a][b];
int ans=0;
ans=calc(a,b,x);
return DP[a][b]=min(solve3(a,b+1,x),solve3(a+1,b,x))+ans;
}
LL solve2(int x){
REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
return solve3(0,0,x);
}
LL solve(){
cin >> H >> W;
REP(i,H){
string s;
cin >> s;
REP(j,W){
maps[H-i-1][j]=s[j]-'a';
}
}
int ans=0;
REP(i,W-1) ans+=solve2(i);
return ans;
}
int main(){
cout << solve() << endl;
return 0;
}
|
a.cc: In function 'LL solve2(int)':
a.cc:2:24: error: 'ut' was not declared in this scope
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^~
a.cc:3:18: note: in expansion of macro 'FOR'
3 | #define REP(i,b) FOR(i,0,b)
| ^~~
a.cc:25:9: note: in expansion of macro 'REP'
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^~~
a.cc:25:13: error: 'i' was not declared in this scope
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:25:9: note: in expansion of macro 'REP'
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^~~
a.cc:25:25: error: expected ';' before 'j'
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^
a.cc:2:27: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:25:21: note: in expansion of macro 'REP'
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^~~
a.cc:25:25: error: 'j' was not declared in this scope
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:25:21: note: in expansion of macro 'REP'
25 | REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
| ^~~
a.cc:2:24: error: 'ut' was not declared in this scope
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^~
a.cc:3:18: note: in expansion of macro 'FOR'
3 | #define REP(i,b) FOR(i,0,b)
| ^~~
a.cc:26:9: note: in expansion of macro 'REP'
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^~~
a.cc:26:13: error: 'i' was not declared in this scope
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:26:9: note: in expansion of macro 'REP'
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^~~
a.cc:26:25: error: expected ';' before 'j'
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^
a.cc:2:27: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:26:21: note: in expansion of macro 'REP'
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^~~
a.cc:26:25: error: 'j' was not declared in this scope
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:26:21: note: in expansion of macro 'REP'
26 | REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
| ^~~
a.cc: In function 'LL solve()':
a.cc:2:24: error: 'ut' was not declared in this scope
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^~
a.cc:3:18: note: in expansion of macro 'FOR'
3 | #define REP(i,b) FOR(i,0,b)
| ^~~
a.cc:31:9: note: in expansion of macro 'REP'
31 | REP(i,H){
| ^~~
a.cc:31:13: error: 'i' was not declared in this scope
31 | REP(i,H){
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:31:9: note: in expansion of macro 'REP'
31 | REP(i,H){
| ^~~
a.cc:34:21: error: expected ';' before 'j'
34 | REP(j,W){
| ^
a.cc:2:27: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:34:17: note: in expansion of macro 'REP'
34 | REP(j,W){
| ^~~
a.cc:34:21: error: 'j' was not declared in this scope
34 | REP(j,W){
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:34:17: note: in expansion of macro 'REP'
34 | REP(j,W){
| ^~~
a.cc:2:24: error: 'ut' was not declared in this scope
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^~
a.cc:3:18: note: in expansion of macro 'FOR'
3 | #define REP(i,b) FOR(i,0,b)
| ^~~
a.cc:39:9: note: in expansion of macro 'REP'
39 | REP(i,W-1) ans+=solve2(i);
| ^~~
a.cc:39:13: error: 'i' was not declared in this scope
39 | REP(i,W-1) ans+=solve2(i);
| ^
a.cc:2:33: note: in definition of macro 'FOR'
2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
| ^
a.cc:39:9: note: in expansion of macro 'REP'
39 | REP(i,W-1) ans+=solve2(i);
| ^~~
|
s967072048
|
p03960
|
C++
|
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
#define dfor(i,a,b) for(int i=(a);i<(b);++i)
#define drfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define drep(i,n) dfor(i,0,n)
#define drrep(i,n) drfor (i,n,0)
#define dump(x) cout << #x << " = " << (x) << endl;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct UnionFind {
vector<int> data;
UnionFind(int size) : data(size, -1) { }
bool unite(int x, int y) {
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool same(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
};
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w,ans=0,cx,cy,cz,rcx,rcy,rcz;
char x, y, z;
vector<char> a,b,c;
cin >> h >> w;
if(w==3){
return 0;
}
drep(i, h) {
cin >> x >> y >> z;
a.push_back(x);
b.push_back(x);
c.push_back(x);
}
drep(j, h * 3) {
for (int i = 0, rcx = 0;i < b.size();i++) {
if (b[i] == a[a.size() - 1]) rcx++;
}
for (int i = 0, rcy = 0;i < a.size();i++) {
if (a[i] == b[b.size() - 1]) rcy++;
}
for (int i = 0;i < c.size();i++) {
if (c[i] == b[b.size() - 1]) rcy++;
}
for (int i = 0, rcz = 0;i < b.size();i++) {
if (b[i] == c[c.size() - 1]) rcz++;
}
vector<char>::iterator itr1 = a.end();
vector<char>::iterator itr2 = b.end();
cx = 0;
drep(i, min(a.size(), b.size()) - 1) {
if (*itr1 == *itr2) cx++;
itr1--;
itr2--;
}
vector<char>::iterator itr1 = b.end();
vector<char>::iterator itr2 = c.end();
cz = 0;
drep(i, min(b.size(), c.size()) - 1) {
if (*itr1 == *itr2) cz++;
itr1--;
itr2--;
}
cy = cx + cz;
if ((cx - rcx < cy - rcy) && (cx - rcx < cz - rcz)) {
a.pop_back();
ans += cx;
}
if ((cy - rcy < cx - rcx) && (cy - rcy < cz - rcz)) {
b.pop_back();
ans += cy;
}
else {
c.pop_back();
ans += cz;
}
}
return 0;
}
|
a.cc:20:19: error: 'acos' was not declared in this scope
20 | const double PI = acos(-1.0);
| ^~~~
a.cc: In function 'int main()':
a.cc:82:40: error: redeclaration of 'std::vector<char>::iterator itr1'
82 | vector<char>::iterator itr1 = b.end();
| ^~~~
a.cc:74:40: note: 'std::vector<char>::iterator itr1' previously declared here
74 | vector<char>::iterator itr1 = a.end();
| ^~~~
a.cc:83:40: error: redeclaration of 'std::vector<char>::iterator itr2'
83 | vector<char>::iterator itr2 = c.end();
| ^~~~
a.cc:75:40: note: 'std::vector<char>::iterator itr2' previously declared here
75 | vector<char>::iterator itr2 = b.end();
| ^~~~
|
s384538726
|
p03960
|
C++
|
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#define INT long long
#define MOD 1000000007
#define oo 1987654321
using namespace std;
INT h, w, dt[302][302][302];
string a[400];
INT dp(int x, int y, int z)
{
if( x>h or y>h or z>h) return oo;
if(x == h && y == h && z == h) return 0;
if( ~dt[x][y][z] ) return dt[x][y][z];
INT &ret = dt[x][y][z] = oo;
ret = min( ret, dp(x+1, y, z) + (y>x||y==h)?0:(bool)(a[0][0]==a[x-y][1])) );
ret = min( ret, dp(x, y+1, z) +
(x>y||x==h)?0:(bool)(a[0][1]==a[y-x][0])) + (z>y||z==h)?0:(bool)(a[0][1]==a[y-z][2])) ) ;
ret = min( ret, dp(x, y, z+1) + (y>z||y==h)?0:(bool)(a[0][2]==a[z-y][1])) );
return ret;
}
int main()
{
ios::sync_with_stdio(false);
memset(dt, -1, sizeof(dt));
cin>>h>>w;
for(int i = 0 ; i < h ; i++) cin>>a[i];
if( w == 3 )
cout<<dp(0, 0, 0)<<endl;
else
cout<<-1<<endl;
return 0;
}
|
a.cc: In function 'long long int dp(int, int, int)':
a.cc:24:14: error: no matching function for call to 'min(long long int&, int)'
24 | ret = min( ret, dp(x+1, y, z) + (y>x||y==h)?0:(bool)(a[0][0]==a[x-y][1])) );
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:24:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
24 | ret = min( ret, dp(x+1, y, z) + (y>x||y==h)?0:(bool)(a[0][0]==a[x-y][1])) );
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:24:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
24 | ret = min( ret, dp(x+1, y, z) + (y>x||y==h)?0:(bool)(a[0][0]==a[x-y][1])) );
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:14: error: no matching function for call to 'min(long long int&, int)'
25 | ret = min( ret, dp(x, y+1, z) +
| ~~~^~~~~~~~~~~~~~~~~~~~~~
26 | (x>y||x==h)?0:(bool)(a[0][1]==a[y-x][0])) + (z>y||z==h)?0:(bool)(a[0][1]==a[y-z][2])) ) ;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:25:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
25 | ret = min( ret, dp(x, y+1, z) +
| ~~~^~~~~~~~~~~~~~~~~~~~~~
26 | (x>y||x==h)?0:(bool)(a[0][1]==a[y-x][0])) + (z>y||z==h)?0:(bool)(a[0][1]==a[y-z][2])) ) ;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:25:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
25 | ret = min( ret, dp(x, y+1, z) +
| ~~~^~~~~~~~~~~~~~~~~~~~~~
26 | (x>y||x==h)?0:(bool)(a[0][1]==a[y-x][0])) + (z>y||z==h)?0:(bool)(a[0][1]==a[y-z][2])) ) ;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:27:14: error: no matching function for call to 'min(long long int&, int)'
27 | ret = min( ret, dp(x, y, z+1) + (y>z||y==h)?0:(bool)(a[0][2]==a[z-y][1])) );
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:27:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
27 | ret = min( ret, dp(x, y, z+1) + (y>z||y==h)?0:(bool)(a[0][2]==a[z-y][1])) );
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:27:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
27 | ret = min( ret, dp(x, y, z+1) + (y>z||y==h)?0:(bool)(a[0][2]==a[z-y][1])) );
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s694413012
|
p03960
|
Java
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
void solve() throws IOException {
int H = ni();
int W = ni();
String[] S = nsa(H);
long sum = 0;
for (int i = 0; i < W - 1; i++) {
long x1 = 0;
long x2 = 0;
long x3 = 0;
long x4 = 0;
long x5 = 0;
for (int j = 0; j < H; j++) {
if (S[j].charAt(i) == S[j].charAt(i + 1)) {
x1++;
}
if (j != H - 1 && S[j].charAt(i) == S[j].charAt(i + 1)) {
x2++;
}
if (j != H - 1 && S[j].charAt(i + 1) == S[j].charAt(i)) {
x3++;
}
if (j != H - 2 && S[j].charAt(i) == S[j].charAt(i + 2)) {
x4++;
}
if (j != H - 2 && S[j].charAt(i + 2) == S[j].charAt(i)) {
x5++;
}
}
sum += x1 + Math.min(Math.min(x2, x3), Math.min(x1 + x4, x1 + x5);
}
out.println(sum);
}
String ns() throws IOException {
while (!tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine(), " ");
}
return tok.nextToken();
}
int ni() throws IOException {
return Integer.parseInt(ns());
}
long nl() throws IOException {
return Long.parseLong(ns());
}
double nd() throws IOException {
return Double.parseDouble(ns());
}
String[] nsa(int n) throws IOException {
String[] res = new String[n];
for (int i = 0; i < n; i++) {
res[i] = ns();
}
return res;
}
int[] nia(int n) throws IOException {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = ni();
}
return res;
}
long[] nla(int n) throws IOException {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = nl();
}
return res;
}
public static void main(String[] args) throws IOException {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
tok = new StringTokenizer("");
Main main = new Main();
main.solve();
out.close();
}
}
|
Main.java:42: error: ')' or ',' expected
sum += x1 + Math.min(Math.min(x2, x3), Math.min(x1 + x4, x1 + x5);
^
1 error
|
s182305986
|
p03960
|
C++
|
#include <stdio.h>
#include <string.h>
#include <stack>
#include <iostream>
using namespace std;
#define LARGE_NUM 114514
using namespace std;
int main(void)
{
int H,W;
cin >> H;
cin >> W;
int b[300][300];
int c =0 ;
for(int i=0;i<h;i++){
for(int i=0;i<w;i++){
cin >> b[h][w];
}
if(b[h][0]==b[h][1]){
c++;
}
if(b[h][2]==b[h][1]){
c++;
}
}
cout << c << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:23: error: 'h' was not declared in this scope
21 | for(int i=0;i<h;i++){
| ^
a.cc:22:31: error: 'w' was not declared in this scope
22 | for(int i=0;i<w;i++){
| ^
|
s011152269
|
p03960
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>
using namespace std;
char dp[305][305];
int main(int argc, const char * argv[]) {
int H,W;
memset(dp,0,sizeof(dp));
cin>>H>>W;
for (int i=0;i<H;i++){
for (int j=0;j<W;j++){
cin>>dp[i][j];
}
}
int ans=0;
for (int j=0;j<W;j++){
if (H>1 && dp[0][j]==dp[1][j]){
ans++;
}
for (int i=1;i<H;i++){
if (dp[i][j]==dp[i-1][j]){
ans++;
}
else{
break;
}
}
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main(int, const char**)':
a.cc:20:4: error: 'memset' was not declared in this scope
20 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:13:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
12 | #include <math.h>
+++ |+#include <cstring>
13 |
|
s506384853
|
p03960
|
C++
|
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#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 dp[303][303][303];
int h,w;
string s;
int c[303][303];
int dai1[800];
int dai2[800];
int saiki(int x,int y,int z)
{
int aa=INF;
if(dp[x][y][z]!=-1)
{
return dp[x][y][z];
}
if(x==h&&y==h)
{
dp[x][y][z]=0;
return 0;
}
if(z==h&&y==h)
{
dp[x][y][z]=0;
return 0;
}
if(z==h&&x==h)
{
dp[x][y][z]=0;
return 0;
}
if(x!=h)
{
int ts=0;
for(int i=max(x,y);i<h;i++)
{
if(c[i-x][0]==c[i-y][1])ts++;
}
dp[x+1][y][z]=saiki(x+1,y,z);
aa=min(aa,ts+dp[x+1][y][z]);
}
ts=0;
if(z!=h)
{
for(int i=max(z,y);i<h;i++)
{
if(c[i-z][2]==c[i-y][1])ts++;
}
dp[x][y][z+1]=saiki(x,y,z+1);
aa=min(aa,ts+dp[x][y][z+1]);
}
ts=0;
if(y!=h)
{
for(int i=max(x,y);i<h;i++)
{
if(c[i-x][0]==c[i-y][1])ts++;
}
for(int i=max(y,z);i<h;i++)
{
if(c[i-z][2]==c[i-y][1])ts++;
}
dp[x][y+1][z]=saiki(x,y+1,z);
aa=min(aa,ts+dp[x][y+1][z]);
}
dp[x][y][z]=aa;
return aa;
}
int main()
{
cin>>h>>w;
rep(i,303)rep(j,303)rep(k,303)dp[i][j][k]=-1;
rep(i,h+1)rep(j,h+1)dp[i][h][j]=0;
rep(i,h)
{
cin>>s;
rep(j,s.size())
{
c[i][j]=(int)(s[j]-'a');
}
}
if(w==3)
{
cout<<saiki(0,0,0)<<endl;
}
else cout<<1<<endl;
return 0;
}
|
a.cc: In function 'int saiki(int, int, int)':
a.cc:58:9: error: 'ts' was not declared in this scope; did you mean 'tm'?
58 | ts=0;
| ^~
| tm
|
s306678406
|
p03960
|
C++
|
#include <stdio.h>
#include <string.h>
#include <stack>
#include <iostream>
using namespace std;
#define LARGE_NUM 114514
using namespace std;
int main(void)
{
int H,W;
cin >> H;
cin >> W;
if(W == 3){
cout << 0 << endl;
}
else{
H/=0;
break;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:18: warning: division by zero [-Wdiv-by-zero]
21 | H/=0;
| ~^~~
a.cc:22:17: error: break statement not within loop or switch
22 | break;
| ^~~~~
|
s865603851
|
p03960
|
C++
|
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
int h, w;
int memo[301][301][301];
char str[301][3];
int mm1[301][301];
int fric1(int a, int b)
{
if (mm1[a][b] >= 0)return mm1[a][b];
int ans = 0;
if (a <= b)
{
for (int i = 0; i < h - b; ++i)
{
if(str[i + b - a][0] == str[i][1])++ans;
}
}
else
{
for (int i = 0; i < h - a; ++i)
{
if (str[i][0] == str[i + a - b][1])++ans;
}
}
return mm1[a][b] = ans;
}
int mm3[301][301];
int fric3(int b, int c)
{
if (mm3[b][c] >= 0)return mm3[b][c];
int ans = 0;
if (b <= c)
{
for (int i = 0; i < h - c; ++i)
{
if (str[i + c - b][1] == str[i][2])++ans;
}
}
else
{
for (int i = 0; i < h - b; ++i)
{
if (str[i][1] == str[i + b - c][2])++ans;
}
}
return mm3[b][c] = ans;
}
int dp(int i, int j, int k)
{
if (i < 0 || j < 0 || k < 0)return 123456789;
if (memo[i][j][k] >= 0)return memo[i][j][k];
int ans = 123456789;
ans = min(dp(i - 1, j, k) + fric1(i - 1, j),ans);
ans = min(dp(i, j - 1, k) + fric1(i, j - 1) + fric3(j - 1, k),ans);
ans = min(dp(i, j, k - 1) + fric3(j, k - 1),ans);
return memo[i][j][k] = ans;
}
int main(void)
{
scanf("%d %d", &h, &w);
if (w != 3)return -1;
memset(memo,0xFF,sizeof(memo));
memset(mm1, 0xFF, sizeof(mm1));
memset(mm3, 0xFF, sizeof(mm3));
memo[0][0][0] = 0;
for (int i = 0; i < h; ++i)
{
char tmp[4];
scanf("%s", tmp);
str[i][0] = tmp[0];
str[i][1] = tmp[1];
str[i][2] = tmp[2];
}
int ans = dp(h, h, h);
printf("%d\n", ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:84:9: error: 'memset' was not declared in this scope
84 | memset(memo,0xFF,sizeof(memo));
| ^~~~~~
a.cc:20:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
19 | #include <queue>
+++ |+#include <cstring>
20 | using namespace std;
|
s406886140
|
p03960
|
C++
|
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long Long;
int MAT[310][310];
int mem[310][310];
int CH[310][310];
int dp(int i,int j,int N){
if(i==N || j==N)return 0;
if(mem[i][j] != -1)return mem[i][j];
int p1 = dp(i+1,j,N);
int p2 = dp(i,j+1,N);
if(p1 <= p2){
CH[i][j] = 0;
}else{
CH[i][j] = 1;
}
return mem[i][j] = MAT[i][j] + min(p1,p2);
}
int solve2(string A,string B){
int N = A.size();
for(int i = N-1; i >= 0; --i){
for(int j = N-1; j >= 0; --j){
int s = A[i] == B[j];
if(i+1 < N && j+1 < N)
s += MAT[i+1][j+1];
MAT[i][j] = s;
}
}
memset(mem,-1,sizeof(mem));
int t = dp(0,0,N);
// cout << A << endl;
// cout << B << endl;
// {
// int i = 0, j = 0;
// while(i<N && j<N){
// int c = CH[i][j];
// int a = MAT[i][j];
// if(c == 0){
// A = " " + A.substr(0,A.size()-1);
// i++;
// }else{
// B = " " + B.substr(0,B.size()-1);
// j++;
// }
// cout << endl;
// cout << a << endl;
// cout << A << endl;
// cout << B << endl;
// }
// cout << t << endl;
// cout << endl;
// }
return t;
}
int solve(string A, string B){
cout << A << " " << B << endl;
int H = A.size();
int st = 0;
int mi = 1000000000;
for(int j = 0; j < H; ++j){
int f = 0 , s = 0, nst = 0;
for(int k = 0; k+j < H; ++k){
if(A[k] == B[j+k]){
nst++;
f += (H-(k+j));
}
}
for(int k = 0; k+j < H; ++k){
if(j+k == 0)continue;
if(A[k] == B[j+k-1]){
s += (H-(k+j));
}
}
mi = min(mi, st+f+s);
cout << "\t" << (st+f+s) <<"\t" << st << " " << f << " " << s << endl;
st += nst;
}
cout << "\t" << st << endl;
mi = min(mi, st);
cout << mi << endl;
return mi;
}
int main()
{
int H,W;
cin >> H >> W;
vector<string> V(H);
for (int i = 0; i < H; ++i) {
cin >> V[i];
}
int s = 0;
for (int i = 1; i < W; ++i) {
string A,B;
for (int j = 0; j < H; ++j) {
A += V[j][i-1];
B += V[j][i];
}
s += solve2(A,B);
}
cout << s << endl;
}
/*
]
xcccccx
xcxxxcx
*/
|
a.cc: In function 'int solve2(std::string, std::string)':
a.cc:42:9: error: 'memset' was not declared in this scope
42 | memset(mem,-1,sizeof(mem));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <sstream>
+++ |+#include <cstring>
11 | using namespace std;
|
s324584398
|
p03960
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
#define clr(a,i) memset((a), (i) ,sizeof(a))
int main(){
int h,w;
std::cin >> h >> w;
std::vector<std::vector<char>> c(h, vector<char>(w));
string s;
rep(i,h){
std::cin >> s;
rep(j,w){
c[i][j]=s[j];
}
}
long ans=0;
vi t(3,0);
rep(j,3*h){
std::vector<long> tmp(3,0);
rep(i,h){
if(c[i+t[0]][0]==c[i+1+t[1]][1]) tmp[0]++;
if(c[i+1+t[0]][0]==c[i+t[1]][1]) tmp[1]++;
if(c[i+1+t[2]][2]==c[i+t[1]][1]) tmp[1]++;
if(c[i+t[2]][2]==c[i+1+t[1]][1]) tmp[2]++;
}
rep(i,3){
if(t[i]==h) t[i]=inf;
}
long mi=min(tmp[0],min(tmp[1],tmp[2]));
if(ma==tmp[0]){
t[0]++;
if(c[i+t[0]][0]==c[i+1+t[1]][1]) ans++;
}else if(ma==tmp[1]){
t[1]++;
if(c[i+1+t[0]][0]==c[i+t[1]][1]) ans++;
if(c[i+1+t[2]][2]==c[i+t[1]][1]) ans++;
}else if(ma==tmp[2]){
t[2]++;
if(c[i+t[2]][2]==c[i+t[1]][1]) ans++;
}
}
std::cout << ans << std::endl;
}
|
a.cc: In function 'int main()':
a.cc:55:8: error: 'ma' was not declared in this scope; did you mean 'mi'?
55 | if(ma==tmp[0]){
| ^~
| mi
a.cc:57:12: error: 'i' was not declared in this scope; did you mean 'mi'?
57 | if(c[i+t[0]][0]==c[i+1+t[1]][1]) ans++;
| ^
| mi
a.cc:60:12: error: 'i' was not declared in this scope; did you mean 'mi'?
60 | if(c[i+1+t[0]][0]==c[i+t[1]][1]) ans++;
| ^
| mi
a.cc:61:12: error: 'i' was not declared in this scope; did you mean 'mi'?
61 | if(c[i+1+t[2]][2]==c[i+t[1]][1]) ans++;
| ^
| mi
a.cc:64:12: error: 'i' was not declared in this scope; did you mean 'mi'?
64 | if(c[i+t[2]][2]==c[i+t[1]][1]) ans++;
| ^
| mi
|
s917782537
|
p03960
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int d[301][301][301];
int onetwo[300][300];
int twothr[300][300];
int onethr[300][300];
int main()
{
ios::sync_with_stdio(0);
cin.tie(NULL);
int h, w;
cin >> h >> w;
if (w == 3) {
int n = h;
string a(n, '0'), b(n, '0'), c(n, '0');
for (int i = 0; i < n; i++) {
if (w == 3) {
cin >> a[i] >> b[i] >> c[i];
} else if (w == 2) {
cin >> a[i] >> b[i];
} else {
cin >> a[i];
}
}
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
reverse(c.begin(), c.end());
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int ii = i, jj = j;
for (int k = min(i, j); k >= 0; k--) {
onetwo[i][j] += (a[ii] == b[jj]);
ii--;
jj--;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int ii = i, jj = j;
for (int k = min(i, j); k >= 0; k--) {
twothr[i][j] += (b[ii] == c[jj]);
ii--;
jj--;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int ii = i, jj = j;
for (int k = min(i, j); k >= 0; k--) {
onethr[i][j] += (a[ii] == c[jj]);
ii--;
jj--;
}
}
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= n; k++) {
if (i == 0 && j == 0 && k == 0) {
continue;
}
d[i][j][k] = 1000 * 1000;
if (i > 0) {
d[i][j][k] = min(d[i][j][k], d[i - 1][j][k] + (j == 0 ? 0 : onetwo[i - 1][j - 1]);
}
if (k > 0) {
d[i][j][k] = min(d[i][j][k], d[i][j][k - 1] + (j == 0 ? 0 : twothr[j - 1][k - 1]);
}
if (j > 0) {
d[i][j][k] = min(d[i][j][k], d[i][j - 1][k] + (i == 0 ? 0 : onetwo[i - 1][j - 1]) + (k == 0 ? 0 : twothr[j - 1][k - 1]));
}
}
}
}
cout << d[n][n][n] << '\n';
} else {
throw;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:81:106: error: expected ')' before ';' token
81 | d[i][j][k] = min(d[i][j][k], d[i - 1][j][k] + (j == 0 ? 0 : onetwo[i - 1][j - 1]);
| ~ ^
| )
a.cc:84:106: error: expected ')' before ';' token
84 | d[i][j][k] = min(d[i][j][k], d[i][j][k - 1] + (j == 0 ? 0 : twothr[j - 1][k - 1]);
| ~ ^
| )
|
s293196194
|
p03960
|
C++
|
asd
|
a.cc:1:1: error: 'asd' does not name a type
1 | asd
| ^~~
|
s523533497
|
p03960
|
C++
|
#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define putans(x) std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "="; rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;}
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif
#pragma endregion
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion
int matchab[300][300];
int matchbc[300][300];
int dp[301][301][301];
void dfs(int x, int y, int z) {
if (x == 0 && y == 0 && z == 0) return;
if (dp[x][y][z] == -10) return;
dfs(x - 1, y, z);
dfs(x, y - 1, z);
dfs(x, y, z - 1);
dp[x][y][z] =
min(min(dp[x - 1][y][z] + matchab[x-1][y],
dp[x][y-1][z] + matchab[x][y-1] + matchbc[y-1][x])
, dp[x][y][z-1] + matchbc[y][z-1]);
}
int main() {
int h, w; put h >> w;
vector<string> table;
rep(i, h) {
string tmp; put tmp;
table.push_back(tmp);
}
if (w > 4) {
return 0;
}
char a[3][300];//転置
rep(i, 3) {
rep(j, h) {
a[i][j] = table[h-1-j][i];
}
}
dp[0][0][0] = 0;
dp[1][0][0] = dp[0][1][0] = dp[0][0][1] = 0;
fill(*dp, *dp + 301 * 301 * 301, -10);
fill(*matchab, *matchab + 300 * 300, 0);
fill(*matchbc, *matchbc + 300 * 300, 0);
REP(i,0, h) {
rep(j,h) {
rep(k, min(h-i,h-j)) {
if (a[0][k + i] == a[1][k + j]) {
matchab[i][j]++;
}
}
}
}
REP(i, 0, h) {
rep(j, h) {
rep(k, min(h - i, h - j)) {
if (a[1][k + i] == a[2][k + j]) {
matchbc[i][j]++;
}
}
}
}
dfs(h, h, h);
putans(dp[2][2][2]);
END:
return 0;
}
//
//vi v;
//vi w; ;
//ll nz1() {
// return 0;
//}
//
//ll nz2() {
// ll dp[201][1000*200+1];
//
//}
//
//ll nz3() {
//
//}
// int n, wkazu; put n >> wkazu;
// v.resize(200);
// w.resize(200);
// rep(i, n) {
// put v[i] >> w[i];
// }
|
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[301]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[301]; _Tp = int]'
998 | { std::__fill_a1(__first, __last, __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[301]; _Tp = int]'
1029 | std::__fill_a(__first, __last, __value);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:87:6: required from here
87 | fill(*dp, *dp + 301 * 301 * 301, -10);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [301]'
952 | *__first = __tmp;
| ~~~~~~~~~^~~~~~~
|
s716882939
|
p03960
|
C++
|
#include <bits/stdc++.h>
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)
using namespace std;
int h,w;
vector<string> f;
int cost[310][310][310];
int frmemo[310][310][310];
int fr(int d,int l,int r){
int he=h-max(l,r);
if(he==0) return 0;
if(frmemo[d][l][r]!=-1) return frmemo[d][l][r];
if(f[h-l-1][d]==f[h-r-1][d+1]) frmemo[d][l][r]=fr(d,l+1,r+1)+1
else frmemo[d][l][r]=fr(d,l+1,r+1);
return frmemo[d][l][r];
}
int solve(int d,int l,int r)
{
int he=h-max(l,r);
if(he==0) return 0;
if(cost[d][l][r]!=-1) return cost[d][l][r];
cost[d][l][r]=fr(d,l,r)+min(solve(d,l+1,r),solve(d,l,r+1));
return cost[d][l][r];
}
int main(void)
{
cin >> h >> w;
f.resize(h);
REP(i,h) cin >> f[i];
REP(i,310) REP(j,310)REP(k,310) cost[i][j][k]=-1;
REP(i,310) REP(j,310)REP(k,310) frmemo[i][j][k]=-1;
int answer=0;
REP(i,w-1) answer+=solve(i,0,0);
cout << answer << endl;
return 0;
}
|
a.cc: In function 'int fr(int, int, int)':
a.cc:17:65: error: expected ';' before 'else'
17 | if(f[h-l-1][d]==f[h-r-1][d+1]) frmemo[d][l][r]=fr(d,l+1,r+1)+1
| ^
| ;
18 | else frmemo[d][l][r]=fr(d,l+1,r+1);
| ~~~~
|
s748108983
|
p03960
|
C++
|
#include <bits/stdc++.h>
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)
using namespace std;
int h,w;
vector<string> f;
int cost[310][310][310];
int frmemo[310][310][310];
int fr(int d,int l,int r){
int he=h-max(l,r);
if(he==0) return 0;
if(frmemo[d][l][r]!=-1) return frmemo[d][l][r];
if(f[h-l-1][d]==f[h-r-1][d+1]) frmemo[d][l][r]=fr(d,l+1,r+1)+1
else frmemo[d][l][r]=fr(d,l+1,r+1);
return frmemo;
}
int solve(int d,int l,int r)
{
int he=h-max(l,r);
if(he==0) return 0;
if(cost[d][l][r]!=-1) return cost[d][l][r];
cost[d][l][r]=fr(d,l,r)+min(solve(d,l+1,r),solve(d,l,r+1));
return cost[d][l][r];
}
int main(void)
{
cin >> h >> w;
f.resize(h);
REP(i,h) cin >> f[i];
REP(i,310) REP(j,310)REP(k,310) cost[i][j][k]=-1;
REP(i,310) REP(j,310)REP(k,310) frmemo[i][j][k]=-1;
int answer=0;
REP(i,w-1) answer+=solve(i,0,0);
cout << answer << endl;
return 0;
}
|
a.cc: In function 'int fr(int, int, int)':
a.cc:17:65: error: expected ';' before 'else'
17 | if(f[h-l-1][d]==f[h-r-1][d+1]) frmemo[d][l][r]=fr(d,l+1,r+1)+1
| ^
| ;
18 | else frmemo[d][l][r]=fr(d,l+1,r+1);
| ~~~~
a.cc:19:10: error: invalid conversion from 'int (*)[310][310]' to 'int' [-fpermissive]
19 | return frmemo;
| ^~~~~~
| |
| int (*)[310][310]
|
s812564777
|
p03960
|
C++
|
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int countx(int i, string s1, int j, string s2){
int res = 0;
for(int k = 0; k != std::min(s1.size() - i, s2.size() - j); k++){
if(s1[s1.size() - k - i - 1] == s2[s2.size() - k - j - 1])
res++;
}
return res;
}
int main(){
int h,w; cin >> h >> w;
/*
vector<vector<char>> c;
rep(i,h){
vector<int> temp;
rep(j,w){
int temp2;
cin >> temp2;
temp.push_back(temp2);
}
c.push_back(temp);
}*/
string c1,c2,c3;
if(w == 3){
rep(i,h){
char k,l,z; cin >> k >> l >> z;
c1.push_back(k); c2.push_back(l); c3.push_back(z);
}
}
if(w == 2){
rep(i,h){
char k,l; cin >> k >> l;
c1.push_back(k); c2.push_back(l); c3.push_back('-');
}
}
if(w == 1){
cout << 0 << endl;
return 0;
}
int ans[300][300][300];
for(int i = h; i != -1; i--){
for(int j = h; j != -1;j--){
for(int k = h; k != -1; k--){
if(j == h)
ans[i][j][k] = 0;
else if(i == h && k == h)
ans[i][j][k] = 0;
else if(i == h)
ans[i][j][k] = std::min(ans[i][j+1][k], ans[i][j][k+1]) + countx(j,c2,k,c3);
else if(k == h)
ans[i][j][k] = std::min(ans[i+1][j][k], ans[i][j+1][k]) + countx(i,c1,j,c2);
else{
ans[i][j][k] = std::min(ans[i+1][j][k] + countx(i,c1,j,c2), ans[i][j+1][k] + countx(i,c1,j,c2) + countx(j,c2,k,c3), ans[i][j][k+1] + countx(j,c2,k,c3));
}
}
}
}
cout << ans[0][0][0] << endl;
}
|
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:69:29: required from here
69 | ans[i][j][k] = std::min(ans[i+1][j][k] + countx(i,c1,j,c2), ans[i][j+1][k] + countx(i,c1,j,c2) + countx(j,c2,k,c3), ans[i][j][k+1] + countx(j,c2,k,c3));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
284 | if (__comp(__b, __a))
| ~~~~~~^~~~~~~~~~
|
s593056982
|
p03960
|
C++
|
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>
using namespace std;
typedef long long ll;
typedef long double ld;
ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;
ll M[500][500] = {0};
ll DP[301][301] = {0};
vector<vector<ll> > C1(301 , vector<ll>());
vector<vector<ll> > C2(301 , vector<ll>());
ll dp(ll i, ll j){
if(i == n || j == n)return 0;
if(DP[i][j] != -1){return DP[i][j];}
ll fric = 0;
for(ll c1 = max(0,j-i); c1 < n-i; c1++){
ll i2 = c1;
ll j2 = c1+j-i;
if(j2 >= 0 && j2 < n){
if(M[i2][k] == M[j2][k+1]){fric++;}
}
}
ll ans = fric + min(dp(i+1,j) , dp(i,j+1));
DP[i][j] = ans;
return ans;
}
int main()
{
ll c1,c2,c3,c4,c5,c6;
ll a,b,d,e,g,c;
ll x,y,z;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin >> n >> m;
for(c1 = 0; c1 < n; c1++){
string s;
cin >> s;
for(c2 = 0; c2 < m; c2++){
M[c1][c2] = ll(s[c2])-97;
}
}
ll ans = 0;
for(c2 = 0; c2 < m-1; c2++){
for(c1 = 0; c1 < 301; c1++){
for(c3 = 0; c3 < 301; c3++){
DP[c1][c3] = -1;
}
}
k = c2;
ans += dp(0,0);
}
cout << ans << "\n";
return 0;
}
|
a.cc: In function 'll dp(ll, ll)':
a.cc:45:16: error: no matching function for call to 'max(int, ll)'
45 | for(ll c1 = max(0,j-i); c1 < n-i; c1++){
| ~~~^~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
45 | for(ll c1 = max(0,j-i); c1 < n-i; c1++){
| ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:45:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
45 | for(ll c1 = max(0,j-i); c1 < n-i; c1++){
| ~~~^~~~~~~
|
s409244873
|
p03960
|
C++
|
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
// #include <boost/multiprecision/cpp_int.hpp>
#include<functional>
#define int long long
#define inf 1000000007
#define pa pair<int,int>
#define ll long long
#define pal pair<ll,ll>
#define ppa pair<int,pa>
#define mp make_pair
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
public:
double x,y;
Point(double x=0,double y=0):x(x),y(y) {}
Point operator + (Point p) {return Point(x+p.x,y+p.y);}
Point operator - (Point p) {return Point(x-p.x,y-p.y);}
Point operator * (double a) {return Point(x*a,y*a);}
Point operator / (double a) {return Point(x/a,y/a);}
double absv() {return sqrt(norm());}
double norm() {return x*x+y*y;}
bool operator < (const Point &p) const{
return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const Point &p) const{
return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
}
};
typedef Point Vector;
struct Segment{
Point p1,p2;
};
double hen(Vector a){
if(fabs(a.x)<EPS && a.y>0) return acos(0);
else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
else if(fabs(a.y)<EPS && a.x>0) return 0.0;
else if(a.y>0) return acos(a.x/a.absv());
else return 2*acos(0)+acos(-a.x/a.absv());
}
double dot(Vector a,Vector b){
return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
//----------------kokomade temple------------
int a[400][5]={0};
int dp[310][310][310];
signed main(){
string s;
int h,w;
cin>>h>>w;
for(int i=1;i<=h;i++){
cin>>s;
for(int j=0;j<w;j++){
a[i][j+1]=1+(s[j]-'a');
}
}
for(int i=0;i<=304;i++)for(int j=0;j<=304;j++) for(int k=0;k<=304;k++) dp[i][j][k]=inf;
dp[0][0][0]=0;
for(int i=0;i<=h;i++)for(int j=0;j<=h;j++) for(int k=0;k<=h;k++){
if(i==0&& j==0 && k==0) continue;
if(i!=0){
int u=0;
for(int l=max(1,j-i+1);l<=h+1-i;l++){
if(a[1][l]==a[2][l+(j-i)])u++;
}
dp[i][j][k] =min(dp[i][j][k],u+dp[i+1][j][k]);
}
if(k!=0){
int u=0;
for(int l=max(1,j-k+1);l<=h+1-k;l++){
if(a[1][l]==a[2][l+(j-k)])u++;
}
dp[i][j][k] =min(dp[i][j][k],u+dp[i][j][k+1]);
}
if(l!=0){
int u=0;
for(int l=max(1,k-j+1);l<=h+1-j;l++){
if(a[1][l]==a[2][l+(k-j)])u++;
}
for(int l=max(1,i-j+1);l<=h+1-j;l++){
if(a[1][l]==a[2][l+(i-j)])u++;
}
dp[i][j][k] =min(dp[i][j][k],u+dp[i][j][k+1]);
}
}
cout<<dp[h][h][h]<<endl;
// cout<<ans<<endl;
return 0;
}
//printf("%.10f\n",ans);
|
a.cc: In function 'int main()':
a.cc:94:38: error: no matching function for call to 'max(int, long long int)'
94 | for(int l=max(1,j-i+1);l<=h+1-i;l++){
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:94:38: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
94 | for(int l=max(1,j-i+1);l<=h+1-i;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:94:38: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
94 | for(int l=max(1,j-i+1);l<=h+1-i;l++){
| ~~~^~~~~~~~~
a.cc:102:38: error: no matching function for call to 'max(int, long long int)'
102 | for(int l=max(1,j-k+1);l<=h+1-k;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:102:38: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
102 | for(int l=max(1,j-k+1);l<=h+1-k;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:102:38: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
102 | for(int l=max(1,j-k+1);l<=h+1-k;l++){
| ~~~^~~~~~~~~
a.cc:108:20: error: 'l' was not declared in this scope
108 | if(l!=0){
| ^
a.cc:110:38: error: no matching function for call to 'max(int, long long int)'
110 | for(int l=max(1,k-j+1);l<=h+1-j;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:110:38: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
110 | for(int l=max(1,k-j+1);l<=h+1-j;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:110:38: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
110 | for(int l=max(1,k-j+1);l<=h+1-j;l++){
| ~~~^~~~~~~~~
a.cc:113:38: error: no matching function for call to 'max(int, long long int)'
113 | for(int l=max(1,i-j+1);l<=h+1-j;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:113:38: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
113 | for(int l=max(1,i-j+1);l<=h+1-j;l++){
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:113:38: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
113 | for(int l=max(1,i-j+1);l<=h+1-j;l++){
| ~~~^~~~~~~~~
|
s083965859
|
p03960
|
C++
|
7 10
xxxxxxxxxx
ccccxxffff
cxxcxxfxxx
cxxxxxffff
cxxcxxfxxx
ccccxxfxxx
xxxxxxxxxx
|
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 7 10
| ^
|
s144097217
|
p03961
|
C++
|
#ifndef __INTMOD_H__
#define __INTMOD_H__
/* updated: 2019-10-10 */
#include <iostream>
#include <cassert>
#include <vector>
#include <cstdint>
#include <functional>
#include <unordered_map>
template <uint32_t Mod>
class IntMod {
static_assert(Mod != 0, "Mod must not be 0");
static_assert(Mod < 0x80000000, "Mod must be less than 0x80000000");
private:
uint32_t value_m;
public:
IntMod();
IntMod(int32_t value);
IntMod(uint32_t value);
IntMod(int64_t value);
IntMod(uint64_t value);
const IntMod<Mod>& operator+() const;
IntMod<Mod> operator-() const;
IntMod<Mod>& operator++();
IntMod<Mod>& operator--();
IntMod<Mod> operator++(int dummy);
IntMod<Mod> operator--(int dummy);
IntMod<Mod>& operator+=(const IntMod<Mod>& right);
IntMod<Mod>& operator-=(const IntMod<Mod>& right);
IntMod<Mod>& operator*=(const IntMod<Mod>& right);
IntMod<Mod>& operator/=(const IntMod<Mod>& right);
IntMod<Mod> operator[](uint64_t exp) const;
static IntMod<Mod> add(const IntMod<Mod>& a, const IntMod<Mod>& b);
static IntMod<Mod> subtract(const IntMod<Mod>& a, const IntMod<Mod>& b);
static IntMod<Mod> multiply(const IntMod<Mod>& a, const IntMod<Mod>& b);
static IntMod<Mod> divide(const IntMod<Mod>& a, const IntMod<Mod>& b);
static int compare(const IntMod<Mod>& a, const IntMod<Mod>& b);
IntMod<Mod> inverse() const;
IntMod<Mod> power(uint64_t exp) const;
uint32_t get() const;
static IntMod<Mod> fact(uint32_t num);
static IntMod<Mod> invFact(uint32_t num);
static IntMod<Mod> combi(uint32_t n, uint32_t r);
static IntMod<Mod> homcombi(uint32_t n, uint32_t r);
static IntMod<Mod> perm(uint32_t n, uint32_t r);
static std::vector<IntMod<Mod>> calcInverseList(int max);
};
template <uint32_t Mod>
IntMod<Mod> operator+(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
IntMod<Mod> operator-(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
IntMod<Mod> operator*(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
IntMod<Mod> operator/(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator+(const IntMod<Mod>& a, const Int& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator-(const IntMod<Mod>& a, const Int& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator*(const IntMod<Mod>& a, const Int& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator/(const IntMod<Mod>& a, const Int& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator+(const Int& a, const IntMod<Mod>& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator-(const Int& a, const IntMod<Mod>& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator*(const Int& a, const IntMod<Mod>& b);
template <uint32_t Mod, class Int>
IntMod<Mod> operator/(const Int& a, const IntMod<Mod>& b);
template <uint32_t Mod>
bool operator==(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
bool operator!=(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
bool operator<(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
bool operator<=(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
bool operator>(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod>
bool operator>=(const IntMod<Mod>& a, const IntMod<Mod>& b);
template <uint32_t Mod, class Int>
bool operator==(const IntMod<Mod>& a, const Int& b);
template <uint32_t Mod, class Int>
bool operator!=(const IntMod<Mod>& a, const Int& b);
template <uint32_t Mod>
std::istream& operator>>(std::istream& ist, IntMod<Mod>& object);
template <uint32_t Mod>
std::ostream& operator<<(std::ostream& ost, const IntMod<Mod>& object);
using MInt = IntMod<1000000007>;
using MF = IntMod<998244353>;
// for unordered_set/map
namespace std {
template <uint32_t Mod>
struct hash<IntMod<Mod>> {
size_t operator() (const IntMod<Mod>& object) const {
return std::hash<uint32_t>()(object.get());
}
};
}
/*------------------------------------*/
/*------- Implementations --------*/
/*------------------------------------*/
template <uint32_t Mod>
IntMod<Mod>::IntMod()
: value_m(0) {
}
template <uint32_t Mod>
IntMod<Mod>::IntMod(int32_t value) {
int32_t tmp = value % int32_t(Mod);
value_m = tmp >= 0 ? tmp : Mod - uint32_t(-tmp);
}
template <uint32_t Mod>
IntMod<Mod>::IntMod(uint32_t value)
: value_m(value % Mod) {
}
template <uint32_t Mod>
IntMod<Mod>::IntMod(int64_t value) {
int32_t tmp = value % int64_t(Mod);
value_m = tmp >= 0 ? tmp : Mod - uint32_t(-tmp);
}
template <uint32_t Mod>
IntMod<Mod>::IntMod(uint64_t value)
: value_m(value % Mod) {
}
template <uint32_t Mod>
const IntMod<Mod>& IntMod<Mod>::operator+() const {
return *this;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::operator-() const {
IntMod<Mod> ret;
if (value_m == 0) {
ret.value_m = 0;
} else {
ret.value_m = Mod - value_m;
}
return ret;
}
template <uint32_t Mod>
IntMod<Mod>& IntMod<Mod>::operator++() {
++value_m;
if (value_m == Mod) {
value_m = 0;
}
return *this;
}
template <uint32_t Mod>
IntMod<Mod>& IntMod<Mod>::operator--() {
if (value_m == 0) {
value_m = Mod;
}
--value_m;
return *this;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::operator++(int dummy) {
IntMod ret(*this);
++*this;
return ret;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::operator--(int dummy) {
IntMod ret(*this);
--*this;
return ret;
}
template <uint32_t Mod>
IntMod<Mod>& IntMod<Mod>::operator+=(const IntMod<Mod>& right) {
value_m += right.value_m; // note: value_m < 0x80000000
if (value_m >= Mod) {
value_m -= Mod;
}
return *this;
}
template <uint32_t Mod>
IntMod<Mod>& IntMod<Mod>::operator-=(const IntMod<Mod>& right) {
if (value_m < right.value_m) {
value_m += Mod; // note: value_m < 0x80000000
}
value_m -= right.value_m;
return *this;
}
template <uint32_t Mod>
IntMod<Mod>& IntMod<Mod>::operator*=(const IntMod<Mod>& right) {
value_m = (uint64_t(value_m) * right.value_m) % Mod;
return *this;
}
template <uint32_t Mod>
IntMod<Mod>& IntMod<Mod>::operator/=(const IntMod<Mod>& right) {
*this *= right.inverse();
return *this;
}
// for power
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::operator[](uint64_t exp) const {
return power(exp);
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::add(const IntMod<Mod>& a, const IntMod<Mod>& b) {
IntMod<Mod> ret(a);
ret += b;
return ret;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::subtract(const IntMod<Mod>& a, const IntMod<Mod>& b) {
IntMod<Mod> ret(a);
ret -= b;
return ret;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::multiply(const IntMod<Mod>& a, const IntMod<Mod>& b) {
IntMod<Mod> ret(a);
ret *= b;
return ret;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::divide(const IntMod<Mod>& a, const IntMod<Mod>& b) {
IntMod<Mod> ret(a);
ret /= b;
return ret;
}
template <uint32_t Mod>
int IntMod<Mod>::compare(const IntMod<Mod>& a, const IntMod<Mod>& b) {
if (a.value_m < b.value_m) return -1;
if (a.value_m > b.value_m) return 1;
return 0;
}
/* Mod must be a prime. */
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::inverse() const {
assert(value_m != 0);
return power(Mod - 2);
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::power(uint64_t exp) const {
IntMod<Mod> product(1);
IntMod<Mod> factor(*this);
while (exp > 0) {
if (exp & 1) {
product *= factor;
}
factor *= factor;
exp >>= 1;
}
return product;
}
template <uint32_t Mod>
uint32_t IntMod<Mod>::get() const {
return value_m;
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::fact(uint32_t num) {
assert(num <= 0x80000000);
static std::vector<IntMod<Mod>> table(1, 1);
if (table.size() > num) return table[num];
uint32_t old_size = table.size();
table.resize(num + 1);
for (uint32_t i = old_size; i <= num; ++i) {
table[i] = table[i - 1] * i;
}
return table[num];
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::invFact(uint32_t num) {
assert(num <= 0x80000000);
static std::vector<IntMod<Mod>> table(1, 1);
if (table.size() > num) return table[num];
uint32_t old_size = table.size();
table.resize(num + 1);
table[num] = fact(num).inverse();
for (uint32_t i = num; i >= old_size; --i) {
table[i - 1] = table[i] * i;
}
return table[num];
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::combi(uint32_t n, uint32_t r) {
assert(n >= r);
return fact(n) * invFact(n - r) * invFact(r);
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::homcombi(uint32_t n, uint32_t r) {
assert(n != 0 || r == 0);
if (n == 0 && r == 0) return IntMod<Mod>(1);
return combi(n + r - 1, r);
}
template <uint32_t Mod>
IntMod<Mod> IntMod<Mod>::perm(uint32_t n, uint32_t r) {
assert(n >= r);
return fact(n) * invFact(n - r);
}
template <uint32_t Mod>
std::vector<IntMod<Mod>> IntMod<Mod>::calcInverseList(int max) {
assert(max < Mod);
std::vector<IntMod<Mod>> table(max + 1);
table[1] = 1;
for (int i = 2; i <= max; ++i) {
table[i] = (uint64_t(Mod - Mod / i) * table[Mod % i].get()) % Mod;
}
return table;
}
template <uint32_t Mod>
IntMod<Mod> operator+(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::add(a, b);
}
template <uint32_t Mod>
IntMod<Mod> operator-(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::subtract(a, b);
}
template <uint32_t Mod>
IntMod<Mod> operator*(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::multiply(a, b);
}
template <uint32_t Mod>
IntMod<Mod> operator/(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::divide(a, b);
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator+(const IntMod<Mod>& a, const Int& b) {
return a + IntMod<Mod>(b);
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator-(const IntMod<Mod>& a, const Int& b) {
return a - IntMod<Mod>(b);
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator*(const IntMod<Mod>& a, const Int& b) {
return a * IntMod<Mod>(b);
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator/(const IntMod<Mod>& a, const Int& b) {
return a / IntMod<Mod>(b);
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator+(const Int& a, const IntMod<Mod>& b) {
return IntMod<Mod>(a) + b;
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator-(const Int& a, const IntMod<Mod>& b) {
return IntMod<Mod>(a) - b;
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator*(const Int& a, const IntMod<Mod>& b) {
return IntMod<Mod>(a) * b;
}
template <uint32_t Mod, class Int>
IntMod<Mod> operator/(const Int& a, const IntMod<Mod>& b) {
return IntMod<Mod>(a) / b;
}
template <uint32_t Mod>
bool operator==(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::compare(a, b) == 0;
}
template <uint32_t Mod>
bool operator!=(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::compare(a, b) != 0;
}
template <uint32_t Mod>
bool operator<(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::compare(a, b) < 0;
}
template <uint32_t Mod>
bool operator<=(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::compare(a, b) <= 0;
}
template <uint32_t Mod>
bool operator>(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::compare(a, b) > 0;
}
template <uint32_t Mod>
bool operator>=(const IntMod<Mod>& a, const IntMod<Mod>& b) {
return IntMod<Mod>::compare(a, b) >= 0;
}
template <uint32_t Mod, class Int>
bool operator==(const IntMod<Mod>& a, const Int& b) {
return a == IntMod<Mod>(b);
}
template <uint32_t Mod, class Int>
bool operator!=(const IntMod<Mod>& a, const Int& b) {
return a != IntMod<Mod>(b);
}
template <uint32_t Mod>
std::istream& operator>>(std::istream& ist, IntMod<Mod>& object) {
uint64_t value;
ist >> value;
object = IntMod<Mod>(value);
return ist;
}
template <uint32_t Mod>
std::ostream& operator<<(std::ostream& ost, const IntMod<Mod>& object) {
ost << object.get();
return ost;
}
#endif
#ifndef __BIT_H__
#define __BIT_H__
/* updated: 2019-10-03 */
#include <vector>
#include <cstdint>
class BinaryIndexedTree {
using T = uint64_t;
private:
const int size_m;
std::vector<T> arr_m;
static const int Default = -1;
public:
BinaryIndexedTree(int size);
void add(int pos, T increment);
T sum(int left) const;
T sum(int left, int right) const;
T get(int pos) const;
void debug(int size = Default) const;
};
#endif
#ifdef ONLY_MY_ENVIR
#include "BIT.h"
#endif
#include <cassert>
#include <iostream>
/* 長さ size の BIT を作成 */
BinaryIndexedTree::BinaryIndexedTree(int size)
: size_m(size), arr_m(size) {
}
/* pos 番目の要素を increment 増加させる O(log n) */
void BinaryIndexedTree::add(int pos, T increment) {
for (int i = pos; i != 0; i &= ~(-i)) {
arr_m[i] += increment;
}
arr_m[0] += increment;
}
/* [left, ∞) に存在する全要素の和をとる O(log n) */
BinaryIndexedTree::T BinaryIndexedTree::sum(int left) const {
if (left == 0) return arr_m[0]; // 0番目の要素は例外
T sum = T();
for (int i = left; i < size_m; i += i & -i) {
sum += arr_m[i];
}
return sum;
}
/* [left, right) に存在する全要素の和をとる O(log n) */
BinaryIndexedTree::T BinaryIndexedTree::sum(int left, int right) const {
assert(left <= right);
return sum(left) - sum(right);
}
/* pos 番目の要素を直接取得 O(log n) */
BinaryIndexedTree::T BinaryIndexedTree::get(int pos) const {
return sum(pos, pos + 1);
}
/* デバッグ出力用; size = -1 とすると全要素出力 */
void BinaryIndexedTree::debug(int size) const {
if (size == Default) { // デフォルト値への対処
size = size_m;
}
if (size > size_m) {
size = size_m;
}
std::cout << "{ ";
for (int i = 0; i < size; ++i) {
std::cout << arr_m[i] << ' ';
}
std::cout << "}" << std::endl;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using uint = uint32_t;
using LL = int64_t;
using ULL = uint64_t;
using PP = pair<LL, LL>;
template <typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#define REP(i, a, n) for(LL i = (a), i##_max_ = (n); i < i##_max_; ++i)
#define REM(i, a, n) for(LL i = (LL)(n) - 1, i##_min_ = (a); i >= i##_min_; --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP { cin.tie(NULL); ios::sync_with_stdio(false); }
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U> ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template <class T> T Next() { T buf; cin >> buf; return buf; }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
#ifdef ONLY_MY_ENVIR
#include "Accumulator.h"
#include "Algebraic.h"
#include "BinaryMatrix.h"
#include "BinaryTree.h"
#include "Bipartite.h"
#include "BIT.h"
#include "Compressor.h"
#include "Decompositions.h"
#include "DiscreteLog.h"
#include "DynamicMod.h"
#include "Factorization.h"
#include "FFT.h"
#include "FlowSolver.h"
#include "Graph.h"
#include "GraphUtil.h"
#include "IntMod.h"
#include "LazySegmentTree.h"
#include "LIS.h"
#include "Math.h"
#include "MathUtil.h"
#include "Matrix.h"
#include "MinCostFlowSolver.h"
#include "MinMax.h"
#include "Numbers.h"
#include "Optimize.h"
#include "Permutation.h"
#include "Polynomial.h"
#include "Position.h"
#include "Range.h"
#include "Rational.h"
#include "RuntimeMod.h"
#include "SegmentTree.h"
#include "SegmentTree2D.h"
#include "Sets.h"
#include "Shortest.h"
#include "SlidingWindow.h"
#include "SpanningTree.h"
#include "StringSearching.h"
#include "SuffixArray.h"
#include "SwitchList.h"
#include "Tree.h"
#include "TreeUtil.h"
#include "UnionFind.h"
#include "Util.h"
#include "VectorUtil.h"
#endif
#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>>(istream& ist, __int128& val) { LL tmp; ist >> tmp; val = tmp; return ist; }
ostream& operator<<(ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif
int N;
int P[500000];
int main() {
RuntimeMod::setDefaultMod(1000000007);
cin >> N;
REP(i, 0, N) {
cin >> P[i];
--P[i];
}
vector<int> is_hole(N, 1);
REP(i, 0, N) if (P[i] != -1) is_hole[P[i]] = 0;
const int K = count(is_hole.begin(), is_hole.end(), 1);
vector<int> accum(N + 1);
partial_sum(is_hole.begin(), is_hole.end(), accum.begin() + 1);
RuntimeMod hole_sum = 0;
REP(i, 0, N) if (is_hole[i]) hole_sum += i;
int hole_cnt = 0;
RuntimeMod coeff = 0;
RuntimeMod ans = 0;
BinaryIndexedTree bit(N);
REP(i, 0, N) {
RuntimeMod sub = 0;
if (P[i] == -1) {
sub += hole_sum * RuntimeMod::fact(K - 1);
sub -= coeff * RuntimeMod::fact(K - 1);
sub -= hole_cnt * RuntimeMod::fact(K) / 2;
++hole_cnt;
} else {
int s = P[i];
sub += s * RuntimeMod::fact(K);
sub -= bit.sum(0, s) * RuntimeMod::fact(K);
if (K > 0) sub -= RuntimeMod(accum[s]) * hole_cnt * RuntimeMod::fact(K - 1);
bit.add(s, 1);
coeff += accum[N] - accum[s];
}
ans += sub * RuntimeMod::fact(N - 1 - i);
}
cout << ans + RuntimeMod::fact(K) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:677:9: error: 'RuntimeMod' has not been declared
677 | RuntimeMod::setDefaultMod(1000000007);
| ^~~~~~~~~~
a.cc:691:9: error: 'RuntimeMod' was not declared in this scope
691 | RuntimeMod hole_sum = 0;
| ^~~~~~~~~~
a.cc:692:38: error: 'hole_sum' was not declared in this scope
692 | REP(i, 0, N) if (is_hole[i]) hole_sum += i;
| ^~~~~~~~
a.cc:695:19: error: expected ';' before 'coeff'
695 | RuntimeMod coeff = 0;
| ^~~~~~
| ;
a.cc:696:19: error: expected ';' before 'ans'
696 | RuntimeMod ans = 0;
| ^~~~
| ;
a.cc:699:27: error: expected ';' before 'sub'
699 | RuntimeMod sub = 0;
| ^~~~
| ;
a.cc:701:25: error: 'sub' was not declared in this scope; did you mean 'fsub'?
701 | sub += hole_sum * RuntimeMod::fact(K - 1);
| ^~~
| fsub
a.cc:701:32: error: 'hole_sum' was not declared in this scope
701 | sub += hole_sum * RuntimeMod::fact(K - 1);
| ^~~~~~~~
a.cc:701:43: error: 'RuntimeMod' is not a class, namespace, or enumeration
701 | sub += hole_sum * RuntimeMod::fact(K - 1);
| ^~~~~~~~~~
a.cc:702:32: error: 'coeff' was not declared in this scope
702 | sub -= coeff * RuntimeMod::fact(K - 1);
| ^~~~~
a.cc:702:40: error: 'RuntimeMod' is not a class, namespace, or enumeration
702 | sub -= coeff * RuntimeMod::fact(K - 1);
| ^~~~~~~~~~
a.cc:703:43: error: 'RuntimeMod' is not a class, namespace, or enumeration
703 | sub -= hole_cnt * RuntimeMod::fact(K) / 2;
| ^~~~~~~~~~
a.cc:707:25: error: 'sub' was not declared in this scope; did you mean 'fsub'?
707 | sub += s * RuntimeMod::fact(K);
| ^~~
| fsub
a.cc:707:36: error: 'RuntimeMod' is not a class, namespace, or enumeration
707 | sub += s * RuntimeMod::fact(K);
| ^~~~~~~~~~
a.cc:708:48: error: 'RuntimeMod' is not a class, namespace, or enumeration
708 | sub -= bit.sum(0, s) * RuntimeMod::fact(K);
| ^~~~~~~~~~
a.cc:709:77: error: 'RuntimeMod' is not a class, namespace, or enumeration
709 | if (K > 0) sub -= RuntimeMod(accum[s]) * hole_cnt * RuntimeMod::fact(K - 1);
| ^~~~~~~~~~
a.cc:711:25: error: 'coeff' was not declared in this scope
711 | coeff += accum[N] - accum[s];
| ^~~~~
a.cc:713:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
713 | ans += sub * RuntimeMod::fact(N - 1 - i);
| ^~~
| abs
a.cc:713:24: error: 'sub' was not declared in this scope; did you mean 'fsub'?
713 | ans += sub * RuntimeMod::fact(N - 1 - i);
| ^~~
| fsub
a.cc:713:30: error: 'RuntimeMod' is not a class, namespace, or enumeration
713 | ans += sub * RuntimeMod::fact(N - 1 - i);
| ^~~~~~~~~~
a.cc:715:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
715 | cout << ans + RuntimeMod::fact(K) << endl;
| ^~~
| abs
a.cc:715:23: error: 'RuntimeMod' is not a class, namespace, or enumeration
715 | cout << ans + RuntimeMod::fact(K) << endl;
| ^~~~~~~~~~
|
s782126101
|
p03961
|
C++
|
10
0 3 0 0 1 0 4 0 0 0
|
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10
| ^~
|
s717624606
|
p03961
|
C++
|
#include <bits/stdc++.h>
#define cadd(_x,_y) _x = add(_x, _y)
#define cpop(_x,_y) _x = pop(_x, _y)
#define cmul(_x,_y) _x = mul(_x, _y)
const int mod = 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int pop(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
int qpow(int a, int b) {
int c = 1;
while (b) {
if (b & 1) cmul(c, a);
b >>= 1; cmul(a, a);
}
return c;
}
int n, a [ 300005 ] , fac [ 300005 ] = { 1 } ;
int c [ 300005 ] ;
void cg(int o, int v) {
for (int i = o; i <= n; i += i & - i )
c[i] += v;
}
int get(int o) {
int sum = 0;
for (int i = o; i >= 1; i -= i & - i )
sum += c[i];
return sum;
}
int c2(int m) {
return (long long)m * (m - 1) / 2 % mod;
}
int suf[300005], pre[300005];
int main() {
scanf("%d", &n);
for ( int i = 1 ; i <= n ; i ++ ) scanf("%d", &a[i]);
for ( int i = 1 ; i <= n ; i ++ ) fac[i] = i * fac [ i - 1 ] % ( 1e9 + 3 ) ;
int ans = 0, cur = 0, all = 0, cof = 0, bs = 0;
for ( int i = 1 ; i <= n ; i ++ ) all += a[i] == 0, cadd(bs, i - 1), pre[i] = 1, suf[i] = 1;
for ( int i = 1 ; i <= n ; i ++ ) if (a[i] != 0) cpop(bs, a[i] - 1);
for ( int i = 1 ; i <= n ; i ++ ) if (a[i] > 0) suf[a[i]] = 0, pre[a[i]] = 0;
for ( int i = n ; i >= 1 ; i -- ) suf[i] += suf[i + 1];
for ( int i = 1 ; i <= n ; i ++ ) pre[i] += pre[i - 1];
for ( int i = 1 ; i <= n ; i ++ ) {
int sum = 0;
cur += a[i] == 0;
if (a[i] != 0) {
cadd(sum, mul(fac[all], a[i] - 1));
int w = get(a[i] - 1);
cpop(sum, mul(fac[all], w));
if (all > 0) cpop(sum, mul(pre[a[i]], mul(cur, fac[all - 1])));
cadd(cof, suf[a[i]]);
cg(a[i], 1);
} else {
if (all > 0) cadd(sum, mul(bs, fac[all - 1]));
if (cur >= 2) cpop(sum, mul(c2(all), mul(cur - 1, fac[all - 2])));
if (all > 0) cpop(sum, mul(cof, fac[all - 1]));
}
cadd(ans, mul(sum, fac[n - i]));
}
printf("%d\n", add(ans, fac[all]));
return 0;
}
|
a.cc: In function 'int main()':
a.cc:36:70: error: invalid operands of types 'int' and 'double' to binary 'operator%'
36 | for ( int i = 1 ; i <= n ; i ++ ) fac[i] = i * fac [ i - 1 ] % ( 1e9 + 3 ) ;
| ~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
| | |
| int double
|
s550851318
|
p03961
|
Java
|
import java.util.*;
public class Main {
private static boolean elapsed = false;
private static long sum;
private static int cnt;
public static void main(String[] args) {
long S = System.currentTimeMillis();
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] P = new int[N];
for (int i = 0; i < P.length; ++i) {
P[i] = sc.nextInt();
}
long div = (long)Math.pow(10, 9) + 7;
solve(P);
System.out.println(sum % div);
long G = System.currentTimeMillis();
if (elapsed) {
System.err.println((G - S) + "ms");
}
}
private static void solve(int[] P) {
List<Integer> list = new ArrayList<>(P.length);
for (int i = 0; i < P.length; ++i) {
list.add(i + 1);
}
search(list, 0, new ArrayList<>(), P);
}
private static void search(List<Integer> list, int d, List<Integer> p, int[] P) {
if (d >= list.size()) {
++cnt;
if (match(P, p)) {
sum += cnt;
sum %= div;
}
} else {
for (int i = 0; i < list.size(); ++i) {
int num = list.get(i);
if (p.contains(num)) {
continue;
}
p.add(num);
search(list, d + 1, p, P);
p.remove(p.size() - 1);
}
}
}
private static boolean match(int[] P, List<Integer> list) {
for (int i = 0; i < P.length; ++i) {
if (P[i] > 0) {
if (list.get(i) != P[i]) {
return false;
}
}
}
return true;
}
}
|
Main.java:41: error: cannot find symbol
sum %= div;
^
symbol: variable div
location: class Main
1 error
|
s693522327
|
p03961
|
C++
|
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int INF = 100000000;
const double EPS = 1e-10;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n;
int k=0;
int p[3010];
int lef[3010]={};
int deru[3010]={};
int dezu[3010];
int big[3010]={};
int kosu[3010]={};
ll mae;
ll kazu;
ll sum;
ll ans=0;
int main()
{
cin >> n;
rep(i, n)
{
cin >> p[i];
if(p[i]!=0)
{
deru[p[i]-1]=1;
lef[i+1]=left[i];
}
else
{
lef[i+1]=left[i]+1;
}
}
rep(i, n)
{
if(deru[i]==0)
{
dezu[k]=i;
k++;
}
}
rep(i, n)
{
if(deru[n-1-i]==0)
{
big[n-1-i]=big[n-i]+1;
}
}
mae=1;
repp(i, 1, k)
{
mae*=i;
mae%=MOD;
}
kazu=(mae*k)%MOD;
sum=(kazu*(kazu+1))%MOD;
sum=(sum*500000004)%MOD;
rep(i, n)
{
if(p[i]!=0)
{
rep(j, i)
{
if(p[i]<p[j])
{
kosu[i]++;
}
}
ans+=(kosu[i]*kazu);
ans+=(((big[p[i]-1]*lef[i])%MOD)*mae)%MOD;
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:32:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
32 | lef[i+1]=left[i];
| ^
a.cc:32:40: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
32 | lef[i+1]=left[i];
| ~~~~~~^
| |
| std::ios_base& (*)(std::ios_base&)
a.cc:36:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
36 | lef[i+1]=left[i]+1;
| ^
a.cc:36:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
36 | lef[i+1]=left[i]+1;
| ~~~~~~~^~
a.cc:36:41: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
36 | lef[i+1]=left[i]+1;
| ~~~~~~~^~
| |
| std::ios_base& (*)(std::ios_base&)
|
s302480779
|
p03961
|
C++
|
1232
|
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1232
| ^~~~
|
s308838482
|
p03961
|
C++
|
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int INF = 100000000;
const double EPS = 1e-10;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n;
int k=0;
int p[3010];
int left[3010]={};
int deru[3010]={};
int dezu[3010];
int big[3010]={};
int kosu[3010]={};
ll mae;
ll kazu;
ll sum;
ll ans=0;
int main()
{
cin >> n;
rep(i, n)
{
cin >> p[i];
if(p[i]!=0)
{
deru[p[i]-1]=1;
left[i+1]=left[i];
}
else
{
left[i+1]=left[i]+1;
}
}
rep(i, n)
{
if(deru[i]==0)
{
dezu[k]=i;
k++;
}
}
rep(i, n)
{
if(deru[n-1-i]==0)
{
big[n-1-i]=big[n-i]+1;
}
}
mae=1;
repp(i, 1, k)
{
mae*=i;
mae%=MOD;
}
kazu=(mae*k)%MOD;
sum=(kazu*(kazu+1))%MOD;
sum=(sum*500000004)%MOD;
rep(i, n)
{
if(p[i]!=0)
{
rep(j, i)
{
if(p[i]<p[j])
{
kosu[i]++;
}
}
ans+=(kosu[i]*kazu);
ans+=(((big[p[i]-1]*left[i])%MOD)*mae)%MOD;
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:32:25: error: reference to 'left' is ambiguous
32 | left[i+1]=left[i];
| ^~~~
In file included from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:14:5: note: 'int left [3010]'
14 | int left[3010]={};
| ^~~~
a.cc:32:35: error: reference to 'left' is ambiguous
32 | left[i+1]=left[i];
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:14:5: note: 'int left [3010]'
14 | int left[3010]={};
| ^~~~
a.cc:36:25: error: reference to 'left' is ambiguous
36 | left[i+1]=left[i]+1;
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:14:5: note: 'int left [3010]'
14 | int left[3010]={};
| ^~~~
a.cc:36:35: error: reference to 'left' is ambiguous
36 | left[i+1]=left[i]+1;
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:14:5: note: 'int left [3010]'
14 | int left[3010]={};
| ^~~~
a.cc:75:45: error: reference to 'left' is ambiguous
75 | ans+=(((big[p[i]-1]*left[i])%MOD)*mae)%MOD;
| ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
1062 | left(ios_base& __base)
| ^~~~
a.cc:14:5: note: 'int left [3010]'
14 | int left[3010]={};
| ^~~~
|
s657339009
|
p03961
|
C++
|
import Control.Monad
import Control.Applicative
import Data.List
taka :: [Int] -> Int
taka xs = sum $ map (\x -> ponya (permutation $ [1..(length xs)]) x 1) (p5 ( length xs ) xs (kuwa xs 1))
ponya :: [[Int]] -> [Int] -> Int -> Int
ponya (x:xs) y n
| x == y = n
| x /= y = ponya xs y (n+1)
p5 :: Int -> [Int] -> [Int] -> [[Int]]
p5 _ [] _ = [[]]
p5 n (x:xs) ys
| x == 0 = do
x <- ys
map (x:) (p5 n xs ( delete x ys ))
| x /= 0 = do
map (x:) (p5 n xs ys)
kuwa :: [Int] -> Int -> [Int]
kuwa [] _ = []
kuwa (x:xs) n
| x == 0 = (n:) (kuwa xs (n+1))
| x /= 0 = kuwa xs (n+1)
permutation :: Eq a => [a] -> [[a]]
permutation [] = [[]]
permutation xs = do
x <- xs
map (x:) (permutation $ delete x xs)
main = do
n' <- getLine
p' <- getLine
print $ taka $ map (\x -> (read x :: Int)) (words p')
|
a.cc:6:22: error: stray '\' in program
6 | taka xs = sum $ map (\x -> ponya (permutation $ [1..(length xs)]) x 1) (p5 ( length xs ) xs (kuwa xs 1))
| ^
a.cc:6:50: error: too many decimal points in number
6 | taka xs = sum $ map (\x -> ponya (permutation $ [1..(length xs)]) x 1) (p5 ( length xs ) xs (kuwa xs 1))
| ^~~
a.cc:35:6: warning: missing terminating ' character
35 | n' <- getLine
| ^
a.cc:35:6: error: missing terminating ' character
35 | n' <- getLine
| ^~~~~~~~~~~~
a.cc:36:6: warning: missing terminating ' character
36 | p' <- getLine
| ^
a.cc:36:6: error: missing terminating ' character
36 | p' <- getLine
| ^~~~~~~~~~~~
a.cc:37:25: error: stray '\' in program
37 | print $ taka $ map (\x -> (read x :: Int)) (words p')
| ^
a.cc:37:56: warning: missing terminating ' character
37 | print $ taka $ map (\x -> (read x :: Int)) (words p')
| ^
a.cc:37:56: error: missing terminating ' character
37 | print $ taka $ map (\x -> (read x :: Int)) (words p')
| ^~
a.cc:1:1: error: 'import' does not name a type
1 | import Control.Monad
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s497704927
|
p03961
|
C++
|
use std::io::prelude::*;
use std::io;
fn read_to_string() -> String {
let mut buf = String::new();
let mut stdin = io::stdin();
stdin.read_to_string(&mut buf);
buf
}
fn solve(p: Vec<u64>, q: Vec<u64>) -> u64 {
let w = p.len();
let h = q.len();
let mut pq: Vec<_> = p.iter()
.map(|c| (*c, 'p'))
.chain(q.iter()
.map(|c| (*c, 'q')))
.collect();
pq.sort();
let mut a = w as u64 + 1;
let mut b = h as u64 + 1;
pq.iter()
.map({
|e| match *e {
(c, 'p') => {
a -= 1;
b * c
}
(c, 'q') => {
b -= 1;
a * c
}
_ => 0
}
})
.fold(0, std::ops::Add::add)
}
fn main() {
let input = read_to_string();
let mut words = input.split_whitespace();
let w: usize = words.next().unwrap().parse().unwrap();
let h: usize = words.next().unwrap().parse().unwrap();
let p: Vec<u64> = words.by_ref().take(w).map(|i| i.parse().unwrap()).collect();
let q: Vec<u64> = words.by_ref().take(h).map(|i| i.parse().unwrap()).collect();
println!("{}", solve(p, q));
}
|
a.cc:1:1: error: 'use' does not name a type
1 | use std::io::prelude::*;
| ^~~
a.cc:2:1: error: 'use' does not name a type
2 | use std::io;
| ^~~
a.cc:4:1: error: 'fn' does not name a type
4 | fn read_to_string() -> String {
| ^~
a.cc:11:1: error: 'fn' does not name a type
11 | fn solve(p: Vec<u64>, q: Vec<u64>) -> u64 {
| ^~
a.cc:39:1: error: 'fn' does not name a type
39 | fn main() {
| ^~
|
s577548945
|
p03962
|
C++
|
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second
using namespace std;
int main(){
int input;
set<int> st;
Srep(3){
cin >> input;
st.insert(input);
}
cout << st.size() << endl;
}
|
a.cc: In function 'int main()':
a.cc:28:3: error: 'set' was not declared in this scope
28 | set<int> st;
| ^~~
a.cc:9:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
8 | #include<bitset>
+++ |+#include <set>
9 |
a.cc:28:7: error: expected primary-expression before 'int'
28 | set<int> st;
| ^~~
a.cc:31:5: error: 'st' was not declared in this scope; did you mean 'std'?
31 | st.insert(input);
| ^~
| std
a.cc:33:11: error: 'st' was not declared in this scope; did you mean 'std'?
33 | cout << st.size() << endl;
| ^~
| std
|
s861426754
|
p03962
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;
inline bool chmin(ll &a, ll b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
inline bool chmax(ll &a, ll b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
template <typename T>
T seinomi(T a)
{
if (a > 0)
{
return a;
}
else
{
return 0;
}
}
//桁数取得
template <typename T>
T ketasuu(T num)
{
return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
if (n == 0)
{
return 1;
}
else
{
ll rep = a;
for (ll i = 1; i < n; i++)
{
rep *= a;
}
return rep;
}
}
template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
while (first != last)
{
*first++ = value;
++value;
}
}
template <typename T>
T amarinasi(T a, T b)
{
if (a % b == 0)
{
return a / b;
}
else if (a % b > 0)
{
return a / b + 1;
}
else
{
return a / b - 1;
}
}
//小数点以下10桁テンプレート(main関数内の最初に貼付け)
//std::cout << std::fixed << std::setprecision(10);
//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;
set<ll> se;
ll data;
int main()
{
ll a, b, c;
cin >> a >> b >> c;
se.insert(a);
se.insert(b);
se.insert(c);
data = se.size();
cout << data << endl;
}
|
a.cc: In function 'int main()':
a.cc:121:5: error: reference to 'data' is ambiguous
121 | data = se.size();
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:113:4: note: 'll data'
113 | ll data;
| ^~~~
a.cc:122:13: error: reference to 'data' is ambiguous
122 | cout << data << endl;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:113:4: note: 'll data'
113 | ll data;
| ^~~~
|
s905123372
|
p03962
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;
inline bool chmin(ll &a, ll b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
inline bool chmax(ll &a, ll b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
template <typename T>
T seinomi(T a)
{
if (a > 0)
{
return a;
}
else
{
return 0;
}
}
//桁数取得
template <typename T>
T ketasuu(T num)
{
return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
if (n == 0)
{
return 1;
}
else
{
ll rep = a;
for (ll i = 1; i < n; i++)
{
rep *= a;
}
return rep;
}
}
template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
while (first != last)
{
*first++ = value;
++value;
}
}
template <typename T>
T amarinasi(T a, T b)
{
if (a % b == 0)
{
return a / b;
}
else if (a % b > 0)
{
return a / b + 1;
}
else
{
return a / b - 1;
}
}
//小数点以下10桁テンプレート(main関数内の最初に貼付け)
//std::cout << std::fixed << std::setprecision(10);
//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;
set<ll> data;
int main()
{
ll a, b, c;
cin >> a >> b >> c;
data.insert(a);
data.insert(b);
data.insert(c);
cout << data.size() << endl;
}
|
a.cc: In function 'int main()':
a.cc:117:5: error: reference to 'data' is ambiguous
117 | data.insert(a);
| ^~~~
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:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:112:9: note: 'std::set<long long int> data'
112 | set<ll> data;
| ^~~~
a.cc:118:5: error: reference to 'data' is ambiguous
118 | data.insert(b);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:112:9: note: 'std::set<long long int> data'
112 | set<ll> data;
| ^~~~
a.cc:119:5: error: reference to 'data' is ambiguous
119 | data.insert(c);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:112:9: note: 'std::set<long long int> data'
112 | set<ll> data;
| ^~~~
a.cc:120:13: error: reference to 'data' is ambiguous
120 | cout << data.size() << endl;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:112:9: note: 'std::set<long long int> data'
112 | set<ll> data;
| ^~~~
|
s756153060
|
p03962
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b,c;
cin >> a >> b >> c;
if(a==b&&b==c){cout<<1<<endl;}
else if(a!=b&&b!&&c||c!=a){cout<<3<<endl;}
else {cout<<2<<endl;}
}
|
a.cc: In function 'int main()':
a.cc:9:16: error: expected ')' before '!' token
9 | else if(a!=b&&b!&&c||c!=a){cout<<3<<endl;}
| ~ ^
| )
|
s544110474
|
p03962
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b,c;
cin >> a >> b >> c;
if(a==b&&b==c){cout<<1<<endl;}
else if(a!==b||b!==C||c!==a){cout<<3<<endl;}
else {cout<<2<<endl;}
}
|
a.cc: In function 'int main()':
a.cc:9:12: error: expected primary-expression before '=' token
9 | else if(a!==b||b!==C||c!==a){cout<<3<<endl;}
| ^
a.cc:9:19: error: expected primary-expression before '=' token
9 | else if(a!==b||b!==C||c!==a){cout<<3<<endl;}
| ^
a.cc:9:20: error: 'C' was not declared in this scope
9 | else if(a!==b||b!==C||c!==a){cout<<3<<endl;}
| ^
a.cc:9:26: error: expected primary-expression before '=' token
9 | else if(a!==b||b!==C||c!==a){cout<<3<<endl;}
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.