submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s824147676 | p00478 | C++ | #include <iostream>
#include <string>
using namespace std;
char str[11];
int n;
const int MAX_N = 100;
char s[MAX_N][11];
char t[MAX_N][22];
int count = 0;
void check(int i){
for(int j=0;t[i][j]!='\0';j++){
int k;
for(k=0;str[k] != '\0';k++){
if(t[i][j+k] != str[k]){
break;
}
}
if(str[k] == '\0'){
count++;
return;
}
}
return;
}
int main()
{
cin >> str;
cin >> n;
for(int i=0;i<n;i++){
cin >> s[i];
strcpy(t[i],s[i]);
strcat(t[i],s[i]);
}
for(int i=0;i<n;i++){
check(i);
}
cout << count <<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:33:17: error: 'strcpy' was not declared in this scope
33 | strcpy(t[i],s[i]);
| ^~~~~~
a.cc:2:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #include <string>
a.cc:34:17: error: 'strcat' was not declared in this scope
34 | strcat(t[i],s[i]);
| ^~~~~~
a.cc:34:17: note: 'strcat' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s583083081 | p00478 | C++ | import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String args[]) {
String tar = sc.next();
int N = sc.nextInt();
int ans = 0;
for(int i = 0; i < N; i++) {
String s = sc.next();
String con = s + s;
if(con.contains(tar)) ans++;
}
System.out.println(ans);
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main {
| ^~~~~~
|
s768472179 | p00478 | C++ | #include <cstdio>
#include <string.h>
int i;
int n,num=0;
int main(){
char search[10];
while(search[i]!=NULL) scanf("%c\n",&search[i]);
scanf("%d\n",&n);
for(int j=0;j<n;j++){
char array[10];
char array2[20];
scanf("%c",&array[i]);
strncat(array2,array,10);
strncpy(array2,array,10);
if (strpbrk(array2,search )!=0) num++;
{
}
}
return 0; | a.cc: In function 'int main()':
a.cc:9:26: warning: NULL used in arithmetic [-Wpointer-arith]
9 | while(search[i]!=NULL) scanf("%c\n",&search[i]);
| ^~~~
a.cc:22:26: error: expected '}' at end of input
22 | return 0;
| ^
a.cc:7:11: note: to match this '{'
7 | int main(){
| ^
|
s757217877 | p00478 | C++ | #include <iostream>
#include <string>
using namespace std;
int main(void)
{
string fin,model;
int n,ans=0;
cin >> fin;
cin >> n;
for(int i = 0; i < n; i++){
cin >> model;
model += model;
if(strstr(model.c_str(), fin.c_str()))
ans++;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:17:20: error: 'strstr' was not declared in this scope
17 | if(strstr(model.c_str(), fin.c_str()))
| ^~~~~~
a.cc:2:1: note: 'strstr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #include <string>
|
s072686550 | p00478 | C++ | #include<stdio.h>
#include<algorithm>
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
int main(){
char k[11];
int n,cnt=0;;
char s[21];
size_t l=sizeof(char)*10;
scanf("%s%d",k,&n);
rep(i,n){
scanf("%s",s);
memcpy(s+10,s,l);
if(strstr(s,k)!=NULL)cnt++;
}
printf("%d\n",cnt);
return 0;
} | a.cc: In function 'int main()':
a.cc:18:17: error: 'memcpy' was not declared in this scope
18 | memcpy(s+10,s,l);
| ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 |
a.cc:19:20: error: 'strstr' was not declared in this scope
19 | if(strstr(s,k)!=NULL)cnt++;
| ^~~~~~
a.cc:19:20: note: 'strstr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s850188192 | p00478 | C++ | include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
string s;
cin >> s;
int n,ret = 0;
cin >> n;
for(int i = 0 ; i < n ; i++ ){
string buff;
cin >> buff;
buff += buff + buff + buff + buff;
if(buff.find(s)) ret++;
}
cout << ret << endl;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
|
s562713086 | p00478 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int s,m[10],mz;
int k,i;
int cnt;
cnt=0;
scanf("%s",&s);
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%s",&m[i]);
}
for(i=0;i<k;i++){
strcat(mz,m[i]);
if(strstr(mz,s)){
cnt++;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:24: error: invalid conversion from 'int' to 'char*' [-fpermissive]
15 | strcat(mz,m[i]);
| ^~
| |
| int
In file included from a.cc:2:
/usr/include/string.h:149:39: note: initializing argument 1 of 'char* strcat(char*, const char*)'
149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:15:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
15 | strcat(mz,m[i]);
| ~~~^
| |
| int
/usr/include/string.h:149:70: note: initializing argument 2 of 'char* strcat(char*, const char*)'
149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:16:26: error: no matching function for call to 'strstr(int&, int&)'
16 | if(strstr(mz,s)){
| ~~~~~~^~~~~~
/usr/include/string.h:330:14: note: candidate: 'char* strstr(char*, const char*)' (near match)
330 | extern char *strstr (char *__haystack, const char *__needle)
| ^~~~~~
/usr/include/string.h:330:14: note: conversion of argument 2 would be ill-formed:
a.cc:16:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
16 | if(strstr(mz,s)){
| ^
| |
| int
/usr/include/string.h:332:20: note: candidate: 'const char* strstr(const char*, const char*)' (near match)
332 | extern const char *strstr (const char *__haystack, const char *__needle)
| ^~~~~~
/usr/include/string.h:332:20: note: conversion of argument 2 would be ill-formed:
a.cc:16:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
16 | if(strstr(mz,s)){
| ^
| |
| int
|
s063741260 | p00478 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int s,m[10],mz;
int k,i;
int cnt;
cnt=0;
scanf("%s",s);
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%s",m[i]);
}
for(i=0;i<k;i++){
strcat(mz,m[i]);
if(strstr(mz,s)){
cnt++;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:24: error: invalid conversion from 'int' to 'char*' [-fpermissive]
15 | strcat(mz,m[i]);
| ^~
| |
| int
In file included from a.cc:2:
/usr/include/string.h:149:39: note: initializing argument 1 of 'char* strcat(char*, const char*)'
149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:15:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
15 | strcat(mz,m[i]);
| ~~~^
| |
| int
/usr/include/string.h:149:70: note: initializing argument 2 of 'char* strcat(char*, const char*)'
149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:16:26: error: no matching function for call to 'strstr(int&, int&)'
16 | if(strstr(mz,s)){
| ~~~~~~^~~~~~
/usr/include/string.h:330:14: note: candidate: 'char* strstr(char*, const char*)' (near match)
330 | extern char *strstr (char *__haystack, const char *__needle)
| ^~~~~~
/usr/include/string.h:330:14: note: conversion of argument 2 would be ill-formed:
a.cc:16:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
16 | if(strstr(mz,s)){
| ^
| |
| int
/usr/include/string.h:332:20: note: candidate: 'const char* strstr(const char*, const char*)' (near match)
332 | extern const char *strstr (const char *__haystack, const char *__needle)
| ^~~~~~
/usr/include/string.h:332:20: note: conversion of argument 2 would be ill-formed:
a.cc:16:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
16 | if(strstr(mz,s)){
| ^
| |
| int
|
s033906711 | p00478 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int s,m[10],mz;
int k,i;
int cnt;
cnt=0;
scanf("%s",&s);
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%s",&m[i]);
}
for(i=0;i<k;i++){
strcat(mz,m[i]);
if(strstr(mz,s)){
cnt++;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:24: error: invalid conversion from 'int' to 'char*' [-fpermissive]
15 | strcat(mz,m[i]);
| ^~
| |
| int
In file included from a.cc:2:
/usr/include/string.h:149:39: note: initializing argument 1 of 'char* strcat(char*, const char*)'
149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:15:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
15 | strcat(mz,m[i]);
| ~~~^
| |
| int
/usr/include/string.h:149:70: note: initializing argument 2 of 'char* strcat(char*, const char*)'
149 | extern char *strcat (char *__restrict __dest, const char *__restrict __src)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:16:26: error: no matching function for call to 'strstr(int&, int&)'
16 | if(strstr(mz,s)){
| ~~~~~~^~~~~~
/usr/include/string.h:330:14: note: candidate: 'char* strstr(char*, const char*)' (near match)
330 | extern char *strstr (char *__haystack, const char *__needle)
| ^~~~~~
/usr/include/string.h:330:14: note: conversion of argument 2 would be ill-formed:
a.cc:16:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
16 | if(strstr(mz,s)){
| ^
| |
| int
/usr/include/string.h:332:20: note: candidate: 'const char* strstr(const char*, const char*)' (near match)
332 | extern const char *strstr (const char *__haystack, const char *__needle)
| ^~~~~~
/usr/include/string.h:332:20: note: conversion of argument 2 would be ill-formed:
a.cc:16:30: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
16 | if(strstr(mz,s)){
| ^
| |
| int
|
s528760655 | p00478 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
char* sr[10];
int slr;
char* sa[100][10];
int sla;
int kazoe=0;
int syokazoe=0;
printf("%s",sr);
cin>>sla;
for(int i=0;i<sla;i++){
printf("%s",sa[i]);
}
slr=(int)strlen(sr);
//いっこずつ
for(int i=0;i<sla;i++){
//開始位置
for(int j=0;j<10;j++){
//文字
for(int k=0;k<slr;k++){
if(sr[k]!=sa[i][j%10]){
break;
}
else{
syokazoe++;
}
}
if(syokazoe==slr){
kazoe++;
break;
}
syokazoe=0;
}
}
cout<<kazoe;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:25: error: cannot convert 'char**' to 'const char*'
20 | slr=(int)strlen(sr);
| ^~
| |
| char**
In file included from /usr/include/c++/14/cstring:43,
from a.cc:3:
/usr/include/string.h:407:35: note: initializing argument 1 of 'size_t strlen(const char*)'
407 | extern size_t strlen (const char *__s)
| ~~~~~~~~~~~~^~~
|
s027549170 | p00478 | C++ | #include <iostream>
#include <string>
using namespace std;
int main() {
int N;
string str;
cin >> str;
cin >> N;
int goodR=0;
for(int i=0;i<N;i++){
string ring;
cin >> ring;
ring+=ring;
int now=0;
for(int j=0;j<20;j++){
if(str[now]==ring[j])
now++;
else if(str[0]==ring[j])
now=1;
else
now=0; | a.cc: In function 'int main()':
a.cc:21:19: error: expected '}' at end of input
21 | now=0;
| ^
a.cc:15:30: note: to match this '{'
15 | for(int j=0;j<20;j++){
| ^
a.cc:21:19: error: expected '}' at end of input
21 | now=0;
| ^
a.cc:10:25: note: to match this '{'
10 | for(int i=0;i<N;i++){
| ^
a.cc:21:19: error: expected '}' at end of input
21 | now=0;
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s693138436 | p00479 | Java | import java.util.*;class Main{public static void main(String[]n){Scanner s=new Scanner(System.in);for(int n=s.nextInt()+1,m=n/2,a,b,i=s.nextInt();i-->0;)System.out.println((m-1-Math.max(Math.abs((a=s.nextInt()-m)>0&&n%2>0?a-1:a),Math.abs((b=s.nextInt()-m)>0&&n%2>0?b-1:b)))%3+1);}} | Main.java:1: error: variable n is already defined in method main(String[])
import java.util.*;class Main{public static void main(String[]n){Scanner s=new Scanner(System.in);for(int n=s.nextInt()+1,m=n/2,a,b,i=s.nextInt();i-->0;)System.out.println((m-1-Math.max(Math.abs((a=s.nextInt()-m)>0&&n%2>0?a-1:a),Math.abs((b=s.nextInt()-m)>0&&n%2>0?b-1:b)))%3+1);}}
^
1 error
|
s225062038 | p00479 | C | #include<stdio.h>
int main(){
int n,k,ai,bi,i,k,c;
scanf("%d",&n);
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d%d",&ai,&bi);
if(n+1-ai<ai)ai=n+1-ai;
if(n+1-bi<bi)bi=n+1-bi;
if(ai>bi)c=(ai-1)%3+1;
else c=(bi-1)%3+1;
printf("%d\n",c);
}
return 0;
}
| main.c: In function 'main':
main.c:3:25: error: redeclaration of 'k' with no linkage
3 | int n,k,ai,bi,i,k,c;
| ^
main.c:3:15: note: previous declaration of 'k' with type 'int'
3 | int n,k,ai,bi,i,k,c;
| ^
|
s336708073 | p00479 | C | #include<stdio.h>
int main(){
int n,k,ai,bi,i,k,c;
scanf("%d",&n);
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d%d",&ai,&bi);
if(n+1-ai<ai)ai=n+1-ai;
if(n+1-bi<bi)bi=n+1-bi;
if(ai>bi)c=(ai-1)%3+1;
else c=(bi-1)%3+1;
printf("%d\n",c);
}
return 0;
}
| main.c: In function 'main':
main.c:3:25: error: redeclaration of 'k' with no linkage
3 | int n,k,ai,bi,i,k,c;
| ^
main.c:3:15: note: previous declaration of 'k' with type 'int'
3 | int n,k,ai,bi,i,k,c;
| ^
|
s545829144 | p00479 | C | #include<stdio.h>
int main(){
int n,k,ai,bi,i,k,c;
scanf("%d",&n);
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d%d",&ai,&bi);
if(n+1-ai<ai)ai=n+1-ai;
if(n+1-bi<bi)bi=n+1-bi;
if(ai>bi)c=(bi-1)%3+1;
else c=(ai-1)%3+1;
printf("%d\n",c);
}
return 0;
}
| main.c: In function 'main':
main.c:3:25: error: redeclaration of 'k' with no linkage
3 | int n,k,ai,bi,i,k,c;
| ^
main.c:3:15: note: previous declaration of 'k' with type 'int'
3 | int n,k,ai,bi,i,k,c;
| ^
|
s658014779 | p00479 | C | #include<stdio.h>
int main()
{
int n,k,i,j,c,e,d,f,t,a,b;
scanf("%d %d",&n,&k);
e=n/2;
f=n%2;
for(i=0;i<k;i++){
scanf("%d %d",&a,&b);
if(f==0){
if(a==e){
c=n-a;
c=c%3;
}
else if(b==e){
c=n-b;
c=c%3;
}
}
if(a<e && b<e){
c=min(a,b);
c=c%3;
}
else if(a>e && b<e){
c=min(a,b);
c=c%3;
}
else if(a<e && b>e){
c=min(a,b);
t=c+1;
t=n-t;
c=t%3;
}
else if(a>e && b>e){
c=max(a,b);
t=c+1;
t=n-t;
c=t%3;
}
if(c==0){
c=3;
}
printf("%d\n",c);
}
return 0;
}
int max(int a,int b)
{
int c;
if(a<b){
c=b;
}
else{
c=a;
}
return c;
}
int min(int a,int b)
{
int c;
if(a<b){
c=a;
}
else{
c=b;
}
return c;
}}
| main.c: In function 'main':
main.c:21:27: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
21 | c=min(a,b);
| ^~~
| main
main.c:35:27: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
35 | c=max(a,b);
| ^~~
main.c: At top level:
main.c:68:2: error: expected identifier or '(' before '}' token
68 | }}
| ^
|
s382721191 | p00479 | C | #include<stdio.h>
volatile int N
//int N=0;
int KIMOCHI(int a,int b)
{
//int N;
// A
if(a<b){
if(a+b<=N){
if(a%3==0){
return 3;
}
else{
return a%3;
}
}
else{
//int cy=N-b+1;
if((N-b+1)%3==0){
return 3;
}
else{
return (N-b+1)%3;
}
}
}
// B
else {
//int cy;
//cy=N-a+1;
if(a+b<=N){
if(b%3==0){
return 3;
}
else{
return b%3;
}
}
else{
if((N-a+1)%3==0){
return 3;
}
else{
//不安↓
return (N-a+1)%3;
}
}
}
}
int main(void)
{
//int N;
int a,b,cy;
int K,i;
scanf("%d%d",&N,&K);
for(i=0;i<K;i++){
scanf("%d%d",&a,&b);
//不安↓
printf("%d\n",KIMOCHI(a,b));
}
return 0;
}
| main.c:2:15: error: expected ';' before 'int'
2 | volatile int N
| ^
| ;
3 | //int N=0;
4 | int KIMOCHI(int a,int b)
| ~~~
main.c: In function 'KIMOCHI':
main.c:9:25: error: 'N' undeclared (first use in this function)
9 | if(a+b<=N){
| ^
main.c:9:25: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:56:23: error: 'N' undeclared (first use in this function)
56 | scanf("%d%d",&N,&K);
| ^
|
s037899648 | p00479 | C | #include <stdio.h>
#defaine N 1000000000
int main(){
int kabe[N][N],a[N],b[N];
int nagasa,naga,i,j,k,l,m=0,n;
int t,f;
scanf("%d",&nagasa);
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
naga=nagasa-1;
if(nagasa%2==1){
for(i=0;i<nagasa/2+1;i++){
if(m%3==0){
for(j=m;j<naga-i;j++){
for(k=m;k<naga-i;k++){
kabe[j][k]=1;
}
}
}
else if(m%3==1){
for(j=m;j<naga-i;j++){
for(k=m;k<naga-i;k++){
kabe[j][k]=2;
}
}
}
else if(m%3==1){
for(j=m;j<naga-i;j++){
for(k=m;k<naga-i;k++){
kabe[j][k]=2;
}
}
}
m++;
}
}
else if(nagasa%2==0){
for(i=0;i<nagasa/2;i++){
if(m%3==0){
for(j=m;j<naga-i;j++){
for(k=m;k<naga-i;k++){
kabe[j][k]=1;
}
}
}
else if(m%3==1){
for(j=m;j<naga-i;j++){
for(k=m;k<naga-i;k++){
kabe[j][k]=2;
}
}
}
else if(m%3==1){
for(j=m;j<naga-i;j++){
for(k=m;k<naga-i;k++){
kabe[j][k]=2;
}
}
}
m++;
}
}
for(i=0;i<n;i++){
t=b[i];
f=a[i];
printf("%d\n",kabe[t][f]);
}
return 0;
} | main.c:2:2: error: invalid preprocessing directive #defaine; did you mean #define?
2 | #defaine N 1000000000
| ^~~~~~~
| define
main.c: In function 'main':
main.c:5:10: error: 'N' undeclared (first use in this function)
5 | int kabe[N][N],a[N],b[N];
| ^
main.c:5:10: note: each undeclared identifier is reported only once for each function it appears in
|
s910604565 | p00479 | C++ | #include <iostream>
#include <algorithm>
#include<vector>
int main() {
int n;
int b;
std::cin >> n >> b;
std::vector<int> v(b);
for (int i = 0; i < b; ++i) {
int x, y;
int a = 0;
std::cin >> x >> y;
a = std::min(n - x, std::min(n - y, std::min(x-1, y-1)));
v[i] = a % 3;
}
for (int i = 0; i < b; ++i) {
if (v[i] == 0) {
std::cout << v[i] + 1 << std::endl;
}
if (v[i] == 1) {
std::cout << v[i] + 1 << std::endl;
}
if (v[i] == 2) {
std::cout << v[i] + 1 << std::endl;
}
}
| a.cc: In function 'int main()':
a.cc:26:10: error: expected '}' at end of input
26 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s982911406 | p00479 | C++ | int main(){
int i,i2,n,m,a,b,core,aa,bb,ans;
scanf("%d%d",&n,&m);
for(i=1;i<=m;i++){
scanf("%d%d",&a,&b);
aa=a;
bb=b;
core=n/2;
if(n%2==1)core++;
if(a>core)aa=n-aa+1;
if(b>core)bb=n-bb+1;
if(aa>bb){
ans=bb;
}
else{
ans=aa;
}
ans%=3;
if(ans==0)ans=3;
printf("%d\n",ans);
}
} | a.cc: In function 'int main()':
a.cc:3:9: error: 'scanf' was not declared in this scope
3 | scanf("%d%d",&n,&m);
| ^~~~~
a.cc:20:17: error: 'printf' was not declared in this scope
20 | printf("%d\n",ans);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int main(){
|
s240391262 | p00479 | C++ | #include <stdio.h>
int main(){
long int N,K,a,b,i,j,A,B;
scanf("%ld",&N);
scanf(" %ld",&K);
if(N%2==0){
for(a=0;a<K;a++){
scanf(" %ld %ld",&A,&B);
for(b=1;b<=N/2;b++){
if(A==b||B==b||A==(N-b+1)||B==(N-b+1)){
for(i=0;i<3;i++){
if(b%3==i){
printf("%ld\n",i+1);
break;
}
}
}
}
}
}
if(N%2!=0){
for(a=0;a<K;a++){
scanf(" %ld %ld",&A,&B);
for(b=1;b<N/2;b++){
if(A==b||B==b||A==(N-b+1)||B==(N-b+1)){
for(i=0;i<3;i++){
if(b%3==i){
printf("%ld\n",i+1);
break;
}
}
} else if (N/2+1==A){
for(i=1;i<N/2;i++){
if(B==i){
for(j=0;j<3;j++){
if(B%3==j){
printf("%ld\n",j+1);
break;
}
}
}
}
} else if (N/2+1==B){
for(i=1;i<N/2;i++){
if(A==i){
for(j=0;j<3;j++){
if(B%3==j){
printf("%ld\n",j+1);
break;
}
}
}
}
} else {
for(j=0;j<3;j++){
if(A%3=j){
printf("%ld\n",j+1);
break;
}
}
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:56:17: error: lvalue required as left operand of assignment
56 | if(A%3=j){
| ~^~
|
s494256360 | p00479 | C++ | #include<stdio.h>
int main()
{
int n,k,i,j,c,e,d,f,t,a[10000],b[10000];
scanf("%d %d",&n,&k);
for(i=0;i<k;i++){
scanf("%d %d",&a[i],&b[i]);
}
e=n/2;
f=n%2;
for(i=0;i<k;i++){
if(f==0){
if(a[i]==e){
c=n-a[i];
c=c%3;
}
else if(b[i]==e){
c=n-b[i];
c=c%3;
}
}
if(a[i]<e && b[i]<e){
c=min(a[i],b[i]);
c=c%3;
}
else if(a[i]>e && b[i]<e){
c=min(a[i],b[i]);
c=c%3;
}
else if(a[i]<e && b[i]>e){
c=min(a[i],b[i]);
c=c%3;
}
else if(a[i]>e && b[i]>e){
c=max(a[i],b[i]);
t=n-c+1;
c=t%3;
}
if(c==0){
c=3;
}
printf("%d\n",c);
}
return 0;
}
int max(int a,int b)
{
int c;
if(a<b){
c=b;
}
else{
c=a;
}
return c;
}
int min(int a,int b)
{
int c;
if(a<b){
c=a;
}
else{
c=b;
}
return c;
}
| a.cc: In function 'int main()':
a.cc:23:27: error: 'min' was not declared in this scope; did you mean 'main'?
23 | c=min(a[i],b[i]);
| ^~~
| main
a.cc:27:27: error: 'min' was not declared in this scope; did you mean 'main'?
27 | c=min(a[i],b[i]);
| ^~~
| main
a.cc:31:27: error: 'min' was not declared in this scope; did you mean 'main'?
31 | c=min(a[i],b[i]);
| ^~~
| main
a.cc:35:27: error: 'max' was not declared in this scope
35 | c=max(a[i],b[i]);
| ^~~
|
s213957755 | p00479 | C++ | #include<iostream>
using namespace std;
main(n,k,x,y,w){
cin>>n>>k;
while(k--){
cin>>x>>y;
cout<<(min(min(x,y),min(n-x+1,n-y+1))-1)%3+1<<endl;
}
} | a.cc:3:5: error: expected constructor, destructor, or type conversion before '(' token
3 | main(n,k,x,y,w){
| ^
|
s454645419 | p00479 | C++ | #include<iostream>
using namespace std;
main(n,k,x,y,w){
cin>>n>>k;
while(k--){
cin>>x>>y;
cout<<(min(min(x,y),min(n-x+1,n-y+1))-1)%3+1<<endl;
}
return 0;
} | a.cc:3:5: error: expected constructor, destructor, or type conversion before '(' token
3 | main(n,k,x,y,w){
| ^
|
s889863161 | p00479 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int n,k;//nÍ¢ÁØñÉA^CÌBkÍͪê½
int a,b;
int main(){
scanf("%d\n",&n);
scanf("%d\n",&k);
for (int j=0;j<k;j++){
scanf("%d",&a);
scanf("%d",&b);
int x = a-1;
int y = b-1;
int z = n-x-1;
int w = n-y-1;
int m = min(min(x,y),min(z,w));
printf("%d\n",m%3+1);
}
retur | a.cc: In function 'int main()':
a.cc:24:9: error: 'retur' was not declared in this scope
24 | retur
| ^~~~~
a.cc:24:14: error: expected '}' at end of input
24 | retur
| ^
a.cc:9:11: note: to match this '{'
9 | int main(){
| ^
|
s657288687 | p00479 | C++ | #include <stdio.h>
#define N 1000000000
int main(){
int n,i,j,f,t,a[N][N];
int k,h,w;
f=0;
t=3;
scanf("%d",&n);
while(1){
if(t<=2)break;
t=0;
if(f%3==0){
for(i=f;i<n-f;i++){
t++;
for(j=f;j<n-f;j++){
a[i][j]=1;
}
}
f++;
continue;
}
else if(f%3==1){
for(i=f;i<n-f;i++){
t++;
for(j=f;j<n-f;j++){
a[i][j]=2;
}
}
f++;
continue;
}
else if(f%3==2){
for(i=f;i<n-f;i++){
t++;
for(j=f;j<n-f;j++){
a[i][j]=3;
}
}
f++;
continue;
}
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d %d",&h,&w);
printf("%d\n",a[h-1][w-1]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:52:2: error: expected '}' at end of input
52 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s299958438 | p00479 | C++ | #define N 1000000000
int main(){
int n,i,j,f,t,a[N][N];
int k,x,y,h[1001],w[1001];
f=0;
t=3;
scanf("%d",&n);
while(1){
if(t<=2)break;
t=0;
if(f%3==0){
for(i=f;i<n-f;i++){
t++;
for(j=f;j<n-f;j++){
a[i][j]=1;
}
}
f++;
continue;
}
else if(f%3==1){
for(i=f;i<n-f;i++){
t++;
for(j=f;j<n-f;j++){
a[i][j]=2;
}
}
f++;
continue;
}
else if(f%3==2){
for(i=f;i<n-f;i++){
t++;
for(j=f;j<n-f;j++){
a[i][j]=3;
}
}
f++;
continue;
}
}
scanf("%d",&k);
for(i=1;i<=k;i++){
scanf("%d %d",&h[i],&w[i]);
}
for(i=1;i<=k;i++){
x=h[i];
y=w[i];
printf("%d\n",a[x-1][y-1]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:1: error: 'scanf' was not declared in this scope
9 | scanf("%d",&n);
| ^~~~~
a.cc:53:1: error: 'printf' was not declared in this scope
53 | printf("%d\n",a[x-1][y-1]);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #define N 1000000000
|
s614341599 | p00479 | C++ | #include <stdio.h>
int min(int,int);
int main(){
int n,k,i,x,y,f;
scanf("%d%d",&n,&k);
for(i=0;i<k;i++){
scanf("%d %d",&x,&y);
x= x>=n/2 ? n-x+1:x;
y= y>=n/2 ? n-y+1:y;
f=(min(x,y)%3 ? min(x,y)%3:3;
printf("%d\n",f);
}
return 0;
}
int min(int a,int b)
{
if(a>b){
return b;
}
return a;
} | a.cc: In function 'int main()':
a.cc:13:29: error: expected ')' before ';' token
13 | f=(min(x,y)%3 ? min(x,y)%3:3;
| ~ ^
| )
|
s649136298 | p00479 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int n,k;
vector<int> ans;
cin >> n >> k;
while(k--){
cin >> x >> y;
int h = min(x,n-x+1);
int w = min(y,n-y+1);
if(h > w){
ans.push_back(w-1)%3+1;
}
else{
ans.push_back(h-1)%3+1;
}
}
int len = ans.size();
for(int i=0;i<len;i++)cout << ans[i] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:24: error: 'x' was not declared in this scope
14 | cin >> x >> y;
| ^
a.cc:14:29: error: 'y' was not declared in this scope
14 | cin >> x >> y;
| ^
a.cc:20:43: error: invalid operands of types 'void' and 'int' to binary 'operator%'
20 | ans.push_back(w-1)%3+1;
| ~~~~~~~~~~~~~~~~~~^~
| | |
| void int
a.cc:23:43: error: invalid operands of types 'void' and 'int' to binary 'operator%'
23 | ans.push_back(h-1)%3+1;
| ~~~~~~~~~~~~~~~~~~^~
| | |
| void int
|
s784751013 | p00479 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int n,k;
vector<int> ans;
cin >> n >> k;
while(k--){
int x,y;
cin >> x >> y;
int h = min(x,n-x+1);
int w = min(y,n-y+1);
if(h > w){
ans.push_back(w-1)%3+1;
}
else{
ans.push_back(h-1)%3+1;
}
}
int len = ans.size();
for(int i=0;i<len;i++)cout << ans[i] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:43: error: invalid operands of types 'void' and 'int' to binary 'operator%'
21 | ans.push_back(w-1)%3+1;
| ~~~~~~~~~~~~~~~~~~^~
| | |
| void int
a.cc:24:43: error: invalid operands of types 'void' and 'int' to binary 'operator%'
24 | ans.push_back(h-1)%3+1;
| ~~~~~~~~~~~~~~~~~~^~
| | |
| void int
|
s003470652 | p00479 | C++ | #include <stdio.h>
#include <algorithm>
int ans[1005];
int main(void)
{
int n, k, a, b;
int i, j, s;
int lenl, lenr, lent, lenb;
scanf("%d", &n);
scanf("%d", &k);
for (i = 0; i < k; i++){
scanf("%d %d", &a, &b);
lenl = a - 1;
lenr = n - a;
lent = b - 1;
lenb = n - b;
s = min(min(lenl, lenr), min(lent, lenb));
ans[i] = s % 3 + 1;
}
for (i = 0; i < k; i++){
printf("%d\n", ans[i]);
}
return (0);
}
| a.cc: In function 'int main()':
a.cc:22:25: error: 'min' was not declared in this scope; did you mean 'std::min'?
22 | s = min(min(lenl, lenr), min(lent, lenb));
| ^~~
| std::min
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
a.cc:22:21: error: 'min' was not declared in this scope; did you mean 'std::min'?
22 | s = min(min(lenl, lenr), min(lent, lenb));
| ^~~
| std::min
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
|
s106154482 | p00480 | Java | import java.util.Scanner;
// First Grader
public class Main2 {
public static void main(String[] args) {
new Main2().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] number = new int[n];
for (int i = 0; i < n; i++)
number[i] = sc.nextInt();
long[][] dp = new long[n][21];
dp[0][0] = 1;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < 21; j++) {
if (dp[i][j] > 0) {
if (j + number[i] < 21)
dp[i + 1][j + number[i]] += dp[i][j];
if (j - number[i] >= 0)
dp[i + 1][j - number[i]] += dp[i][j];
}
}
}
System.out.println(dp[n - 1][number[n - 1]]);
sc.close();
}
}
import java.util.Scanner;
// First Grader
public class Main2 {
public static void main(String[] args) {
new Main2().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] number = new int[n];
for (int i = 0; i < n; i++)
number[i] = sc.nextInt();
long[][] dp = new long[n][21];
dp[0][0] = 1;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < 21; j++) {
if (dp[i][j] > 0) {
if (j + number[i] < 21)
dp[i + 1][j + number[i]] += dp[i][j];
if (j - number[i] >= 0)
dp[i + 1][j - number[i]] += dp[i][j];
}
}
}
System.out.println(dp[n - 1][number[n - 1]]);
sc.close();
}
} | Main.java:31: error: class, interface, enum, or record expected
import java.util.Scanner;
^
1 error
|
s879192747 | p00480 | Java | import java.util.Scanner;
// First Grader
public class Main {
public static void main(String[] args) {
new Main2().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] number = new int[n];
for (int i = 0; i < n; i++)
number[i] = sc.nextInt();
long[][] dp = new long[n][21];
dp[0][0] = 1;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < 21; j++) {
if (dp[i][j] > 0) {
if (j + number[i] < 21)
dp[i + 1][j + number[i]] += dp[i][j];
if (j - number[i] >= 0)
dp[i + 1][j - number[i]] += dp[i][j];
}
}
}
System.out.println(dp[n - 1][number[n - 1]]);
sc.close();
}
}
import java.util.Scanner;
// First Grader
public class Main2 {
public static void main(String[] args) {
new Main2().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] number = new int[n];
for (int i = 0; i < n; i++)
number[i] = sc.nextInt();
long[][] dp = new long[n][21];
dp[0][0] = 1;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < 21; j++) {
if (dp[i][j] > 0) {
if (j + number[i] < 21)
dp[i + 1][j + number[i]] += dp[i][j];
if (j - number[i] >= 0)
dp[i + 1][j - number[i]] += dp[i][j];
}
}
}
System.out.println(dp[n - 1][number[n - 1]]);
sc.close();
}
} | Main.java:31: error: class, interface, enum, or record expected
import java.util.Scanner;
^
1 error
|
s570137143 | p00480 | Java | import java.util.Scanner;
// First Grader
public class Main {
public static void main(String[] args) {
new Main2().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] number = new int[n];
for (int i = 0; i < n; i++)
number[i] = sc.nextInt();
long[][] dp = new long[n][21];
dp[0][0] = 1;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < 21; j++) {
if (dp[i][j] > 0) {
if (j + number[i] < 21)
dp[i + 1][j + number[i]] += dp[i][j];
if (j - number[i] >= 0)
dp[i + 1][j - number[i]] += dp[i][j];
}
}
}
System.out.println(dp[n - 1][number[n - 1]]);
sc.close();
}
} | Main.java:6: error: cannot find symbol
new Main2().run();
^
symbol: class Main2
location: class Main
1 error
|
s384166415 | p00480 | C | #include<stdio.h>
int main(void) {
longlong kaz[101][21] = { 0 };
int n,su[101];
int i,j;
scanf("%d", &n);
for (i = 0;i < n;i++) {
scanf("%d", &su[i]);
}
kaz[0][su[0]]++;
for (i = 1;i < n - 1;i++) {
for (j = 0;j < 21;j++) {
if (kaz[i-1][j] >= 1) {
if (j + su[i] < 21) {
kaz[i][j + su[i]] += kaz[i - 1][j];
}
if (j - su[i] >= 0) {
kaz[i][j - su[i]] += kaz[i - 1][j];
}
}
}
}
printf("%lld\n", kaz[n - 2][su[n - 1]]);
for (i = 0;i < n;i++) {
for (j = 0;j < 21;j++) {
printf("%lld", kaz[i][j]);
}
printf("\n");
}
return 0;
} | main.c: In function 'main':
main.c:3:9: error: unknown type name 'longlong'
3 | longlong kaz[101][21] = { 0 };
| ^~~~~~~~
|
s063677743 | p00480 | C | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");} | main.c:1:1: warning: data definition has no type or storage class
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:1:3: error: return type defaults to 'int' [-Wimplicit-int]
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
| ^~~~
main.c: In function 'main':
main.c:1:10: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
main.c:1:10: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
| ^~~~~
main.c:1:10: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:25: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
| ^~~~
main.c:1:25: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:1:49: error: invalid operands to binary - (have 'int' and 'char *')
1 | a;main(){scanf("%d",&a);puts(a-=20?a-=20?a-=10?a-=40?"671013170798012928":"31320243434344576":"1671496112":"3443144":"488");}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| char *
|
s651409706 | p00480 | C | #include<cstdio>
int i,j,k,n;
long long int a[110][25],x;
//long long int b;
int main(){
scanf("%d%lld",&n,&x);
for(i=0;i<n-1;i++)for(j=0;j<=20;j++)a[i][j]=0;
a[0][x]=1;
for(i=1;i<n-1;i++){
scanf("%lld",&x);
for(j=0;j<=20;j++){
if(a[i-1][j]>0){
if(j+x<=20 && j+x>=0)a[i][j+x]+=a[i-1][j];
if(j-x<=20 && j-x>=0)a[i][j-x]+=a[i-1][j];
}
}
}
scanf("%lld",&x);
printf("%lld",a[n-2][x]);
return 0;
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s844592135 | p00480 | C | #include<iostream>
long long a[2][40],i,n,j;main(){for(a[1][9]=1;std::cin>>n;++i)for(j=8;i&&++j-30;)a[~i&1][j]=a[i&1][j-n]+a[i&1][j+n];std::cout<<a[~i&1][n+9]<<'\n';} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s660786360 | p00480 | C | #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> num;
int total,limit;
long long cont=0;
void math(int pl,int res){
int add,sub;
add = res + num[pl];
sub = res - num[pl];
if(add<=20 && add>=0){
if(pl==limit-2 && add==total){
cont++;
}
math(pl+1,add);
}
if(sub<=20 && sub>=0){
if(pl==limit-2 && sub==total){
cont++;
}
math(pl+1,sub);
}
}
int main(){
string equa;
cin>>limit;
cin.ignore();
getline(cin,equa);
for(int i = 0 ; i < equa.size() ; i++){
if(equa[i]!=' ')
num.push_back(equa[i]-'0');
}
total = equa[equa.size()-1] - '0';
math(0,0);
cout<<cont<<endl;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s710050143 | p00480 | C | #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> num;
int total,limit;
long long cont=0;
void math(int pl,int res){
int add,sub;
add = res + num[pl];
sub = res - num[pl];
if(add<=20 && add>=0){
if(pl==limit-2 && add==total){
cont++;
}
math(pl+1,add);
}
if(sub<=20 && sub>=0){
if(pl==limit-2 && sub==total){
cont++;
}
math(pl+1,sub);
}
}
int main(){
string equa;
cin>>limit;
cin.ignore();
getline(cin,equa);
for(int i = 0 ; i < equa.size() ; i++){
if(equa[i]!=' ')
num.push_back(equa[i]-'0');
}
total = equa[equa.size()-1] - '0';
math(0,0);
cout<<cont<<endl;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s074581495 | p00480 | C | #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
ll num[101];
ll memo[101][101];
ll limit;
ll math(ll p,ll sum){
if(sum<0 || sum>20) return 0;
else if(p == limit-1 )return sum == num[p];
else if(memo[p][sum]>0)return memo[p][sum];
else return memo[p][sum] = math(p+1,sum+num[p])+math(p+1,sum-num[p]);
}
int main(){
cin>>limit;
for(int i = 0 ; i < limit ; i++)cin>>num[i];
cout<<math(1,num[0])<<endl;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s379206666 | p00480 | C | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;} | main.c:1:1: warning: data definition has no type or storage class
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int]
main.c:1:8: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^
main.c:1:10: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^
main.c:1:12: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^
main.c:1:14: error: expected identifier or '(' before 'long'
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~~~
main.c:1:35: error: return type defaults to 'int' [-Wimplicit-int]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~~~
main.c: In function 'main':
main.c:1:42: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
main.c:1:42: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~~~~
main.c:1:42: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:96: error: 'dp' undeclared (first use in this function)
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~
main.c:1:96: note: each undeclared identifier is reported only once for each function it appears in
main.c:1:201: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | x[101],i,j,n,long long dp[80][80];main(){scanf("%lld",&n);for(i=1;i<=n;i++){scanf("%d",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~~~~~
main.c:1:201: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:201: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:201: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s765960580 | p00480 | C | #include <stdio.h>long long x[101],i,j,dp[100][80],n;main(){scanf("%d",&n);for(i=1;i<=n;i++){scanf("%lld",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;} | main.c:1:19: warning: extra tokens at end of #include directive
1 | #include <stdio.h>long long x[101],i,j,dp[100][80],n;main(){scanf("%d",&n);for(i=1;i<=n;i++){scanf("%lld",&x[i]);}dp[1][50+x[1]]=1;for(i=2;i<n;i++){for(j=0;j<=20;j++){dp[i][50+j]=dp[i-1][50+j+x[i]]+dp[i-1][50+j-x[i]];}}printf("%lld\n",dp[n-1][50+x[n]]);return 0;}
| ^~~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s366709075 | p00480 | C | #include <stdio.h>
#include <string.h>
#define N 101
int n;
int right;
int val[N];
__int64 memo[N][21];
// 今まで合計値=num
__int64 getWay(int i, int num)
{
__int64 ret = 0;
if (memo[i][num] >= 0){
return (memo[i][num]);
}
if (i == n - 1){
if (num == right){
return (1);
}
else {
return (0);
}
}
if (num + val[i] <= 20){
ret += getWay(i + 1, num + val[i]);
}
if (num - val[i] >= 0){
ret += getWay(i + 1, num - val[i]);
}
return (memo[i][num] = ret);
}
int main(void)
{
int i, j;
scanf("%d", &n);
for (i = 0; i < n - 1; i++){
scanf("%d", val + i);
}
scanf("%d", &right);
memset(memo, -1, sizeof(memo));
printf("%llu\n", getWay(0,0));
return (0);
} | main.c:9:1: error: unknown type name '__int64'; did you mean '__int64_t'?
9 | __int64 memo[N][21];
| ^~~~~~~
| __int64_t
main.c:12:1: error: unknown type name '__int64'; did you mean '__int64_t'?
12 | __int64 getWay(int i, int num)
| ^~~~~~~
| __int64_t
main.c: In function 'getWay':
main.c:14:9: error: unknown type name '__int64'; did you mean '__int64_t'?
14 | __int64 ret = 0;
| ^~~~~~~
| __int64_t
|
s110554992 | p00480 | C | #include <stdio.h>
#include <string.h>
#define N 101
#define RIGHT 100
int shiki[N];
int n;
__int64 memo[N][21];
// i番目の数字, 今までの合計値
__int64 getWay(int i, int num)
{
__int64 ret = 0;
int dx[] = {1, -1};
int j;
if (memo[i][num] != -1){
return (memo[i][num]);
}
if (i == n - 2){
if (num == shiki[RIGHT]){
return (1);
}
return (0);
}
for (j = 0; j < 2; j++){
int val = num + shiki[i + 1] * dx[j];
if (val >= 0 && val <= 20){
ret += getWay(i + 1, val);
}
}
return (memo[i][num] = ret);
}
int main(void)
{
int i;
memset(memo, -1, sizeof(memo));
scanf("%d", &n);
for (i = 0; i < n - 1; i++){
scanf("%d", shiki + i);
}
scanf("%d", shiki + RIGHT);
printf("%I64d\n", getWay(0, shiki[0]));
return (0);
} | main.c:9:1: error: unknown type name '__int64'; did you mean '__int64_t'?
9 | __int64 memo[N][21];
| ^~~~~~~
| __int64_t
main.c:12:1: error: unknown type name '__int64'; did you mean '__int64_t'?
12 | __int64 getWay(int i, int num)
| ^~~~~~~
| __int64_t
main.c: In function 'getWay':
main.c:14:9: error: unknown type name '__int64'; did you mean '__int64_t'?
14 | __int64 ret = 0;
| ^~~~~~~
| __int64_t
|
s204795865 | p00480 | C | #include ,stdio.h> | main.c:1:10: error: #include expects "FILENAME" or <FILENAME>
1 | #include ,stdio.h>
| ^
|
s736069587 | p00480 | C++ | #include <cstdio>
#include <vector>
using namespace std;
#define MAX_N 100
typedef __int64 Int;
int N, A[MAX_N];
Int table[MAX_N][21];
Int dp(int p, int res){
if(res > 20 || res < 0) return 0;
if(p == N - 1){
return (res == A[p])? 1 : 0;
}
if(table[p][res] > -1) return table[p][res];
return table[p][res] = dp(p + 1, res + A[p]) + dp(p + 1, res - A[p]);
}
int main(){
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%d", A + i);
}
memset(table, -1, sizeof(table));
printf("%I64d\n", dp(0, 0));
return 0;
} | a.cc:6:9: error: '__int64' does not name a type; did you mean '__int64_t'?
6 | typedef __int64 Int;
| ^~~~~~~
| __int64_t
a.cc:8:1: error: 'Int' does not name a type; did you mean 'int'?
8 | Int table[MAX_N][21];
| ^~~
| int
a.cc:10:1: error: 'Int' does not name a type; did you mean 'int'?
10 | Int dp(int p, int res){
| ^~~
| int
a.cc: In function 'int main()':
a.cc:25:16: error: 'table' was not declared in this scope; did you mean 'mutable'?
25 | memset(table, -1, sizeof(table));
| ^~~~~
| mutable
a.cc:25:9: error: 'memset' was not declared in this scope
25 | memset(table, -1, sizeof(table));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <vector>
+++ |+#include <cstring>
3 | using namespace std;
a.cc:27:27: error: 'dp' was not declared in this scope
27 | printf("%I64d\n", dp(0, 0));
| ^~
|
s997991659 | p00480 | C++ | #include <cstdio>
#include <vector>
using namespace std;
#define MAX_N 100
typedef long long Int;
int N, A[MAX_N];
Int table[MAX_N][21];
Int dp(int p, int res){
if(res > 20 || res < 0) return 0;
if(p == N - 1){
return (res == A[p])? 1 : 0;
}
if(table[p][res] > -1) return table[p][res];
return table[p][res] = dp(p + 1, res + A[p]) + dp(p + 1, res - A[p]);
}
int main(){
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%d", A + i);
}
memset(table, -1, sizeof(table));
printf("%I64d\n", dp(0, 0));
return 0;
} | a.cc: In function 'int main()':
a.cc:25:9: error: 'memset' was not declared in this scope
25 | memset(table, -1, sizeof(table));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <vector>
+++ |+#include <cstring>
3 | using namespace std;
|
s196334933 | p00480 | C++ | #include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
using namespace std;
int a[100];
__int64 dp[100][21];
int n;
__int64 rec(int i, int j)
{
if (j < 0 || 20 < j)
{
return 0;
}
if (i == n - 2)
{
if (j == a[i])
{
return 1;
}
return 0;
}
if (dp[i][j] > -1)
{
return dp[i][j];
}
dp[i][j] = rec(i + 1, j + a[i + 1]) + rec(i + 1, j - a[i + 1]);
return dp[i][j];
}
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
memset(dp, -1, sizeof(dp));
cout << rec(0, a[0]) << endl;
return 0;
} | a.cc:11:1: error: '__int64' does not name a type; did you mean '__int64_t'?
11 | __int64 dp[100][21];
| ^~~~~~~
| __int64_t
a.cc:14:1: error: '__int64' does not name a type; did you mean '__int64_t'?
14 | __int64 rec(int i, int j)
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:46:16: error: 'dp' was not declared in this scope
46 | memset(dp, -1, sizeof(dp));
| ^~
a.cc:47:17: error: 'rec' was not declared in this scope
47 | cout << rec(0, a[0]) << endl;
| ^~~
|
s077810280 | p00480 | C++ | #include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
using namespace std;
int a[100];
__int64 dp[100][21];
int n;
__int64 rec(int i, int j)
{
if (j < 0 || 20 < j)
{
return 0;
}
if (i == n - 2)
{
if (j == a[i])
{
return 1;
}
return 0;
}
if (dp[i][j] > -1)
{
return dp[i][j];
}
dp[i][j] = rec(i + 1, j + a[i + 1]) + rec(i + 1, j - a[i + 1]);
return dp[i][j];
}
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
memset(dp, -1, sizeof(dp));
cout << rec(0, a[0]) << endl;
return 0;
} | a.cc:12:1: error: '__int64' does not name a type; did you mean '__int64_t'?
12 | __int64 dp[100][21];
| ^~~~~~~
| __int64_t
a.cc:15:1: error: '__int64' does not name a type; did you mean '__int64_t'?
15 | __int64 rec(int i, int j)
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:47:16: error: 'dp' was not declared in this scope
47 | memset(dp, -1, sizeof(dp));
| ^~
a.cc:48:17: error: 'rec' was not declared in this scope
48 | cout << rec(0, a[0]) << endl;
| ^~~
|
s205288625 | p00480 | C++ | #include<stdio.h>
#include<stdlib.h>
int* nums;
int done[21][100];
int isOK[21][100];//0ならともにダメ 1なら+のみ -1なら-のみ 2なら両方
const int true = 1;
const int false = 0;
int ans = 0;
int n;
void solve(int,int);
int main()
{
scanf("%d",&n);
nums = (int*)malloc(sizeof(int)*n);
int i,j;
for(i=0;i<n;i++)
{
scanf("%d",&nums[i]);
}
for(i=0;i<21;i++)
{
for(j=0;j<100;j++)
{
done[i][j] = false;
isOK[i][j] = 0;
}
}
solve(nums[0],1);
printf("%d",ans);
free(nums);
}
void solve(int sum,int next)
{
if(next == n-1)
{
if(done[sum][nums[next]])
{
ans += abs(isOK[sum][nums[next]]);
}
else
{
int count = 0;
int f =0;
if(sum + nums[next]<21){f=1;count++;}
if(sum - nums[next]>-1){f=-1;count++;}
if(count ==2 | count ==0)isOK[sum][nums[next]]==count;
if(count ==1){isOK[sum][nums[next]] = f;}
done[sum][nums[next]]=true;
ans += count;
}
}
else
{
if(done[sum][nums[next]])
{
switch(isOK[sum][nums[next]])
{
case 2:
solve(sum+nums[next],next+1);
solve(sum+nums[next],next+1);
break;
case 1:
solve(sum+nums[next],next+1);
break;
case -1:
solve(sum+nums[next],next+1);
break;
}
}
if(sum + nums[next]<21)
{
solve(sum+nums[next],next+1);
}
if(sum - nums[next]>-1)
{
solve(sum-nums[next],next+1);
}
}
} | a.cc:7:11: error: expected unqualified-id before 'true'
7 | const int true = 1;
| ^~~~
a.cc:8:11: error: expected unqualified-id before 'false'
8 | const int false = 0;
| ^~~~~
|
s456667759 | p00480 | C++ | #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int ban[500],a;
int ans;
__int64 x;
int dfs(int sum,int hukasa){
if(hukasa==a-1){
if(sum==ban[a-1]){
//cout<<sum;
x++;
return 1;
}
return 0;
}
int res=0;
if(sum+ban[hukasa]<=20)res+=dfs(sum+ban[hukasa],hukasa+1);
//return res;
if(sum-ban[hukasa]>=0)res+=dfs(sum-ban[hukasa],hukasa+1);
return res;
}
int main(){
cin>>a;
for(int i=0;i<a;i++)cin>>ban[i];
cout<<dfs(0,0)<<endl;
//cout<<x<<endl;
return 0;
} | a.cc:7:1: error: '__int64' does not name a type; did you mean '__int64_t'?
7 | __int64 x;
| ^~~~~~~
| __int64_t
a.cc: In function 'int dfs(int, int)':
a.cc:12:9: error: 'x' was not declared in this scope
12 | x++;
| ^
|
s470361523 | p00480 | C++ | #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int ban[500],a;
int dp[101][101]={{0},{0}};
int ans;
__int64 x;
int dfs(int sum,int hukasa){
if(dp[sum][hukasa]!=-1)return dp[sum][hukasa];
if(hukasa==a-1){
if(sum==ban[a-1]){
//cout<<sum;
x++;
return 1;
}
return 0;
}
int res=0;
if(sum+ban[hukasa]<=20){
res+=dfs(sum+ban[hukasa],hukasa+1);
} //return res;
if(sum-ban[hukasa]>=0)res+=dfs(sum-ban[hukasa],hukasa+1);
dp[sum][hukasa]=res;
return res;
}
int main(){
cin>>a;
for(int i=0;i<a;i++)cin>>ban[i];
for(int i=0;i<100;i++)for(int j=0;j<100;j++)dp[i][j]=-1;
cout<<dfs(0,0)<<endl;
//cout<<x<<endl;
return 0;
} | a.cc:8:1: error: '__int64' does not name a type; did you mean '__int64_t'?
8 | __int64 x;
| ^~~~~~~
| __int64_t
a.cc: In function 'int dfs(int, int)':
a.cc:14:9: error: 'x' was not declared in this scope
14 | x++;
| ^
|
s158859616 | p00480 | C++ | #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int ban[500],a;
unsigned __int64 dp[101][1001]={{0},{0}};
int ans;
unsigned __int64 dfs(int sum,int hukasa){
if(dp[sum][hukasa]!=-1)return dp[sum][hukasa];
if(hukasa==a-1){
if(sum==ban[a-1]){
//cout<<sum;
return 1;
}
return 0;
}
unsigned __int64 res=0;
if(sum+ban[hukasa]<=20){
res+=dfs(sum+ban[hukasa],hukasa+1);
} //return res;
if(sum-ban[hukasa]>=0)res+=dfs(sum-ban[hukasa],hukasa+1);
dp[sum][hukasa]=res;
return res;
}
int main(){
cin>>a;
for(int i=0;i<a;i++)cin>>ban[i];
for(int i=0;i<101;i++)for(int j=0;j<1001;j++)dp[i][j]=-1;
cout<<dfs(0,0)<<endl;
//cout<<x<<endl;
return 0;
} | a.cc:6:19: error: expected initializer before 'dp'
6 | unsigned __int64 dp[101][1001]={{0},{0}};
| ^~
a.cc:8:18: error: expected initializer before 'dfs'
8 | unsigned __int64 dfs(int sum,int hukasa){
| ^~~
a.cc: In function 'int main()':
a.cc:28:54: error: 'dp' was not declared in this scope
28 | for(int i=0;i<101;i++)for(int j=0;j<1001;j++)dp[i][j]=-1;
| ^~
a.cc:29:15: error: 'dfs' was not declared in this scope
29 | cout<<dfs(0,0)<<endl;
| ^~~
|
s932594153 | p00480 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long int ll;
typedef pair<int, int> P;
ll solve(int i, int j)
{
if (j < 0 || 20 < j)return 0;
if (dp[i][j] >= 0)return dp[i][j];//探索済み
if (i==n-1)
{
if (j == a[n - 1])return 1;
else return 0;
}
else
{
dp[i][j] = solve(i + 1, j + a[i]) + solve(i + 1, j - a[i]);
return dp[i][j];
}
}
int main()
{
int n, a[105];
ll dp[105][23];
int ans;
cin >> n;
REP(i, n)cin >> a[i];
REP(i, 105)REP(j, 25)dp[i][j] = -1;
ans = solve(1, a[0]);
cout << ans << endl;
return 0;
} | a.cc: In function 'll solve(int, int)':
a.cc:19:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
19 | if (dp[i][j] >= 0)return dp[i][j];//探索済み
| ^~
| dup
a.cc:20:16: error: 'n' was not declared in this scope
20 | if (i==n-1)
| ^
a.cc:22:26: error: 'a' was not declared in this scope
22 | if (j == a[n - 1])return 1;
| ^
a.cc:27:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
27 | dp[i][j] = solve(i + 1, j + a[i]) + solve(i + 1, j - a[i]);
| ^~
| dup
a.cc:27:45: error: 'a' was not declared in this scope
27 | dp[i][j] = solve(i + 1, j + a[i]) + solve(i + 1, j - a[i]);
| ^
|
s926347897 | p00480 | C++ | #include <cstdio>
using namespace std;
typedef __int64 Int;
int main(){
const int MAX_N = 100;
int N;
int a[MAX_N];
Int dp[MAX_N + 1][21];
for(int i = 0; i <= MAX_N; i++){
for(int j = 0; j <= 20; j++){
dp[i][j] = 0;
}
}
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%d", a + i);
}
dp[0][0] = 1;
for(int i = 1; i < N; i++){
for(int j = 0; j <= 20; j++){
if(j - a[i - 1] >= 0) dp[i][j] += dp[i - 1][j - a[i - 1]];
if(j + a[i - 1] <= 20) dp[i][j] += dp[i - 1][j + a[i - 1]];
}
}
printf("%I64d\n", dp[N - 1][a[N - 1]]);
return 0;
} | a.cc:4:9: error: '__int64' does not name a type; did you mean '__int64_t'?
4 | typedef __int64 Int;
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:10:9: error: 'Int' was not declared in this scope; did you mean 'int'?
10 | Int dp[MAX_N + 1][21];
| ^~~
| int
a.cc:14:25: error: 'dp' was not declared in this scope
14 | dp[i][j] = 0;
| ^~
a.cc:23:9: error: 'dp' was not declared in this scope
23 | dp[0][0] = 1;
| ^~
|
s094839226 | p00480 | C++ | #include <iostream>
#include <vector>
std::vector<int> seq_number;
int count; // count of the number
int answer;
//depth-first search
void dfs(int i, int computation){
if(i==count-2){
if(computation == seq_number.back()) ++answer;
}else{
if(computation >= 0){
dfs(i+1, computation+seq_number[i]);
dfs(i+1, computation-seq_number[i]);
}
}
}
int main(){
std::cin >> count
seq_number.resize(count);
for(int i=0; i<count; ++i){
std::cin >> seq_number[i];
}
answer = 0;
dfs(0,0);
std:: cout << answer << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:26: error: expected ';' before 'seq_number'
22 | std::cin >> count
| ^
| ;
23 | seq_number.resize(count);
| ~~~~~~~~~~
|
s822973208 | p00480 | C++ | #include <iostream>
#include <vector>
std::vector<int> seq_number;
int count; // count of the number
int answer;
//depth-first search
void dfs(int i, int computation){
if(i==count-2){
if(computation == seq_number.back()) ++answer;
}else{
if(computation >= 0){
dfs(i+1, computation+seq_number[i]);
dfs(i+1, computation-seq_number[i]);
}
}
}
int main(){
std::cin >> count
seq_number.resize(count);
for(int i=0; i<count; ++i){
std::cin >> seq_number[i];
}
answer = 0;
dfs(0,0);
std:: cout << answer << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:26: error: expected ';' before 'seq_number'
22 | std::cin >> count
| ^
| ;
23 | seq_number.resize(count);
| ~~~~~~~~~~
|
s668723690 | p00480 | C++ | #include <iostream>
#include <vector>
#include <array>
#include <iterator>
#include <algorithm>
int main(){
int num;
while(std::cin >> num){
//input
std::vector<int> factor;
for(int i = 0; i < num; ++i){
int buf;
std::cin >> buf;
factor.push_back(buf);
}
std::array<int, 21> count = {0}; //0~20
std::array<int, 21> tmp_count = {0};
int cnt_number = 0;
for(auto fct_itr = factor.begin(); fct_itr != factor.end(); ++fct_itr){
for(auto cnt_itr = count.begin(); cnt_itr != count.end(); ++cnt_itr){
if(cnt_number >= *fct_itr){
tmp_count[cnt_number - *fct_itr] += *cnt_itr;
}
if(cnt_number + *fct_itr <= 20){
tmp_count[cnt_number + *fct_itr] += *cnt_itr;
}
cnt_number++;
}
std::copy(tmp_count.begin(), tmp_count.end(), count,begin());
tmp_count = {0};
cnt_number = 0;
}
std::cout << count.front() << endl;
~factor();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:33:69: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
33 | std::copy(tmp_count.begin(), tmp_count.end(), count,begin());
| ^~~~~
| std::begin
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:114:37: note: 'std::begin' declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
| ^~~~~
a.cc:39:47: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
39 | std::cout << count.front() << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:40:24: error: no match for call to '(std::vector<int>) ()'
40 | ~factor();
| ~~~~~~^~
|
s203235375 | p00480 | C++ | #include <iostream>
#include <vector>
#include <array>
#include <iterator>
#include <algorithm>
int main(){
int num;
while(std::cin >> num){
//input
std::vector<int> factor;
for(int i = 0; i < num; ++i){
int buf;
std::cin >> buf;
factor.push_back(buf);
}
std::array<int, 21> count = {0}; //0~20
std::array<int, 21> tmp_count = {0};
int cnt_number = 0;
for(auto fct_itr = factor.begin(); fct_itr != factor.end(); ++fct_itr){
for(auto cnt_itr = count.begin(); cnt_itr != count.end(); ++cnt_itr){
if(cnt_number >= *fct_itr){
tmp_count[cnt_number - *fct_itr] += *cnt_itr;
}
if(cnt_number + *fct_itr <= 20){
tmp_count[cnt_number + *fct_itr] += *cnt_itr;
}
cnt_number++;
}
std::copy(tmp_count.begin(), tmp_count.end(), count.begin());
tmp_count = {0};
cnt_number = 0;
}
std::cout << count.front() << endl;
~factor();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:47: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
39 | std::cout << count.front() << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:40:24: error: no match for call to '(std::vector<int>) ()'
40 | ~factor();
| ~~~~~~^~
|
s907716847 | p00480 | C++ | #include <iostream>
#include <vector>
#include <array>
#include <iterator>
#include <algorithm>
int main(){
int num;
while(std::cin >> num){
//input
std::vector<int> factor;
for(int i = 0; i < num; ++i){
int buf;
std::cin >> buf;
factor.push_back(buf);
}
std::array<int, 21> count = {0}; //0~20
for(auto fct_itr = factor.begin(); fct_itr != factor.end(); ++fct_itr){
std::array<int, 21> tmp_count = {0};
int cnt_number = 0;
for(auto cnt_itr = count.begin(); cnt_itr != count.end(); ++cnt_itr){
if(cnt_number >= *fct_itr){
tmp_count[cnt_number - *fct_itr] += *cnt_itr;
}
if(cnt_number + *fct_itr <= 20){
tmp_count[cnt_number + *fct_itr] += *cnt_itr;
}
cnt_number++;
}
std::copy(tmp_count.begin(), tmp_count.end(), count.begin());
}
std::cout << count.front() << endl;
~factor();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:47: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
37 | std::cout << count.front() << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:38:24: error: no match for call to '(std::vector<int>) ()'
38 | ~factor();
| ~~~~~~^~
|
s098999604 | p00480 | C++ | #include <iostream>
#include <vector>
#include <array>
#include <iterator>
#include <algorithm>
int main(){
int num;
while(std::cin >> num){
//input
std::vector<int> factor;
for(int i = 0; i < num; ++i){
int buf;
std::cin >> buf;
factor.push_back(buf);
}
std::array<int, 21> count = {0}; //0~20
for(auto fct_itr = factor.begin(); fct_itr != factor.end(); ++fct_itr){
std::array<int, 21> tmp_count = {0};
int cnt_number = 0;
for(auto cnt_itr = count.begin(); cnt_itr != count.end(); ++cnt_itr){
if(cnt_number >= *fct_itr){
tmp_count[cnt_number - *fct_itr] += *cnt_itr;
}
if(cnt_number + *fct_itr <= 20){
tmp_count[cnt_number + *fct_itr] += *cnt_itr;
}
cnt_number++;
}
std::copy(tmp_count.begin(), tmp_count.end(), count.begin());
}
std::cout << count.front() << std::endl;
~factor();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:38:24: error: no match for call to '(std::vector<int>) ()'
38 | ~factor();
| ~~~~~~^~
|
s977845370 | p00480 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
int n; cin >> n;
ll dp[101][21];
int t[101];
memset(dp,0,sizeof(dp));
for ( int i = 1; i <= n; i++ ) cin >> t[i];
dp[1][t[1]] = 1;
for ( int i = 2; i < n; i++ ) {
for ( int j = 0; j <= 20; j++ ) {
if ( j + t[i] <= 20 ) dp[i][j+t[i]] += dp[i-1][j];
if ( j - t[i] >= 0 ) dp[i][j-t[i]] += dp[i-1][j];
}
}
cout << dp[n-1][t[n]] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:3: error: 'memset' was not declared in this scope
10 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s458486404 | p00480 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
int n; cin >> n;
ll dp[101][21];
int t[101];
memset(dp,0,sizeof(dp));
for ( int i = 1; i <= n; i++ ) cin >> t[i];
dp[1][t[1]] = 1;
for ( int i = 2; i < n; i++ ) {
for ( int j = 0; j <= 20; j++ ) {
if ( j + t[i] <= 20 ) dp[i][j+t[i]] += dp[i-1][j];
if ( j - t[i] >= 0 ) dp[i][j-t[i]] += dp[i-1][j];
}
}
cout << dp[n-1][t[n]] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:3: error: 'memset' was not declared in this scope
10 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s618940758 | p00480 | C++ | #include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main() {
int n; cin >> n;
ll dp[101][21];
int t[101];
memset(dp,0,sizeof(dp));
for ( int i = 1; i <= n; i++ ) cin >> t[i];
dp[1][t[1]] = 1;
for ( int i = 2; i < n; i++ ) {
for ( int j = 0; j <= 20; j++ ) {
if ( j + t[i] <= 20 ) dp[i][j+t[i]] += dp[i-1][j];
if ( j - t[i] >= 0 ) dp[i][j-t[i]] += dp[i-1][j];
}
}
cout << dp[n-1][t[n]] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:3: error: 'memset' was not declared in this scope
11 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #include <string>
|
s166279005 | p00480 | C++ | #include <stdio.h>
long long memo[101][21];
int data[101];
int N;
long long fanc(int flo,int num)
{
long long ret;
if(memo[flo][num]!=-1)
{
return memo[flo][num];
}
if(flo==0)
{
return fanc(flo+1,num+data[flo]);
}
if(flo==N-1)
{
return memo[flo][num];
}
if(num+data[flo]<=20)
{
ret+=fanc(flo+1,num+data[flo]);
}
if(num-data[flo]>=0)
{
ret+=fanc(flo+1,num-data[flo]);
}
return memo[flo][num]=ret;
}
int main()
{
int i,j;
scanf("%d",&N);
for(i=0;i<N;++i)scanf("%d",&data[i]);
for(i=0;i<N;++i)
{
for(j=0;j<21;++j)
{
memo[i][j]=-1;
}
}
memo[N][data[N]]=1;
if(data[0]==0){memo[]}
printf("%d\n",fanc(0,0))
} | a.cc: In function 'int main()':
a.cc:49:29: error: expected primary-expression before ']' token
49 | if(data[0]==0){memo[]}
| ^
a.cc:50:33: error: expected ';' before '}' token
50 | printf("%d\n",fanc(0,0))
| ^
| ;
51 | }
| ~
|
s591910324 | p00480 | C++ | #include<iostream>
using namespace std;
long long int k[21][101],n,num,sum;
main(){
cin>>n;
for(int i=0;i<n;i++){cin>>num[i];}
k[num[0]][0]=1;
for(int i=1;i<n-1;i++){for(int j=0;j<21;j++){
if(j+num[i]<21){k[j+num[i]][i]+=k[j][i-1];}
if(j-num[i]>=0){k[j-num[i]][i] += k[j][i-1];}
}}
sum=k[num[n-1]][n-2];
cout<<sum<<endl;} | a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:6:30: error: invalid types 'long long int[int]' for array subscript
6 | for(int i=0;i<n;i++){cin>>num[i];}
| ^
a.cc:7:6: error: invalid types 'long long int[int]' for array subscript
7 | k[num[0]][0]=1;
| ^
a.cc:9:9: error: invalid types 'long long int[int]' for array subscript
9 | if(j+num[i]<21){k[j+num[i]][i]+=k[j][i-1];}
| ^
a.cc:9:24: error: invalid types 'long long int[int]' for array subscript
9 | if(j+num[i]<21){k[j+num[i]][i]+=k[j][i-1];}
| ^
a.cc:10:9: error: invalid types 'long long int[int]' for array subscript
10 | if(j-num[i]>=0){k[j-num[i]][i] += k[j][i-1];}
| ^
a.cc:10:24: error: invalid types 'long long int[int]' for array subscript
10 | if(j-num[i]>=0){k[j-num[i]][i] += k[j][i-1];}
| ^
a.cc:12:10: error: invalid types 'long long int[long long int]' for array subscript
12 | sum=k[num[n-1]][n-2];
| ^
|
s468849627 | p00480 | C++ | #include<iostream>
using namespace std;
long long int k[21][101],n,q[100],sum;
main(){cin>>n;
for(int i=0;i<n;i++){cin>>q[i];}
k[num[0]][0]=1;
for(int i=1;i<n-1;i++){for(int j=0;j<21;j++){
if(j+num[i]<21){k[j+q[i]][i]+=k[j][i-1];}
if(j-num[i]>=0){k[j-q[i]][i]+=k[j][i-1];}
}}
cout<<k[q[n-1]][n-2]<<endl;} | a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){cin>>n;
| ^~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'num' was not declared in this scope; did you mean 'sum'?
6 | k[num[0]][0]=1;
| ^~~
| sum
|
s502515512 | p00480 | C++ | #include <iostream>
#define int long long
using namespace std;
int a[101];
int n;
int memo[101][21];
int fanc(int lo,int sum)
{
if (sum < 0 || 20 < sum){ return 0; }
if (lo == n - 1){ return (a[lo] == sum); }
if (memo[lo][sum] != -1)
{
return memo[lo][sum];
}
else
{
return memo[lo][sum] = fanc(lo + 1, sum + a[lo]) + fanc(lo + 1, sum - a[lo]);
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
memset(memo,-1,sizeof(memo));
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
cout << fanc(0,0) << "\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:33:9: error: 'memset' was not declared in this scope
33 | memset(memo,-1,sizeof(memo));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #define int long long
|
s477745854 | p00480 | C++ | #include <iostream>
using namespace std;
int n;
int x[100];
long long int dp[101][21];
int main()
{
cin >> n;
for(int i = 0; i < n; i++){
cin >> x[i];
}
for(int i = 0; i <= n; i++){
for(int j = 0; j <= 20; j++){
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for(int i = 1; i < n; i++){
for(int j = 0; j <= 20; j++){
int minus = j - x[i-1];
int plus = j + x[i-1];
if (minus >= 0){
dp[i][j] += dp[i-1][minus];
}
if (plus <= 20){
dp[i][j] += dp[i-1][plus];
}
}
}
cout << dp[n - 1][x[n - 1]] << endl;
return 0;
}
} | a.cc:38:1: error: expected declaration before '}' token
38 | }
| ^
|
s887605770 | p00480 | C++ | #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }
int n, s[100], ans;
__int64 dp[100][1000];
__int64 func(int a, int sum) {
if (a == n-1)
return sum == ans ? 1 : 0;
__int64 cnt = 0;
if (sum - s[a + 1] >= 0) {
if (!dp[a + 1][sum - s[a + 1]]) {
dp[a + 1][sum - s[a + 1]] = func(a + 1, sum - s[a + 1]);
}
cnt += dp[a + 1][sum - s[a + 1]];
}
if (sum + s[a + 1] <= 20) {
if (!dp[a + 1][sum + s[a + 1]]) {
dp[a + 1][sum + s[a + 1]] = func(a + 1, sum + s[a + 1]);
}
cnt += dp[a + 1][sum + s[a + 1]];
}
return cnt;
}
int main() {
scanf("%d", &n);
n--;
for (int i = 0; n > i; i++) {
scanf("%d", &s[i]);
}
scanf("%d", &ans);
printf("%lld\n", func(0, s[0]));
return 0;
} | a.cc:9:1: error: '__int64' does not name a type; did you mean '__int64_t'?
9 | __int64 dp[100][1000];
| ^~~~~~~
| __int64_t
a.cc:11:1: error: '__int64' does not name a type; did you mean '__int64_t'?
11 | __int64 func(int a, int sum) {
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:37:26: error: 'func' was not declared in this scope
37 | printf("%lld\n", func(0, s[0]));
| ^~~~
|
s501593367 | p00480 | C++ | #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
int compare_int(const void* a, const void* b) { return *(int*) a - *(int*) b; }
int n, s[100], ans;
__int64 dp[100][1000];
__int64 func(int a, int sum) {
if (a == n-1)
return sum == ans ? 1 : 0;
__int64 cnt = 0;
if (sum - s[a + 1] >= 0) {
if (!dp[a + 1][sum - s[a + 1]]) {
dp[a + 1][sum - s[a + 1]] = func(a + 1, sum - s[a + 1]);
}
cnt += dp[a + 1][sum - s[a + 1]];
}
if (sum + s[a + 1] <= 20) {
if (!dp[a + 1][sum + s[a + 1]]) {
dp[a + 1][sum + s[a + 1]] = func(a + 1, sum + s[a + 1]);
}
cnt += dp[a + 1][sum + s[a + 1]];
}
return cnt;
}
int main() {
scanf("%d", &n);
n--;
for (int i = 0; n > i; i++) {
scanf("%d", &s[i]);
}
scanf("%d", &ans);
printf("%lld\n", func(0, s[0]));
return 0;
} | a.cc:9:1: error: '__int64' does not name a type; did you mean '__int64_t'?
9 | __int64 dp[100][1000];
| ^~~~~~~
| __int64_t
a.cc:11:1: error: '__int64' does not name a type; did you mean '__int64_t'?
11 | __int64 func(int a, int sum) {
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:37:26: error: 'func' was not declared in this scope
37 | printf("%lld\n", func(0, s[0]));
| ^~~~
|
s403749192 | p00480 | C++ | #include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
int main(void) {
int n, a[100] = {0};
LL dp[100][21] = {0};
cin >> n;
REP(i, n) scanf("%d", &a[i]);
dp[n-1][a[n-1]] = 1;
for (int i = n - 2; i >= 0; --i) {
for (int j = 0; j <= 20; ++j) {
if (j + a[i] <= 20) dp[i][j] += dp[i+1][j+a[i]];
if (j - a[i] >= 0) dp[i][j] += dp[i+1][j-a[i]];
}
}
cout << dp[0][0] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:13: error: 'i' was not declared in this scope
12 | REP(i, n) scanf("%d", &a[i]);
| ^
a.cc:12:9: error: 'REP' was not declared in this scope
12 | REP(i, n) scanf("%d", &a[i]);
| ^~~
|
s443051573 | p00480 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
int main(){
int n,number,start,plus,minus;
while(std::cin >> n){
std::vector<int> numbers;
for(int i=0; i<n; ++i){
std::cin >> number;
numbers.push_back(number);
}
int whole = (int)pow(2.0,(double)(n-2));
std::vector<int> process;
std::vector<int> exception(whole, 0);
for(int j=0; j<n-1; ++j){
if(j == 0){ //first step
process.push_back(numbers.at(j));
}else{
start = (int)pow(2.0,(double)(j-1));
for(int k=0; k<start; ++k){
plus = process.at(start-1+k)+numbers.at(j);
minus = process.at(start-1+k)-numbers.at(j);
if(plus > 20 || plus < 0){
process.push_back(plus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
process.push_back(minus);
}else if(minus > 20 || minus < 0){
process.push_back(plus);
process.push_back(minus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
}else{
process.push_back(plus);
process.push_back(minus);
}
}
}
}
int size = (int)process.size();
int sum = 0;
int j = 0;
for(int i=size-whole; i<size; ++i){
if(process.at(i) == numbers.back() && exception.at(j) != 1){
++sum;
}
++j;
}
std::cout << sum << std::endl;
} | a.cc: In function 'int main()':
a.cc:74:10: error: expected '}' at end of input
74 | }
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s934760239 | p00480 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
int main(){
int n,number,start,plus,minus;
while(std::cin >> n){
std::vector<int> numbers;
for(int i=0; i<n; ++i){
std::cin >> number;
numbers.push_back(number);
}
int whole = (int)pow(2.0,(double)(n-2));
std::vector<int> process;
std::vector<int> exception(whole, 0);
for(int j=0; j<n-1; ++j){
if(j == 0){ //first step
process.push_back(numbers.at(j));
}else{
start = (int)pow(2.0,(double)(j-1));
for(int k=0; k<start; ++k){
plus = process.at(start-1+k)+numbers.at(j);
minus = process.at(start-1+k)-numbers.at(j);
if(plus > 20 || plus < 0){
process.push_back(plus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
process.push_back(minus);
}else if(minus > 20 || minus < 0){
process.push_back(plus);
process.push_back(minus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
}else{
process.push_back(plus);
process.push_back(minus);
}
}
}
}
int size = (int)process.size();
unsigned_int64 sum = 0;
int j = 0;
for(int i=size-whole; i<size; ++i){
if(process.at(i) == numbers.back() && exception.at(j) != 1){
++sum;
}
++j;
}
std::cout << sum << std::endl;
}
} | a.cc: In function 'int main()':
a.cc:63:17: error: 'unsigned_int64' was not declared in this scope
63 | unsigned_int64 sum = 0;
| ^~~~~~~~~~~~~~
a.cc:68:35: error: 'sum' was not declared in this scope
68 | ++sum;
| ^~~
a.cc:73:30: error: 'sum' was not declared in this scope
73 | std::cout << sum << std::endl;
| ^~~
|
s329746068 | p00480 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
int main(){
int n,number,start,plus,minus;
while(std::cin >> n){
std::vector<int> numbers;
for(int i=0; i<n; ++i){
std::cin >> number;
numbers.push_back(number);
}
int whole = (int)pow(2.0,(double)(n-2));
std::vector<int> process;
std::vector<int> exception(whole, 0);
for(int j=0; j<n-1; ++j){
if(j == 0){ //first step
process.push_back(numbers.at(j));
}else{
start = (int)pow(2.0,(double)(j-1));
for(int k=0; k<start; ++k){
plus = process.at(start-1+k)+numbers.at(j);
minus = process.at(start-1+k)-numbers.at(j);
if(plus > 20 || plus < 0){
process.push_back(plus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
process.push_back(minus);
}else if(minus > 20 || minus < 0){
process.push_back(plus);
process.push_back(minus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
}else{
process.push_back(plus);
process.push_back(minus);
}
}
}
}
int size = (int)process.size();
unsigned_int64 sum = 0;
int j = 0;
for(int i=size-whole; i<size; ++i){
if(process.at(i) == numbers.back() && exception.at(j) != 1){
++sum;
}
++j;
}
std::cout << sum << std::endl;
}
} | a.cc: In function 'int main()':
a.cc:63:17: error: 'unsigned_int64' was not declared in this scope
63 | unsigned_int64 sum = 0;
| ^~~~~~~~~~~~~~
a.cc:68:35: error: 'sum' was not declared in this scope
68 | ++sum;
| ^~~
a.cc:73:30: error: 'sum' was not declared in this scope
73 | std::cout << sum << std::endl;
| ^~~
|
s099432681 | p00480 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
int main(){
int n,number,start,plus,minus;
while(std::cin >> n){
std::vector<int> numbers;
for(int i=0; i<n; ++i){
std::cin >> number;
numbers.push_back(number);
}
int whole = (int)pow(2.0,(double)(n-2));
std::vector<int> process;
std::vector<int> exception(whole, 0);
for(int j=0; j<n-1; ++j){
if(j == 0){ //first step
process.push_back(numbers.at(j));
}else{
start = (int)pow(2.0,(double)(j-1));
for(int k=0; k<start; ++k){
plus = process.at(start-1+k)+numbers.at(j);
minus = process.at(start-1+k)-numbers.at(j);
if(plus > 20 || plus < 0){
process.push_back(plus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
process.push_back(minus);
}else if(minus > 20 || minus < 0){
process.push_back(plus);
process.push_back(minus);
for(int l=(int)process.size()*pow(2.0,(double)(n-1-(j+1))); l<(int)process.size()*pow(2.0,(double)(n-1-(j+1)))+pow(2.0,(double)(n-1-(j+1))); ++l){
exception.at(l-whole) = 1;
}
}else{
process.push_back(plus);
process.push_back(minus);
}
}
}
}
int size = (int)process.size();
unsigned_int64 sum = 0;
int j = 0;
for(int i=size-whole; i<size; ++i){
if(process.at(i) == numbers.back() && exception.at(j) != 1){
++sum;
}
++j;
}
std::cout << sum << std::endl;
}
} | a.cc: In function 'int main()':
a.cc:63:17: error: 'unsigned_int64' was not declared in this scope
63 | unsigned_int64 sum = 0;
| ^~~~~~~~~~~~~~
a.cc:68:35: error: 'sum' was not declared in this scope
68 | ++sum;
| ^~~
a.cc:73:30: error: 'sum' was not declared in this scope
73 | std::cout << sum << std::endl;
| ^~~
|
s968524775 | p00480 | C++ | #include <iostream>
using namespace std;
#define N 101
int main()
{
int n, ans;
int arr[N];
__int64 table[N][21];
cin >> n;
for(int i = 0; i < n - 1; i++) cin >> arr[i];
for(int i = 0; i < n - 1; i++) {
for(int j = 0; j < 21; j++) table[i][j] = 0;
}
cin >> ans;
table[0][arr[0]] = 1;
for(int i = 1; i < n - 1; i++) {
for(int j = 0; j < 21; j++) {
if(table[i - 1][j] >= 1) {
if(j - arr[i] >= 0) {
table[i][j - arr[i]] += table[i - 1][j];
}
if(j + arr[i] <= 20) {
table[i][j + arr[i]] += table[i - 1][j];
}
}
}
}
cout << table[n - 2][ans] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
11 | __int64 table[N][21];
| ^~~~~~~
| __int64_t
a.cc:17:45: error: 'table' was not declared in this scope; did you mean 'mutable'?
17 | for(int j = 0; j < 21; j++) table[i][j] = 0;
| ^~~~~
| mutable
a.cc:22:9: error: 'table' was not declared in this scope; did you mean 'mutable'?
22 | table[0][arr[0]] = 1;
| ^~~~~
| mutable
|
s478688593 | p00480 | C++ | while True:
N = int(input())
if N == 0:
break
a = list(map(int, input().split()))
## dp[i][j]: i???????????°????????§??§j????????????????????°
dp = [[0 for j in range(21)] for i in range(N-1)]
dp[0][a[0]] = 1
for i in range(1, N-1):
for j in range(21):
if (j - a[i]) in range(21):
dp[i][j] += dp[i-1][j-a[i]]
if (j + a[i]) in range(21):
dp[i][j] += dp[i-1][j+a[i]]
print(dp[N-2][a[N-1]]) | a.cc:7:5: error: stray '##' in program
7 | ## dp[i][j]: i???????????°????????§??§j????????????????????°
| ^~
a.cc:7:30: error: extended character ° is not valid in an identifier
7 | ## dp[i][j]: i???????????°????????§??§j????????????????????°
| ^
a.cc:7:39: error: extended character § is not valid in an identifier
7 | ## dp[i][j]: i???????????°????????§??§j????????????????????°
| ^
a.cc:7:42: error: extended character § is not valid in an identifier
7 | ## dp[i][j]: i???????????°????????§??§j????????????????????°
| ^
a.cc:7:64: error: extended character ° is not valid in an identifier
7 | ## dp[i][j]: i???????????°????????§??§j????????????????????°
| ^
a.cc:1:1: error: expected unqualified-id before 'while'
1 | while True:
| ^~~~~
|
s782358189 | p00480 | C++ | n = int(input())
a = list(map(int, input().split()))
dp = [[0] * 21 for i in range(n)]
dp[0][0] = 1
for i in range(n - 1):
for j in range(21):
if dp[i][j] == 0:
continue
if 0 <= j + a[i] <= 20:
dp[i + 1][j + a[i]] += dp[i][j]
if 0 <= j - a[i] <= 20:
dp[i + 1][j - a[i]] += dp[i][j]
print(dp[n - 1][a[n - 1]]) | a.cc:1:1: error: 'n' does not name a type
1 | n = int(input())
| ^
|
s928321151 | p00480 | C++ | #include <vector>
#include <sstream>
#include <deque>
std::vector<std::vector<long int> > table;
void outtable(std::vector<std::vector<int> > t){
for(int i = 0; i < t.size(); ++i){
for(int j = 0; j < t[i].size(); ++j){
std::cout << t[i][j] << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
int calc(std::deque<int> num, int input_data_num){
for(int i = 0; i < input_data_num - 1; ++i){
for(int j = 0; j < 21; ++j){
if(table[i][j] != 0){
//std::cout << i << " " << j << std::endl;
if(j + num.front() <= 20){
table[i+1][j + num.front()] += table[i][j];
}
if(j - num.front() >= 0){
table[i+1][j - num.front()] += table[i][j];
}
//outtable(table);
}
}
num.pop_front();
}
}
int main(){
std::deque<int> num;
int input_data;
int input_data_num;
std::string str;
std::cin >> input_data_num;
std::cin.ignore();
std::getline(std::cin, str);
std::istringstream iss(str);
while(!iss.eof()){
iss >> input_data;
num.push_back(input_data);
}
table = std::vector<std::vector<int> >(input_data_num, std::vector<int>(21, 0));
++table[0][num.front()];
//outtable(table);
num.pop_front();
calc(num, input_data_num);
//outtable(table);
std::cout << table[input_data_num-1][0] << std::endl;
return 0;
} | a.cc: In function 'void outtable(std::vector<std::vector<int> >)':
a.cc:10:18: error: 'cout' is not a member of 'std'
10 | std::cout << t[i][j] << " ";
| ^~~~
a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
3 | #include <deque>
+++ |+#include <iostream>
4 |
a.cc:12:14: error: 'cout' is not a member of 'std'
12 | std::cout << std::endl;
| ^~~~
a.cc:12:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:14:10: error: 'cout' is not a member of 'std'
14 | std::cout << std::endl;
| ^~~~
a.cc:14:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc: In function 'int calc(std::deque<int>, int)':
a.cc:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
33 | }
| ^
a.cc: In function 'int main()':
a.cc:42:10: error: 'cin' is not a member of 'std'
42 | std::cin >> input_data_num;
| ^~~
a.cc:42:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:10: error: 'cin' is not a member of 'std'
43 | std::cin.ignore();
| ^~~
a.cc:43:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:45:23: error: 'cin' is not a member of 'std'
45 | std::getline(std::cin, str);
| ^~~
a.cc:45:23: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:52:83: error: no match for 'operator=' (operand types are 'std::vector<std::vector<long int> >' and 'std::vector<std::vector<int> >')
52 | table = std::vector<std::vector<int> >(input_data_num, std::vector<int>(21, 0));
| ^
In file included from /usr/include/c++/14/vector:72,
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 = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::vector<std::vector<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 = std::vector<long int>; _Alloc = std::allocator<std::vector<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 'std::vector<std::vector<int> >' to 'std::vector<std::vector<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 = std::vector<long int>; _Alloc = std::allocator<std::vector<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 'std::vector<std::vector<int> >' to 'std::initializer_list<std::vector<long int> >'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:63:10: error: 'cout' is not a member of 'std'
63 | std::cout << table[input_data_num-1][0] << std::endl;
| ^~~~
a.cc:63:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s344012065 | p00480 | C++ | #include <iostream>
#include <vector>
#include <sstream>
#include <deque>
std::vector<std::vector<long int> > table;
void outtable(std::vector<std::vector<long int> > t){
for(int i = 0; i < t.size(); ++i){
for(int j = 0; j < t[i].size(); ++j){
std::cout << t[i][j] << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
int calc(std::deque<int> num, int input_data_num){
for(int i = 0; i < input_data_num - 1; ++i){
for(int j = 0; j < 21; ++j){
if(table[i][j] != 0){
//std::cout << i << " " << j << std::endl;
if(j + num.front() <= 20){
table[i+1][j + num.front()] += table[i][j];
}
if(j - num.front() >= 0){
table[i+1][j - num.front()] += table[i][j];
}
//outtable(table);
}
}
num.pop_front();
}
}
int main(){
std::deque<int> num;
int input_data;
int input_data_num;
std::string str;
std::cin >> input_data_num;
std::cin.ignore();
std::getline(std::cin, str);
std::istringstream iss(str);
while(!iss.eof()){
iss >> input_data;
num.push_back(input_data);
}
table = std::vector<std::vector<long int> >(input_data_num, std::vector<int>(21, 0));
++table[0][num.front()];
//outtable(table);
num.pop_front();
calc(num, input_data_num);
outtable(table);
std::cout << table[input_data_num-1][0] << std::endl;
return 0;
} | a.cc: In function 'int calc(std::deque<int>, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
34 | }
| ^
a.cc: In function 'int main()':
a.cc:53:88: error: no matching function for call to 'std::vector<std::vector<long int> >::vector(int&, std::vector<int>)'
53 | table = std::vector<std::vector<long int> >(input_data_num, std::vector<int>(21, 0));
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >]'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed:
a.cc:53:88: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
53 | table = std::vector<std::vector<long int> >(input_data_num, std::vector<int>(21, 0));
| ^
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; allocator_type = std::allocator<std::vector<long int> >]'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<long int> >'
678 | vector(initializer_list<value_type> __l,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<long int> >]'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<long int> >&&'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; allocator_type = std::allocator<std::vector<long int> >; std::false_type = std::false_type]'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; allocator_type = std::allocator<std::vector<long int> >; std::true_type = std::true_type]'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<long int> >]'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<long int> >&'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >]'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >]'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; size_type = long unsigned int; value_type = std::vector<long int>; allocator_type = std::allocator<std::vector<long int> >]'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<long int> >::value_type&' {aka 'const std::vector<long int>&'}
569 | vector(size_type __n, const value_type& __value,
| ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<long int> >]'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<long int> >::allocator_type&' {aka 'const std::allocator<std::vector<long int> >&'}
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; allocator_type = std::allocator<std::vector<long int> >]'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >]'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
|
s482710276 | p00480 | C++ | #include <iostream>
using namespace std;
void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
{
int plas = total + num[current + 1];
if ((current + 1) == max && plas == ans)
{
(*count)++;
}
if (current != max) {
if (plas < 20 && plas >= 0)
{
Recurrent(count, num, current + 1, plas, max, ans);
}
}
int mainas = total - num[current + 1];
if ((current + 1) == max && mainas == ans)
{
(*count)++;
}
if (current != max)
{
if (mainas < 20 && mainas >= 0)
{
Recurrent(count, num, current + 1, mainas, max, ans);
}
}
}
int main()
{
int n;
cin >> n;
int* num = new int[n];
for (int i = 0; i < n; i++)
{
cin >> num[i];
}
__int64 count = 0;
Recurrent(&count, num, 0, num[0], n - 2, num[n - 1]);
cout << count << endl;
return 0;
} | a.cc:5:6: error: variable or field 'Recurrent' declared void
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~~~~~~~
a.cc:5:16: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~~~~~
| __int64_t
a.cc:5:25: error: 'count' was not declared in this scope
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~~~
a.cc:5:32: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:42: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:55: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:66: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:75: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc: In function 'int main()':
a.cc:42:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
42 | __int64 count = 0;
| ^~~~~~~
| __int64_t
a.cc:43:20: error: 'count' was not declared in this scope
43 | Recurrent(&count, num, 0, num[0], n - 2, num[n - 1]);
| ^~~~~
a.cc:43:9: error: 'Recurrent' was not declared in this scope
43 | Recurrent(&count, num, 0, num[0], n - 2, num[n - 1]);
| ^~~~~~~~~
|
s038236408 | p00480 | C++ | #include <iostream>
using namespace std;
void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
{
int plas = total + num[current + 1];
if ((current + 1) == max && plas == ans)
{
(*count)++;
}
if (current != max) {
if (plas < 20 && plas >= 0)
{
Recurrent(count, num, current + 1, plas, max, ans);
}
}
int mainas = total - num[current + 1];
if ((current + 1) == max && mainas == ans)
{
(*count)++;
}
if (current != max)
{
if (mainas < 20 && mainas >= 0)
{
Recurrent(count, num, current + 1, mainas, max, ans);
}
}
}
int main()
{
int n;
cin >> n;
int* num = new int[n];
for (int i = 0; i < n; i++)
{
cin >> num[i];
}
__int64 count = 0;
Recurrent(&count, num, 0, num[0], n - 2, num[n - 1]);
cout << count << endl;
return 0;
} | a.cc:5:6: error: variable or field 'Recurrent' declared void
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~~~~~~~
a.cc:5:16: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~~~~~
| __int64_t
a.cc:5:25: error: 'count' was not declared in this scope
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~~~
a.cc:5:32: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:42: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:55: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:66: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc:5:75: error: expected primary-expression before 'int'
5 | void Recurrent(__int64 *count, int *num, int current, int total, int max, int ans)
| ^~~
a.cc: In function 'int main()':
a.cc:42:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
42 | __int64 count = 0;
| ^~~~~~~
| __int64_t
a.cc:43:20: error: 'count' was not declared in this scope
43 | Recurrent(&count, num, 0, num[0], n - 2, num[n - 1]);
| ^~~~~
a.cc:43:9: error: 'Recurrent' was not declared in this scope
43 | Recurrent(&count, num, 0, num[0], n - 2, num[n - 1]);
| ^~~~~~~~~
|
s509523731 | p00480 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
using ll=long long;
int main(){
int n; cin>>n;
int num[101];
ll dp[101][21]={};
for(int i=1; i<=n; i++){
cin>>num[i];
}
dp[1][num[1]]=1;
for(int i=2; i<n; i++){
for(int j=0; j<=20; j++){
if(num[i]<=j)dp[i][j]+=dp[i-1][j-num[i]];
if(num[i]+j<=20)dp[i][j]+=dp[i-1][j+num[i]];
}
}
cout<<dp[n-1][num[n]]<<endl;
return 0; | a.cc: In function 'int main()':
a.cc:33:14: error: expected '}' at end of input
33 | return 0;
| ^
a.cc:16:11: note: to match this '{'
16 | int main(){
| ^
|
s199342003 | p00480 | C++ | #include <iostream>
using namespace std;
int n;
int a[105];
long long memo[105][22];
long long solve(int i, int j) {
long long result = 0;
if (memo[i][j] != -1) {
return memo[i][j];
}
if (i == 0) {
result = j == a[0] ? 1 : 0;
} else {
if (j + a[i] <= 20) {
result += solve(i - 1, j + a[i]);
}
if (j - a[i] >= 0) {
result += solve(i - 1, j - a[i]);
}
}
memo[i][j] = result;
return result;
}
int main() {
memset(memo, -1, sizeof(memo));
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << solve(n - 2, a[n - 1]) << endl;
} | a.cc: In function 'int main()':
a.cc:29:5: error: 'memset' was not declared in this scope
29 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 |
|
s358031132 | p00480 | C++ | #include <bits/stdc++.h>
using namespace std;
int N;
int num[102];
__int64 a[102][21];
__int64 dp(int d,int sum){
if(sum > 20 || sum < 0) return 0;
if(a[d][sum] >= 0) return a[d][sum];
if(d == N-1){
if(sum == num[N]){
return a[d][sum] = 1;
}else{
return a[d][sum] = 0;
}
}
__int64 b = 0;
int n = num[d+1];
b += dp(d+1 , sum + n) + dp(d+1 , sum - n);
return a[d][sum] = b;
}
int main(){
fill_n(num,101,0);
fill_n(*a,101*21,-1);
cin >>N;
for(int i = 1;i <= N;i++){
cin >> num[i];
}
cout << dp(0,0) << endl;
} | a.cc:7:1: error: '__int64' does not name a type; did you mean '__int64_t'?
7 | __int64 a[102][21];
| ^~~~~~~
| __int64_t
a.cc:9:1: error: '__int64' does not name a type; did you mean '__int64_t'?
9 | __int64 dp(int d,int sum){
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:30:13: error: 'a' was not declared in this scope
30 | fill_n(*a,101*21,-1);
| ^
a.cc:37:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
37 | cout << dp(0,0) << endl;
| ^~
| dup
|
s892721218 | p00480 | C++ | #include <bits/stdc++.h>
using namespace std;
int N;
int num[102];
long long int a[102][22];
long long int dp(int d,int sum){
if(sum > 20 || sum < 0) return 0;
if(a[d][sum] >= 0) return a[d][sum];
if(d == N-1){
if(sum == num[N]){
return a[d][sum] = 1;
}else{
return a[d][sum] = 0;
}
}
long long int b = 0;
int n = num[d+1];
if(d ==0){
b += dp(d+1 , sum + n)
}else{
b += dp(d+1 , sum + n) + dp(d+1 , sum - n);
return a[d][sum] = b;
}
}
int main(){
fill_n(num,101,0);
fill_n(*a,101*22,-1);
cin >>N;
for(int i = 1;i <= N;i++){
cin >> num[i];
}
cout << dp(0,0) << endl;
} | a.cc: In function 'long long int dp(int, int)':
a.cc:25:31: error: expected ';' before '}' token
25 | b += dp(d+1 , sum + n)
| ^
| ;
26 | }else{
| ~
a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
30 | }
| ^
|
s454215768 | p00480 | C++ | ???????????????????????????????????????????????????
??????????????????????????????????????????????????????
?????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
?????????????????????????????????????????????][?????????????????????????????????????????????
?????????????????????????????????
????????????????????????????????????????????????
?????????????????????
??????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????
?????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????
??????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????p?????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???
???
???
?????????????????????????????????????????????????????????????????????????????????
???????????????????????????
??? | a.cc:1:1: error: expected unqualified-id before '?' token
1 | ???????????????????????????????????????????????????
| ^
|
s130049832 | p00480 | C++ | #include<stdio.h>
int main(void) {
longlong kaz[101][21] = { 0 };
int n,su[101];
int i,j;
scanf("%d", &n);
for (i = 0;i < n;i++) {
scanf("%d", &su[i]);
}
kaz[0][su[0]]++;
for (i = 1;i < n - 1;i++) {
for (j = 0;j < 21;j++) {
if (kaz[i-1][j] >= 1) {
if (j + su[i] < 21) {
kaz[i][j + su[i]] += kaz[i - 1][j];
}
if (j - su[i] >= 0) {
kaz[i][j - su[i]] += kaz[i - 1][j];
}
}
}
}
printf("%lld\n", kaz[n - 2][su[n - 1]]);
for (i = 0;i < n;i++) {
for (j = 0;j < 21;j++) {
printf("%lld", kaz[i][j]);
}
printf("\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:3:9: error: 'longlong' was not declared in this scope
3 | longlong kaz[101][21] = { 0 };
| ^~~~~~~~
a.cc:10:9: error: 'kaz' was not declared in this scope
10 | kaz[0][su[0]]++;
| ^~~
|
s701213272 | p00480 | C++ | #include<stdio.h>
int main(void) {
longlong kaz[101][21] = { 0 };
int n,su[101];
int i,j;
scanf("%d", &n);
for (i = 0;i < n;i++) {
scanf("%d", &su[i]);
}
kaz[0][su[0]]++;
for (i = 1;i < n - 1;i++) {
for (j = 0;j < 21;j++) {
if (kaz[i-1][j] >= 1) {
if (j + su[i] < 21) {
kaz[i][j + su[i]] += kaz[i - 1][j];
}
if (j - su[i] >= 0) {
kaz[i][j - su[i]] += kaz[i - 1][j];
}
}
}
}
printf("%lld\n", kaz[n - 2][su[n - 1]]);
for (i = 0;i < n;i++) {
for (j = 0;j < 21;j++) {
printf("%lld", kaz[i][j]);
}
printf("\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:3:9: error: 'longlong' was not declared in this scope
3 | longlong kaz[101][21] = { 0 };
| ^~~~~~~~
a.cc:10:9: error: 'kaz' was not declared in this scope
10 | kaz[0][su[0]]++;
| ^~~
|
s684522165 | p00480 | C++ | #include <iostream>
using namespace std;
int main(void)
{
int a,b,c,d[100]={0},e,f;
long long D[100][21]={0};
cin>>a;
int Z=0;
for (b=0;b<a;b++)
{
cin>>c;
d[b]=c;
if (b==0)
{
D[b][c]=1;
}
else
{
for (e=0;e<21;e++)
{
if (D[b-1][e]>0)
{
f=e-c;
if (f>=0)
{
D[b][f]+=D[b-1][e];
}
f=e+c;
if (f<=20)
{
D[b][f]+=D[b-1][e];
}
}
}
}
}
cout<<endl;
}
cout<<D[a-2][d[a-1]]<<endl;
return 0;
}
| a.cc:42:9: error: 'cout' does not name a type
42 | cout<<D[a-2][d[a-1]]<<endl;
| ^~~~
a.cc:43:9: error: expected unqualified-id before 'return'
43 | return 0;
| ^~~~~~
a.cc:44:1: error: expected declaration before '}' token
44 | }
| ^
|
s326343851 | p00480 | C++ | #include<bits/stdc++.h>
using namespace std;
long long int dp[200][200],a,su[200];
int main(){
cin>>a;
for(int i=0;i<a;i++){cin>>su[i];}???
dp[su[0]][0]=1;
for(int i=0;i<a-1;i++){
for(int j=0;j<21;j++){
if(dp[j][i]!=0){
if(j+su[i+1]>20){}else{ dp[j+su[i+1]][i+1]+=dp[j][i]; }
if(j-su[i+1]<0){}else{ dp[j-su[i+1]][i+1]+=dp[j][i]; }
}
}
}
cout<<dp[su[a-1]][a-2]<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:6:38: error: expected primary-expression before '?' token
6 | for(int i=0;i<a;i++){cin>>su[i];}???
| ^
a.cc:6:39: error: expected primary-expression before '?' token
6 | for(int i=0;i<a;i++){cin>>su[i];}???
| ^
a.cc:6:40: error: expected primary-expression before '?' token
6 | for(int i=0;i<a;i++){cin>>su[i];}???
| ^
a.cc:7:19: error: expected ':' before ';' token
7 | dp[su[0]][0]=1;
| ^
| :
a.cc:7:19: error: expected primary-expression before ';' token
a.cc:7:19: error: expected ':' before ';' token
7 | dp[su[0]][0]=1;
| ^
| :
a.cc:7:19: error: expected primary-expression before ';' token
a.cc:7:19: error: expected ':' before ';' token
7 | dp[su[0]][0]=1;
| ^
| :
a.cc:7:19: error: expected primary-expression before ';' token
|
s344276219 | p00480 | C++ | #include <iostream>
using namespace std;
int main(){
long long dp[105][21];
int n,begin,ans,k;
cin>>n;
cin>>begin;
memset(dp, 0, sizeof(dp));
dp[0][begin]=1;
for(int i=1; i<n-1; i++){
cin>>k;
for(int j=0; j<21; j++){
if(j+k<=20) dp[i][j+k]+=dp[i-1][j];
if(j-k>=0) dp[i][j-k]+=dp[i-1][j];
}
}
cin>>ans;
cout<<dp[n-2][ans]<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:5: error: 'memset' was not declared in this scope
9 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s795641860 | p00480 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main(){
long long dp[105][21];
int n,begin,ans,k;
cin>>n;
cin>>begin;
memset(dp, 0, sizeof(dp));
dp[0][begin]=1;
for(int i=1; i<n-1; i++){
cin>>k;
for(int j=0; j<21; j++){
if(j+k<=20) dp[i][j+k]+=dp[i-1][j];
if(j-k>=0) dp[i][j-k]+=dp[i-1][j];
}
}
cin>>ans;
cout<<dp[n-2][ans]<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:5: error: 'memset' was not declared in this scope
10 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s769292552 | p00480 | C++ | #include<iostream>
#include<algorithm>
long long int dp[100000][30] = {0};
using namespace std;
int main(){
int n;
scanf("%d",&n);
int a[10000]={0};
for(int i = 0;i < n; i++)scanf("%d",&a[i]);
memset(dp,0,sizeof(dp));
dp[0][a[0]] = 1;
int v = 0;
for(int i = 1;i < n-1; i++){
for(int j = 0;j <= 20; j++){
if(dp[i-1][j] > 0){
v = j + a[i];
if(v <= 20){
dp[i][v] += dp[i-1][j];
}
v = j-a[i];
if(v >= 0){
dp[i][v] += dp[i-1][j];
}
}
}
}
printf("%lld\n",dp[n-2][a[n-1]]);
return 0;
} | a.cc: In function 'int main()':
a.cc:12:5: error: 'memset' was not declared in this scope
12 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | long long int dp[100000][30] = {0};
|
s447828842 | p00480 | C++ | #include <iostream>
#include <vector>
unsigned long int count=0;
int answer=0;
std::vector<int> number;
void roop(int ans, int num, int fin){
if((int a=ans+number(num)) <= 20){
if(num+2!=fin) roop(a, num+1, fin);
else if(a==answer) ++count;
} else if((int b=ans-number(num) >=0)){
if(num+2!=fin) roop(b, num+1, fin);
else if(b==answer) ++count;
} else break;
}
int main(){
int n;
std::cin >> n;
for(int i=0;i<n-1;++i){
std::cin >> number(i);
}
std::cin >> answer;
roop(number(0),1,n);
std::cout << count << std::endl;
return 0;
}
| a.cc: In function 'void roop(int, int, int)':
a.cc:9:13: error: expected primary-expression before 'int'
9 | if((int a=ans+number(num)) <= 20){
| ^~~
a.cc:9:13: error: expected ')' before 'int'
9 | if((int a=ans+number(num)) <= 20){
| ~^~~
| )
a.cc:12:10: error: expected ')' before 'else'
12 | } else if((int b=ans-number(num) >=0)){
| ^~~~~
| )
a.cc:9:11: note: to match this '('
9 | if((int a=ans+number(num)) <= 20){
| ^
a.cc: In function 'int main()':
a.cc:24:35: error: no match for call to '(std::vector<int>) (int&)'
24 | std::cin >> number(i);
| ~~~~~~^~~
a.cc:28:20: error: no match for call to '(std::vector<int>) (int)'
28 | roop(number(0),1,n);
| ~~~~~~^~~
|
s228200505 | p00480 | C++ | #include <iostream>
#include <vector>
unsigned long int count=0;
int answer=0;
std::vector<int> number;
void roop(int ans, int num, int fin){
if((int a=ans+number(num)) <= 20){
if(num+2!=fin) roop(a, num+1, fin);
else if(a==answer) ++count;
} else if((int b=ans-number(num)) >=0){
if(num+2!=fin) roop(b, num+1, fin);
else if(b==answer) ++count;
} else break;
}
int main(){
int n;
std::cin >> n;
for(int i=0;i<n-1;++i){
std::cin >> number(i);
}
std::cin >> answer;
roop(number(0),1,n);
std::cout << count << std::endl;
return 0;
}
| a.cc: In function 'void roop(int, int, int)':
a.cc:9:13: error: expected primary-expression before 'int'
9 | if((int a=ans+number(num)) <= 20){
| ^~~
a.cc:9:13: error: expected ')' before 'int'
9 | if((int a=ans+number(num)) <= 20){
| ~^~~
| )
a.cc:12:10: error: expected ')' before 'else'
12 | } else if((int b=ans-number(num)) >=0){
| ^~~~~
| )
a.cc:9:11: note: to match this '('
9 | if((int a=ans+number(num)) <= 20){
| ^
a.cc: In function 'int main()':
a.cc:24:35: error: no match for call to '(std::vector<int>) (int&)'
24 | std::cin >> number(i);
| ~~~~~~^~~
a.cc:28:20: error: no match for call to '(std::vector<int>) (int)'
28 | roop(number(0),1,n);
| ~~~~~~^~~
|
s038750590 | p00480 | C++ | #include <iostream>
#include <vector>
unsigned long int count=0;
int answer=0;
void roop(int ans, vecter<int> number,int num, int fin){
if((int a=ans+number(num)) <= 20){
if(num+2!=fin) roop(a, number , num+1, fin);
else if(a==answer) ++count;
} else if((int b=ans-number(num)) >=0){
if(num+2!=fin) roop(b, number, num+1, fin);
else if(b==answer) ++count;
} else break;
}
int main(){
int n;
std::cin >> n;
std::vector<int> number(n-1);
for(int i=0;i<n-1;++i){
std::cin >> number(i);
}
std::cin >> answer;
roop(number(0),number, 1, n);
std::cout << count << std::endl;
return 0;
}
| a.cc:7:20: error: 'vecter' has not been declared
7 | void roop(int ans, vecter<int> number,int num, int fin){
| ^~~~~~
a.cc:7:26: error: expected ',' or '...' before '<' token
7 | void roop(int ans, vecter<int> number,int num, int fin){
| ^
a.cc: In function 'void roop(int, int)':
a.cc:8:13: error: expected primary-expression before 'int'
8 | if((int a=ans+number(num)) <= 20){
| ^~~
a.cc:8:13: error: expected ')' before 'int'
8 | if((int a=ans+number(num)) <= 20){
| ~^~~
| )
a.cc:11:10: error: expected ')' before 'else'
11 | } else if((int b=ans-number(num)) >=0){
| ^~~~~
| )
a.cc:8:11: note: to match this '('
8 | if((int a=ans+number(num)) <= 20){
| ^
a.cc: In function 'int main()':
a.cc:24:35: error: no match for call to '(std::vector<int>) (int&)'
24 | std::cin >> number(i);
| ~~~~~~^~~
a.cc:28:20: error: no match for call to '(std::vector<int>) (int)'
28 | roop(number(0),number, 1, n);
| ~~~~~~^~~
|
s291893031 | p00480 | 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>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define PB push_back
ll dp[21][100];
int n;
num[100];
main(){
cin>>n;
rep(i,n)cin>>num[i];
dp[num[0]][0]=1;
for(int i=1;i<n-1;i++){
rep(j,20){
int nn=j-num[i];
if(nn>=0)dp[j][i]+=dp[nn][i-1];
nn=j+num[i];
if(nn<21)dp[j][i]+=dp[nn][i-1];
}
}
cout<<dp[num[n-1]][n-2]<<endl;
} | a.cc:34:1: error: 'num' does not name a type; did you mean 'enum'?
34 | num[100];
| ^~~
| enum
a.cc:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
36 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:38:16: error: 'num' was not declared in this scope; did you mean 'enum'?
38 | rep(i,n)cin>>num[i];
| ^~~
| enum
a.cc:40:6: error: 'num' was not declared in this scope; did you mean 'enum'?
40 | dp[num[0]][0]=1;
| ^~~
| enum
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.