submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s443221967
|
p04030
|
C++
|
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define sz 12
char s[sz + 3];
int main(){
int i, j, len;
gets(s);
len = strlen(s);
if(len == 1){
puts(s);
}else{
for(i = 0; s[i]; i++){
if(s[i + 1] != 'B' && s[i] != 'B'){
putchar(s[i]);
}
}
printf("\n");
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
14 | gets(s);
| ^~~~
| getw
|
s871712928
|
p04030
|
C++
|
#include <iostream>
/* Karen {{{
___ ____
|_ ||_ _|
| |_/ / ,--. _ .--. .---. _ .--.
| __'. `'_\ : [ `/'`\]/ /__\\[ `.-. |
_| | \ \_ // | |, | | | \__., | | | |
|____||____|\'-;__/[___] '.__.'[___||__]
}}} */
/* cpp template {{{*/
/*
using namespace std;
#define endl '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;
inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
REP(i, v.size()) {
if (i != 0) std::cout << c;
std::cout << v[i];
}
std::cout << endl;
}
template <typename T>
void print(T x) {
std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
/*
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
*//* }}} */
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int cnt = 0;
for (int i = s.size(); i >= 0; i--){
if (s[i] == 'B') cnt++;
else if (cnt){
s[i] = 'B';
cnt--;
}
}
REP(i, s.size()) if (s[i] != 'B') cout << s[i];
cout << endl;
return (0);
}
|
a.cc: In function 'int main()':
a.cc:61:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
61 | cin.tie(0);
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:62:3: error: 'ios' has not been declared
62 | ios::sync_with_stdio(false);
| ^~~
a.cc:64:3: error: 'string' was not declared in this scope
64 | string s;
| ^~~~~~
a.cc:64:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:65:10: error: 's' was not declared in this scope
65 | cin >> s;
| ^
a.cc:76:7: error: 'i' was not declared in this scope
76 | REP(i, s.size()) if (s[i] != 'B') cout << s[i];
| ^
a.cc:76:3: error: 'REP' was not declared in this scope
76 | REP(i, s.size()) if (s[i] != 'B') cout << s[i];
| ^~~
a.cc:77:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
77 | cout << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:77:11: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
77 | cout << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s416461800
|
p04030
|
C++
|
#include <iostream>
/* Karen {{{
___ ____
|_ ||_ _|
| |_/ / ,--. _ .--. .---. _ .--.
| __'. `'_\ : [ `/'`\]/ /__\\[ `.-. |
_| | \ \_ // | |, | | | \__., | | | |
|____||____|\'-;__/[___] '.__.'[___||__]
}}} */
/* cpp template {{{*/
/*
using namespace std;
#define endl '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;
inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
REP(i, v.size()) {
if (i != 0) std::cout << c;
std::cout << v[i];
}
std::cout << endl;
}
template <typename T>
void print(T x) {
std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */
*/
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int cnt = 0;
for (int i = s.size(); i >= 0; i--){
if (s[i] == 'B') cnt++;
else if (cnt){
s[i] = 'B';
cnt--;
}
}
REP(i, s.size()) if (s[i] != 'B') cout << s[i];
cout << endl;
return (0);
}
|
a.cc:51:7: error: 'll' does not name a type
51 | const ll MOD = 1e9 + 7;
| ^~
a.cc:52:7: error: 'll' does not name a type
52 | const ll INF = 1e9 + 9;
| ^~
a.cc:53:7: error: 'D' does not name a type
53 | const D EPS = 1e-9;
| ^
a.cc:57:2: error: expected unqualified-id before '/' token
57 | */
| ^
|
s689484948
|
p04030
|
C++
|
#include <bits/stdc++.h>
/* Karen {{{
___ ____
|_ ||_ _|
| |_/ / ,--. _ .--. .---. _ .--.
| __'. `'_\ : [ `/'`\]/ /__\\[ `.-. |
_| | \ \_ // | |, | | | \__., | | | |
|____||____|\'-;__/[___] '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;
#define endl '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;
inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
REP(i, v.size()) {
if (i != 0) std::cout << c;
std::cout << v[i];
}
std::cout << endl;
}
template <typename T>
void print(T x) {
std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */
signed main()
{
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int cnt = 0;
for (int i = s.size(); i >= 0; i--){
if (s[i] == 'B') cnt++;
else if (cnt){
s[i] = 'B';
cnt--;
}
}
REP(i, s.size()) s[i] == 'B'?:cout << s[i];
cout << endl;
return (0);
}
|
a.cc: In function 'int main()':
a.cc:74:31: error: operands to '?:' have different types 'bool' and 'std::basic_ostream<char>'
74 | REP(i, s.size()) s[i] == 'B'?:cout << s[i];
|
s866904559
|
p04030
|
C++
|
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
string s;
cin>>s;
string out="";
rep(i,s.size()){
if(s[i]=="B"){
if(out.size())out=out.substr(0,out.size()-1);
}else{
out+=s[i];
}
}
cout<<out<<endl;
}
|
a.cc: In function 'int main()':
a.cc:38:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
38 | if(s[i]=="B"){
|
s139565533
|
p04030
|
C++
|
#include<iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
char str[10] = { }, ans[10] = { };
int count = 0;
cin >> str;
for (int i = 0; i < strlen(str); i++) {
if (str[i] == '0')
ans[count] = '0';
else if (str[i] == '1')
ans[count] = '1';
else {
if (count != 0) {
ans[count - 1] = ' ';
count-=2;
}
else count--;
}
count++;
}
for (int i = 0; i <strlen(ans); i++) {
cout << ans[i];
}
putchar('\n');
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:29: error: 'strlen' was not declared in this scope
14 | for (int i = 0; i < strlen(str); i++) {
| ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 |
a.cc:31:28: error: 'strlen' was not declared in this scope
31 | for (int i = 0; i <strlen(ans); i++) {
| ^~~~~~
a.cc:31:28: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s105219034
|
p04030
|
Java
|
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
Deque<Character> dq = new ArrayDeque<>();
for(int i=0; i<s.length(); i++) {
char c = s.charAt(i);
if(c == 'B') {
if(!dq.isEmpty()) dq.pop();
continue;
}
dq.push(c);
}
while(!dq.isEmpty()) {
System.out.print(dq.poll());
}
System.out.println();
}
}
|
Main.java:6: error: class Test is public, should be declared in a file named Test.java
public class Test {
^
1 error
|
s027773625
|
p04030
|
C
|
include <stdio.h>
int main(void)
{
char s[10];
char ans[10];
int i, j;
j = 0;
scanf("%s", s);
for(i=0; i<10; i++){
if(s[i] == '0' || s[i] == '1' ){
printf("%d\n", j);
ans[j] = s[i];
j++;
}else if(s[i] == 'B'){
printf("%s\n", ans);
if(j!=0){
ans[--j] = '\0';
}
}
}
printf("%s\n", ans);
return 0;
}
|
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | include <stdio.h>
| ^
|
s055440492
|
p04030
|
Java
|
import java.util.*;
public class Hoge {
public static int sum(int n){
return (1+n)*n/2;
}
public static String conv(String in){
String result = "";
for (int i = 1; i < in.length(); i++) {
if (in.charAt(i) != 'B') {
result += in.charAt(i-1);
}
}
if (in.charAt(in.length()-1) != 'B') {
result += in.charAt(in.length()-1);
}
return result;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の入力
String a = sc.next();
System.out.println(conv(a));
}
}
|
Main.java:3: error: class Hoge is public, should be declared in a file named Hoge.java
public class Hoge {
^
1 error
|
s535710860
|
p04030
|
Java
|
import java.util.*;
public class Main {
public static int sum(int n){
return (1+n)*n/2;
}
public static String conv(String in){
String result = "";
int i = 1;
for (; i < in.length(); i++) {
if (in.charAt(i) != 'B') {
result += in.charAt(i-1);
}
}
if (in.charAt(i) != 'B') {
result += in.charAt(i);
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の入力
String a = sc.next();
System.out.println(conv(a));
}
}
|
Main.java:20: error: missing return statement
}
^
1 error
|
s604188371
|
p04030
|
Java
|
import java.util.*;
public class Main {
public static int sum(int n){
return (1+n)*n/2;
}
public static String conv(String in){
String result = "";
int i = 1;
for (; i < in.length(); i++) {
if (in.charAt(i) != 'B') {
result += in.charAt(i-1);
}
}
if (in.charAt(i) != 'B') {
result += in.charAt(i);
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の入力
int a = sc.next();
System.out.println(conv(a));
}
}
|
Main.java:25: error: incompatible types: String cannot be converted to int
int a = sc.next();
^
Main.java:26: error: incompatible types: int cannot be converted to String
System.out.println(conv(a));
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
|
s361572914
|
p04030
|
Java
|
import java.util.*;
public class Main {
public static int sum(int n){
return (1+n)*n/2;
}
public static String conv(String in){
String result = "";
int i = 1;
for (; i < in.length; i++) {
if (in.charAt(i) != 'B') {
result += in.charAt(i-1);
}
}
if (in.charAt(i) != 'B') {
result += in.charAt(i);
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の入力
int a = sc.nextString();
System.out.println(conv(a));
}
}
|
Main.java:12: error: cannot find symbol
for (; i < in.length; i++) {
^
symbol: variable length
location: variable in of type String
Main.java:25: error: cannot find symbol
int a = sc.nextString();
^
symbol: method nextString()
location: variable sc of type Scanner
Main.java:26: error: incompatible types: int cannot be converted to String
System.out.println(conv(a));
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
|
s269937388
|
p04030
|
C++
|
#include<iostream>
using namespace std;
int main(int argc, char const *argv[]) {
string s,sout;
int i;
cin>>s;
for(i=0;i<s.length;i++){
if(s[i]=="B"){
if (!(sout.empty())) {
sout.pop_back();
}
}
else{
sout+=s[i];
}
}
cout<<sout;
return 0;
}
|
a.cc: In function 'int main(int, const char**)':
a.cc:9:15: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
9 | for(i=0;i<s.length;i++){
| ~~^~~~~~
| ()
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
10 | if(s[i]=="B"){
|
s000793136
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(){
string s;
string ans="";
cin >> s;
for (int i = 0; i < s.size(); ++i)
{
switch(s[i]){
case '0':
ans+="0";
break;
case '1':
ans+="1";
break;
case 's':
if(!ans.empty()) 10ans.erase(ans.size()-1);
break;
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:18:42: error: unable to find numeric literal operator 'operator""ans.erase'
18 | if(!ans.empty()) 10ans.erase(ans.size()-1);
| ^~~~~~~~~~~
|
s844462698
|
p04030
|
C++
|
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
string S;
stack <char> ans;
cin >> S;
numa(c, S){
if (c == 'B') {
if (!ans.empty()) {
ans.pop();
}
}else{
ans.push(c);
}
}
string output;
while(!ans.empty()){
output += ans.top();
ans.pop();
}
reverse(ALL(output));
cout << ouput << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:56:11: error: 'ouput' was not declared in this scope; did you mean 'output'?
56 | cout << ouput << endl;
| ^~~~~
| output
|
s685160015
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
string s;
cin>>s;
int sLen=s.length()+1;
char *s1 = new char[sLen];
memset(s1,'\0',sLen);
char *pStr = (char*)s.c_str();
int i=0;
while (*pStr != '\0'){
if (*pStr != 'B'){
s1[i++] += *pStr;
}else{
if (i>0){
i--;
s1[i]='\0';
}
}
pStr++;
}
cout<<s1<<endl;
delete[] s1;
return 0;
}
|
a.cc: In function 'int main(int, char**)':
a.cc:10:9: error: 'memset' was not declared in this scope
10 | memset(s1,'\0',sLen);
| ^~~~~~
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>
|
s599094120
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(void){
string s; cin >> s;
string ans;
rep(i, s.size()){
if(s[i] == '0') ans += '0';
else if(s[i] == '1') ans += '1';
else{
if(!s) ans.pop_back();//空文字でなければ
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:28: error: no match for 'operator!' (operand type is 'std::string' {aka 'std::__cxx11::basic_string<char>'})
13 | if(!s) ans.pop_back();//空文字でなければ
| ^~
a.cc:13:28: note: candidate: 'operator!(bool)' (built-in)
a.cc:13:28: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'bool'
|
s375153357
|
p04030
|
C
|
#include <stdio.h>
#include <String.h>
int main(){
char s[10];
int i;
for(i = 0; i < 10; i++){
s[i] = getchar();
if(s[i] == '\n' || s[i] == '\r') break;
}
s[i] ='\0';
int s_index = 0;
int s_len = strlen(s);
int consec_b_count = 0;
if(s[0] == 'B'){ // if first letter is B, don't need to delete anything beforehand
while(s[s_index] == 'B'){
s_index++;
}
}
while(s_index < s_len){
s_index++;
if(s[s_index] == 'B' ){
consec_b_count++;
}
else if( consec_b_count != 0){ // if we run into a 0 or a 1 after a B
int index_to_change = s_index - consec_b_count;
for(; consec_b_count > 0; consec_b_count--){
if(index_to_change < 0){
consec_b_count = 0;
break;
}
while( s[index_to_change] !='0' && s[index_to_change] !='1' ){
index_to_change--;
if(index_to_change < 0){
break;
}
}
if(index_to_change < 0){
consec_b_count = 0;
break;
}
s[index_to_change] = 'X';
index_to_change--;
}
}
}
i = 0;
while(i < s_len){
if(s[i] == '0' || s[i] == '1') printf("%c", s[i]);
i++;
}
return 0;
}
|
main.c:2:10: fatal error: String.h: No such file or directory
2 | #include <String.h>
| ^~~~~~~~~~
compilation terminated.
|
s121830310
|
p04030
|
C
|
#include<stdio.h>
#include <stdlib.h>
int main() {
char s[11];
char r[11];
char buf[64];
int i,n,j,dummy,k;
scanf_s("%s", s, 11);
for (n = 0; s[n] != '\0'; n++);
for (i = 0, j=0; s[i] != '\0'; i++) {
fgets(buf, 64, stdin);
if (s[i] == 'B') {
j--;
}
else {
r[j] = s[i];
j++;
}
for (k = 0, r[j] = '\0'; k < j; k++) printf("%c", r[k]);
}
return 0;
}
|
main.c: In function 'main':
main.c:12:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
12 | scanf_s("%s", s, 11);
| ^~~~~~~
| scanf
|
s948987635
|
p04030
|
C
|
#include<stdio.h>
#include <stdlib.h>
int main() {
char s[11];
char r[11];
char buf[64];
int i,n,j,dummy,k;
scanf_s("%s", s, 11);
for (n = 0; s[n] != '\0'; n++);
for (i = 0, j=0; s[i] != '\0'; i++) {
fgets(buf, 64, stdin);
if (s[i] == 'B') {
//j--;
continue;
}
r[j] = s[i];
j++;
for (k = 0, r[j] = '\0'; k < j; k++) printf("%c", r[k]);
}
return 0;
}
|
main.c: In function 'main':
main.c:12:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
12 | scanf_s("%s", s, 11);
| ^~~~~~~
| scanf
|
s962337798
|
p04030
|
C
|
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char S[11];
char S2[11];
int i;
int j;
int len;
scanf("%s",S);
len = strlen( S );
j = 0;
for (i=0; i < len; i++) {
if (S[i] == '0') {
j = j + 1;
S2[j - 1] = '0';
}
if ( S[i] == '1') {
j = j + 1;
S2[j - 1] = '1';
}
if ( S[i] == 'B') {
if ( j != 0 ) {
j = j - 1;
S2[j] = null;
}
}
}
printf("%s\n",S2);
return 0;
}
|
main.c: In function 'main':
main.c:30:26: error: 'null' undeclared (first use in this function)
30 | S2[j] = null;
| ^~~~
main.c:30:26: note: each undeclared identifier is reported only once for each function it appears in
|
s195860107
|
p04030
|
C++
|
include <iostream>
#include <string>
using namespace std;
signed main()
{
string ans,in;
cin >> in;
for(auto a:in)
{
if(a == 'B')
{
ans.pop_back();
}
else
{
ans.push_back(a);
}
}
cout << ans << endl;
}
|
a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/char_traits.h:50:
/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:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared
144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type
146 | static _GLIBCXX14_CONSTEXPR std::size_t
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared
150 | find(const char_type* __s, std::size_t __n, const char_type& __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared
153 | move(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared
156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared
159 | assign(char_type* __s, std::size_t __n, char_type __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared
187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
| ^~~
/usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)':
/usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:189:33: error: '__i' was not declared in this scope; did you mean '__n'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| ^~~
| __n
/usr/include/c++/14/bits/char_traits.h: At global scope:
/usr/include/c++/14/bits/char_traits.h:198:31: error: 'size_t' in namespace 'std' does not name a type
198 | _GLIBCXX14_CONSTEXPR std::size_t
|
|
s265874166
|
p04030
|
C++
|
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
string a,b;
cin>>a;
int n=a.size();
for (int i=0;i<n;i++){
if (a[i]!='B'){
b+=a[i];
}else{
b.pop_back();}
cout<<b<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:17:2: error: expected '}' at end of input
17 | }
| ^
a.cc:6:12: note: to match this '{'
6 | int main() {
| ^
|
s907062009
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
cin >> str;
int len = str.length();
char* s = new char[len + 1];
memcpy(s, str.c_str(), len + 1);
for (int i = 0; i < len; i++) {
if (s[i] == 'B') {
if (i >= 1) {
for (int j = i - 1; j < len - -2; j++) {
s[j] = s[j + 2];
}
len -= 2;
i = -1;
}
if (i == 0) {
for (int j = i; j < len - 1; j++) {
s[j] = s[j + 1];
}
len -= 1;
i = -1;
}
}
}
for (int i = 0; i < len; i++) {
cout << *(s + i);
}
cout << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:9: error: 'memcpy' was not declared in this scope
12 | memcpy(s, str.c_str(), len + 1);
| ^~~~~~
a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #include <string>
|
s223394279
|
p04030
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
string c;
cin>>c;
for(int i=0;i<c.size();i++){
if(c=='1'){
s+="1";
}else if(c=='0'){
s+="0";
}else if(c=='B'){
s.erase(s.end()-1);
}
}
cout<<s<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:11:5: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char')
11 | if(c=='1'){
| ~^~~~~
| | |
| | char
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1274 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1441 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1613 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
11 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
11 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
11 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
11 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:11:7: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if(c=='1'){
| ^~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_vi
|
s906277269
|
p04030
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
string c;
for(int i=0;i<c.size();i++){
if(c=='1'){
s+="1";
}else if(c=='0'){
s+="0";
}else if(c=='B'){
s.erase(s.end()-1);
}
}
cout<<s<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:5: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char')
9 | if(c=='1'){
| ~^~~~~
| | |
| | char
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1274 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1441 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1613 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
9 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
9 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
9 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
9 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
9 | if(c=='1'){
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:9:7: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
9 | if(c=='1'){
| ^~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note:
|
s853097588
|
p04030
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<char> s;
char c;
for(int i=0;i<c.size();i++){
if(c=='1'){
s+="1";
}else if(c=='0'){
s+="0";
}else if(c=='B'){
s.erase(s.end()-1);
}
}
cout<<s<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:8:17: error: request for member 'size' in 'c', which is of non-class type 'char'
8 | for(int i=0;i<c.size();i++){
| ^~~~
a.cc:10:2: error: no match for 'operator+=' (operand types are 'std::vector<char>' and 'const char [2]')
10 | s+="1";
| ~^~~~~
a.cc:12:2: error: no match for 'operator+=' (operand types are 'std::vector<char>' and 'const char [2]')
12 | s+="0";
| ~^~~~~
a.cc:18:5: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<char>')
18 | cout<<s<<endl;
| ~~~~^~~
| | |
| | std::vector<char>
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<char>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<char>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<char>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<char>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<char>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<char>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<char>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<char>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<char>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<char>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<char>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<char>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<char>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<char>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<char>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'std::vector<char>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _
|
s981401976
|
p04030
|
C++
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<stdio.h>
int main() {
char s[10000],m[10000];
char c;
int i, j, k=0, l;
fgets(s, 10000, stdin);
for (i = 0;i < strlen(s);i++) {
switch (s[i])
{
case '0':
m[k] = '0';
k++;
break;
case '1':
m[k] = '1';
k++;
break;
case 'B':
if (k == 0)break;
m[k - 1] = '\0';
k--;
break;
default:
break;
}
}
m[k] = '\0';
l = strlen(m);
for (i = l-1;i >=0;i--) {
printf("%c", m[i]);
}
printf("\n");
return 0;
}
|
a.cc: In function 'int main()':
a.cc:17:24: error: 'strlen' was not declared in this scope
17 | for (i = 0;i < strlen(s);i++) {
| ^~~~~~
a.cc:7:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
6 | #include<algorithm>
+++ |+#include <cstring>
7 |
a.cc:38:13: error: 'strlen' was not declared in this scope
38 | l = strlen(m);
| ^~~~~~
a.cc:38:13: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s893145711
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string s,ans;
for(int i = 0; i < s.size(); i++)
{
if(s[i]=='B'){
if(ans.size != 0){
ans = ans.substr(0,s.size()-1);
}
}
else{
ans += s[i];
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:11:14: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
11 | if(ans.size != 0){
| ~~~~^~~~
| ()
|
s598743868
|
p04030
|
C++
|
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <list>
#include <vector>
#include <map>
using namespace std;
int main(void) {
string str,a;
cin >> str;
for (int i = 0; i < str.length(); i++) {
switch(str[i]) {
case '0':
a.push_back('0');
break;
case '1':
a.push_back('1');
break;
case 'B':
if(!a.empty)
a.pop_back();
break;
}
}
cout << a << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:27:31: error: cannot convert 'std::__cxx11::basic_string<char>::empty' from type 'bool (std::__cxx11::basic_string<char>::)() const noexcept' to type 'bool'
27 | if(!a.empty)
| ^~~~~
a.cc:27:31: error: in argument to unary !
27 | if(!a.empty)
| ~~^~~~~
|
s746254219
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string s,ans;
for(int i = 0; i < s.size(); i++)
{
if(s[i]=="B"){
if(ans != 0){
ans = ans.substr(0,s.size()-1);
}
}
else{
ans += s[i];
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
10 | if(s[i]=="B"){
a.cc:11:14: error: no match for 'operator!=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
11 | if(ans != 0){
| ~~~ ^~ ~
| | |
| | int
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
243 | operator!=(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1686 | operator!=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1753 | operator!=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
651 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
658 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3847 | operator!=(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'const _CharT*' and 'int'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2613 | operator!=(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2613:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46:
/usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator!=(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)'
242 | operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>'
11 | if(ans != 0){
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
from /usr/include/c++/14/bits/allocator.h:46:
/usr/include/c++/14/bits/new_allocator.h:222:9: note: candidate: 'template<class _Up> bool std::operator!=(const
|
s645037103
|
p04030
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string s,ans;
for(int i = 0; i < strlen(s); i++)
{
if(s[i]=="B"){
if(ans != 0){
ans = ans.substr(0,strlen(ans)-1);
}
}
else{
ans += s[i];
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:8:22: error: 'strlen' was not declared in this scope
8 | for(int i = 0; i < strlen(s); i++)
| ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #include <string>
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
10 | if(s[i]=="B"){
a.cc:11:14: error: no match for 'operator!=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
11 | if(ans != 0){
| ~~~ ^~ ~
| | |
| | int
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
243 | operator!=(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1686 | operator!=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1753 | operator!=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
651 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
658 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3847 | operator!=(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>'
11 | if(ans != 0){
| ^
/usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: mismatched types 'const _CharT*' and 'int'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2613 | operator!=(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2613:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>'
11 | if(ans != 0){
| ^
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46:
/usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator!=(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)'
242 | operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:242:5: note: template argument deduction/substitution failed:
a.cc:11:17: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::istreambuf_itera
|
s764217222
|
p04030
|
C++
|
string = input()
result = []
j=0
for i in range(len(string)):
if string[i] == '0':
result.append('0')
elif string[i] == '1':
result.append('1')
elif string[i]=='B' and result[-1] in ['0','1']:
result.append(" ")
str_result=" ".join(result)
print(str_result.replace(" ",""))
|
a.cc:1:1: error: 'string' does not name a type
1 | string = input()
| ^~~~~~
|
s228409296
|
p04030
|
C++
|
#include <iostream>
##include <string>
using namespace std;
int main(){
int n;
string s,ans;
for(int i = 0; i < strlen(s); i++)
{
if(s[i]=="B"){
if(ans != 0){
ans = ans.substr(0,strlen(ans)-1);
}
}
else{
ans += s[i];
}
}
cout << ans << endl;
return 0;
}
|
a.cc:2:1: error: stray '##' in program
2 | ##include <string>
| ^~
a.cc:2:3: error: 'include' does not name a type
2 | ##include <string>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'string' was not declared in this scope
7 | string s,ans;
| ^~~~~~
a.cc:7:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:8:29: error: 's' was not declared in this scope
8 | for(int i = 0; i < strlen(s); i++)
| ^
a.cc:8:22: error: 'strlen' was not declared in this scope
8 | for(int i = 0; i < strlen(s); i++)
| ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | ##include <string>
a.cc:11:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
11 | if(ans != 0){
| ^~~
| abs
a.cc:16:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
16 | ans += s[i];
| ^~~
| abs
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
19 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:19:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
19 | cout << ans << endl;
| ^~~
| abs
a.cc:19:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
19 | cout << ans << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s998478184
|
p04030
|
C
|
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char S[11];
char S2[11];
int i;
int j;
int len;
scanf("%s",S);
len = strlen( S );
j = 0;
for (i=0; i < len; i++) {
if (S[i] == 0) {
j = j + 1;
S2[j - 1] = 0;
}
if ( S[i] == 1) {
j = j + 1;
S2[j - 1] = 1;
}
if ( S[i] == 'B') {
j = j - 1;
}
printf("%s\n",S2);
return 0;
}
|
main.c: In function 'main':
main.c:34:1: error: expected declaration or statement at end of input
34 | }
| ^
|
s958975871
|
p04030
|
C
|
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char S[11];
char S2[11];
int i;
int j;
scanf("%s",S);
j = 0;
for (i=0; i < 10; i++) {
if (S[i] == 0) {
j = j + 1;
S2[j - 1] = 0;
}
if ( S[i] == 1) {
j = j + 1;
S2[j - 1] = 1;
}
if ( S[i] == 'B') {
j = j - 1;
}
if (S[i] == " ") {
break;
}
printf("%s\n",S2);
return 0;
}
|
main.c: In function 'main':
main.c:28:23: warning: comparison between pointer and integer
28 | if (S[i] == " ") {
| ^~
main.c:35:1: error: expected declaration or statement at end of input
35 | }
| ^
|
s191627853
|
p04030
|
C
|
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char S[11];
char S2[11];
int i;
int j;
scanf("%s",S);
j = 0;
for (i=0; i < 10; i++) {
if (S[i] == 0) {
j = j + 1;
S2[j - 1] = 0;
}
if ( S[i] == 1) {
j = j + 1;
S2[j - 1] = 1;
}
if ( S[i] == "B") {
j = j - 1;
}
if (S[i] == " ") {
break;
}
printf("%s\n",S2);
return 0;
}
|
main.c: In function 'main':
main.c:25:24: warning: comparison between pointer and integer
25 | if ( S[i] == "B") {
| ^~
main.c:28:23: warning: comparison between pointer and integer
28 | if (S[i] == " ") {
| ^~
main.c:35:1: error: expected declaration or statement at end of input
35 | }
| ^
|
s290698278
|
p04030
|
C
|
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char S[11];
char S2[11];
int i;
int j;
scanf("%s",S);
j = 0;
for (i=0; i < 10; i++) {
if (S[i] == 0) {
j = j + 1;
S2[j - 1] = 0;
}
if ( S[i] == 1) {
j = j + 1;
S2[j - 1] = 1;
}
if ( S[i] == B) {
j = j - 1;
}
if (S[i] == "") {
break;
}
printf("%s\n",S2);
return 0;
}
|
main.c: In function 'main':
main.c:25:28: error: 'B' undeclared (first use in this function)
25 | if ( S[i] == B) {
| ^
main.c:25:28: note: each undeclared identifier is reported only once for each function it appears in
main.c:28:23: warning: comparison between pointer and integer
28 | if (S[i] == "") {
| ^~
main.c:35:1: error: expected declaration or statement at end of input
35 | }
| ^
|
s536358437
|
p04030
|
C
|
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char S[11];
char S2[11];
int i;
int j;
scanf("%s",S);
j = 0;
for (i=0; i < 10; i++) {
if (S[i] == 0) {
j = j + 1;
S2[j - 1] = 0;
}
if ( (S[i] == 1) {
j = j + 1;
S2[j - 1] = 1;
}
if ( S[i] == B) {
j = j - 1;
}
if (S[i] == "") {
break;
}
printf("%s\n",S2);
return 0;
}
|
main.c: In function 'main':
main.c:20:31: error: expected ')' before '{' token
20 | if ( (S[i] == 1) {
| ~ ^~
| )
main.c:35:1: error: expected expression before '}' token
35 | }
| ^
main.c:35:1: error: expected declaration or statement at end of input
|
s494882407
|
p04030
|
C++
|
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<stdio.h>
int main() {
int a;
char c;
int x=0,i=0,j,n=0;
char s[1000];
while(scanf("%c",&c)!=EOF){
switch (c)
{
case '0':
x *= 2;
i++;
if (x == 0)n++;
break;
case '1':
x *= 2;
x++;
i++;
break;
case 'B':
if (x == 0) {
if(n!=0)n--;
if(i!=0)i--;
break;
}
x /= 2;
i--;
default:
break;
}
if (c == EOF)break;
}
itoa(x,s,2);
if (i == 0) {
printf("\n");
return 0;
}
for (j = 0;j < n-1;j++) {
printf("0");
}
printf("%s\n", s);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:45:9: error: 'itoa' was not declared in this scope
45 | itoa(x,s,2);
| ^~~~
|
s594836608
|
p04030
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<char> s;
char c;
while(cin>>c){
if(c=="1"){
s.push_buck("1");
}else if(c=="0"){
s.push_buck("0");
}else if(c=="B"){
s.pop_buck();
}
}
for(auto it=s.begin();it!=s.end();it++) {
cout<<*it<<endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
9 | if(c=="1"){
| ~^~~~~
a.cc:10:3: error: 'class std::vector<char>' has no member named 'push_buck'; did you mean 'push_back'?
10 | s.push_buck("1");
| ^~~~~~~~~
| push_back
a.cc:11:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
11 | }else if(c=="0"){
| ~^~~~~
a.cc:12:3: error: 'class std::vector<char>' has no member named 'push_buck'; did you mean 'push_back'?
12 | s.push_buck("0");
| ^~~~~~~~~
| push_back
a.cc:13:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
13 | }else if(c=="B"){
| ~^~~~~
a.cc:14:3: error: 'class std::vector<char>' has no member named 'pop_buck'; did you mean 'pop_back'?
14 | s.pop_buck();
| ^~~~~~~~
| pop_back
|
s356910173
|
p04030
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<char> s;
char c;
while(cin>>c){
if(c=="1"){
s.push_buck("1");
}else if(c=="0"){
s.push_buck("0");
}else if(c=="B"){
s.pop_buck();
}
}
cout<<s<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
9 | if(c=="1"){
| ~^~~~~
a.cc:10:3: error: 'class std::vector<char>' has no member named 'push_buck'; did you mean 'push_back'?
10 | s.push_buck("1");
| ^~~~~~~~~
| push_back
a.cc:11:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
11 | }else if(c=="0"){
| ~^~~~~
a.cc:12:3: error: 'class std::vector<char>' has no member named 'push_buck'; did you mean 'push_back'?
12 | s.push_buck("0");
| ^~~~~~~~~
| push_back
a.cc:13:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
13 | }else if(c=="B"){
| ~^~~~~
a.cc:14:3: error: 'class std::vector<char>' has no member named 'pop_buck'; did you mean 'pop_back'?
14 | s.pop_buck();
| ^~~~~~~~
| pop_back
a.cc:17:5: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<char>')
17 | cout<<s<<endl;
| ~~~~^~~
| | |
| | std::vector<char>
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::vector<char>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::vector<char>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::vector<char>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::vector<char>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::vector<char>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::vector<char>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::vector<char>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::vector<char>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::vector<char>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::vector<char>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::vector<char>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::vector<char>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::vector<char>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::vector<char>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::vector<char>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Tr
|
s713387375
|
p04030
|
C++
|
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<stdio.h>
int main() {
int a;
int c;
int x=0,i=0,j,n=0;
char s[1000];
while(scanf("%c",&c)!=EOF){
switch (c)
{
case '0':
x *= 2;
i++;
if (x == 0)n++;
break;
case '1':
x *= 2;
x++;
i++;
break;
case 'B':
if (x == 0) {
if(n!=0)n--;
if(i!=0)i--;
break;
}
x /= 2;
i--;
default:
break;
}
if (c == EOF)break;
}
itoa(x,s,2);
if (i == 0) {
printf("\n");
return 0;
}
for (j = 0;j < n-1;j++) {
printf("0");
}
printf("%s\n", s);
return 0;
}
//改行注意
|
a.cc: In function 'int main()':
a.cc:43:9: error: 'itoa' was not declared in this scope
43 | itoa(x,s,2);
| ^~~~
|
s908501401
|
p04030
|
C++
|
#include <algorithm>
using namespace std;
int main(){
string s; cin >> s;
string a = "";
int cnt = 0;
for(int i = s.size() - 1; i >= 0; i--){
if(s[i] == 'B'){
cnt++;
continue;
}
a += s[i-cnt];
if(i-cnt == 0) break;
if(cnt < 0) cnt++;
}
reverse(a.begin(),a.end());
cout << a << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:5:5: error: 'string' was not declared in this scope
5 | string s; cin >> s;
| ^~~~~~
a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
1 | #include <algorithm>
+++ |+#include <string>
2 | using namespace std;
a.cc:5:15: error: 'cin' was not declared in this scope
5 | string s; cin >> s;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <algorithm>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:5:22: error: 's' was not declared in this scope
5 | string s; cin >> s;
| ^
a.cc:6:11: error: expected ';' before 'a'
6 | string a = "";
| ^~
| ;
a.cc:13:9: error: 'a' was not declared in this scope
13 | a += s[i-cnt];
| ^
a.cc:17:13: error: 'a' was not declared in this scope
17 | reverse(a.begin(),a.end());
| ^
a.cc:18:5: error: 'cout' was not declared in this scope
18 | cout << a << endl;
| ^~~~
a.cc:18:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:18: error: 'endl' was not declared in this scope
18 | cout << a << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <algorithm>
+++ |+#include <ostream>
2 | using namespace std;
|
s203761452
|
p04030
|
C
|
#include<stdio.h>
int main(void){
char s[12],a[12];
int i,c=0;
scanf("%s",s);
for(i=0,s[i]!='\0',i++){
if(s[i]=='B'){
c--;
}else{
a[c]=s[i];
c++;
}
}
for(i=0;i<c;i++)printf("%c",a[i]);
puts("");return 0;
}
|
main.c: In function 'main':
main.c:6:23: error: expected ';' before ')' token
6 | for(i=0,s[i]!='\0',i++){
| ^
| ;
main.c:6:23: error: expected expression before ')' token
|
s137209339
|
p04030
|
Java
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);
String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
if(c!=0){
c--;
z[c] =0;
}
}else{
z[c] = y.charAt(i);
c++;
}
}
String o="";
for(int i=0;i<z.length;i++){
o = o+z.charAt(i);
}
System.out.println(o);
}
}
|
Main.java:24: error: cannot find symbol
o = o+z.charAt(i);
^
symbol: method charAt(int)
location: variable z of type char[]
1 error
|
s455509391
|
p04030
|
C++
|
#include <iostream>
using namespace std;
int main() {
string a;
cin >> a;
for(int i = 0; i <= a.size(); i++) {
if(a[i] == "b"){
a.erase(i - 1, 2)
i-= 2
};
}
cout << a << endl;
}
|
a.cc: In function 'int main()':
a.cc:8:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
8 | if(a[i] == "b"){
a.cc:9:24: error: expected ';' before 'i'
9 | a.erase(i - 1, 2)
| ^
| ;
10 | i-= 2
| ~
|
s785827052
|
p04030
|
Java
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);
String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
if(c!=0){
c--;
z[c] =0;
}
}else{
z[c] = y.charAt(i);
c++;
}
}
String o="";
for(int i=0;i<z.length;i++){
o = o+z.charAt(i);
}
System.out.println(o);
}
|
Main.java:28: error: reached end of file while parsing
}
^
1 error
|
s647423377
|
p04030
|
C++
|
s = raw_input()
words = []
for c in list(s):
if c == 'B':
words.pop()
else:
words.append(c)
print ''.join(words)
|
a.cc:8:7: error: empty character constant
8 | print ''.join(words)
| ^~
a.cc:1:1: error: 's' does not name a type
1 | s = raw_input()
| ^
|
s835812959
|
p04030
|
Java
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);
String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
if(c!=0){
c--;
z[c] =0;
}
}else{
z[c] = y.charAt(i);
c++;
}
}
String o="";
for(int i=0;i<,z.length;i++){
o = o+z.charAt(i);
}
System.out.println(o);
}
|
Main.java:23: error: illegal start of expression
for(int i=0;i<,z.length;i++){
^
Main.java:23: error: not a statement
for(int i=0;i<,z.length;i++){
^
Main.java:23: error: ')' expected
for(int i=0;i<,z.length;i++){
^
Main.java:23: error: ';' expected
for(int i=0;i<,z.length;i++){
^
Main.java:28: error: reached end of file while parsing
}
^
5 errors
|
s571432723
|
p04030
|
C++
|
#include <iostream>
using namespace std;
int main() {
string a;
cin >> a;
for(int i = 0; i <= a.size(); i++) {
if(a[i] == "b"){a.erase(i - 1, 2); i-= 2};
}
cout << a << endl;
}
|
a.cc: In function 'int main()':
a.cc:8:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
8 | if(a[i] == "b"){a.erase(i - 1, 2); i-= 2};
a.cc:8:45: error: expected ';' before '}' token
8 | if(a[i] == "b"){a.erase(i - 1, 2); i-= 2};
| ^
| ;
|
s086021808
|
p04030
|
Java
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner x= new Scanner(System.in);
String y = x.next();
char[] z = new char[y.length()];
int c=0;
for(int i=0;i<y.length();i++){
if(y.charAt(i)=='B'){
if(c!=0){
c--;
z[c] =0;
}
}else{
z[c] = y.charAt(i);
c++;
}
}
String o="";
for(int i=0;i<,z.length;i++)
o = o+z.charAt(i);
}
System.out.println(o);
}
|
Main.java:23: error: illegal start of expression
for(int i=0;i<,z.length;i++)
^
Main.java:23: error: not a statement
for(int i=0;i<,z.length;i++)
^
Main.java:23: error: ')' expected
for(int i=0;i<,z.length;i++)
^
Main.java:23: error: ';' expected
for(int i=0;i<,z.length;i++)
^
Main.java:27: error: <identifier> expected
System.out.println(o);
^
Main.java:27: error: <identifier> expected
System.out.println(o);
^
6 errors
|
s414145169
|
p04030
|
C++
|
#include <iostream>
using namespace std;
int main() {
string a;
cin >> a;
for(int i = 0; i <= a.size(); i++) {
if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
}
cout << a << endl;
}
|
a.cc: In function 'int main()':
a.cc:8:10: error: expected unqualified-id before '[' token
8 | if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
| ^
a.cc:8:22: error: expected primary-expression before '.' token
8 | if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
| ^
a.cc:8:45: error: expected ';' before '}' token
8 | if(a.[i] == "b"){.erase(i - 1, 2); i-= 2};
| ^
| ;
|
s832067391
|
p04030
|
C++
|
#include <iostream>
#include<string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string s,ans;
cin >> s;
for (int i = 0; i < s.length(); ++i){
if (s[i] == '1'){ ans += '1'; }
if (s[i] == '0'){ ans+= '0'; }
if (s[i] == 'B'){ if(ans.length()>0) ans.pop_back(); }
}
cout << ans << endl;
return 0;
}
|
a.cc:5:22: error: '_TCHAR' has not been declared
5 | int _tmain(int argc, _TCHAR* argv[])
| ^~~~~~
|
s300374185
|
p04030
|
C++
|
#include <string>
using namespace std;
int main(){
string s; cin >> s;
string a = "";
int cnt = 0;
for(int i = s.size() - 1; i-cnt >= 0; i--){
if(s[i] == 'B'){
cnt++;
continue;
}
a += s[i-cnt];
}
cout << a << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:5:15: error: 'cin' was not declared in this scope
5 | string s; cin >> s;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <string>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:15:5: error: 'cout' was not declared in this scope
15 | cout << a << endl;
| ^~~~
a.cc:15:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:18: error: 'endl' was not declared in this scope
15 | cout << a << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <string>
+++ |+#include <ostream>
2 | using namespace std;
|
s688362326
|
p04030
|
C++
|
from re import sub
s = input()
print(sub(r'.B', '', s).replace('B', ''))
|
a.cc:6:12: warning: multi-character character constant [-Wmultichar]
6 | print(sub(r'.B', '', s).replace('B', ''))
| ^~~~
a.cc:6:18: error: empty character constant
6 | print(sub(r'.B', '', s).replace('B', ''))
| ^~
a.cc:6:38: error: empty character constant
6 | print(sub(r'.B', '', s).replace('B', ''))
| ^~
a.cc:1:1: error: 'from' does not name a type
1 | from re import sub
| ^~~~
|
s011226223
|
p04031
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
using namespace std;
int main()
{
int numm[105];
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int temp;
cin >> temp;
numm[i] = temp;
}
int mincost = INT_MAX;
for (int i = -100; i < 101; i++)
{
int cost = 0;
for (int j = 0; j < n; j++)
{
cost += ((numm[j] - i) * (numm[j] - i));
}
if (cost < mincost) mincost = cost;
}
cout << mincost;
}
|
a.cc: In function 'int main()':
a.cc:35:19: error: 'INT_MAX' was not declared in this scope
35 | int mincost = INT_MAX;
| ^~~~~~~
a.cc:19:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
18 | #include <cassert>
+++ |+#include <climits>
19 |
|
s084713631
|
p04031
|
C++
|
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define INF 0x7fffffff
using namespace std;
int N;
int main() {
cin >> N;
vector<int> nums(N);
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> nums[i];
sum += nums[i];
}
int x = floor(sum / n);
int y = ceil(sum / n);
int ans1 = 0, ans2 = 0;
for(auto index : nums) {
ans1 += (index - x) * (index - x);
ans2 += (index - y) * (index - y);
}
cout << min(ans1, ans2) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:19:25: error: 'n' was not declared in this scope
19 | int x = floor(sum / n);
| ^
|
s175757478
|
p04031
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
int arr[n];
for(int i=0;i<n;i++) cin>>arr[i];
int ans = 1e9;
for(int k=-100;k<=100;k++){
int cost = 0;
for(int i=0;i<n;i++) cost += (k-arr[i])*(k-arr[i]);
ans = min(ans,cost);
}
cout<<cost;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:17:9: error: 'cost' was not declared in this scope; did you mean 'cosl'?
17 | cout<<cost;
| ^~~~
| cosl
|
s925989545
|
p04031
|
C++
|
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vec vector<int>
#define fo(i,n) for (int i = 0; i < n; i++)
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
using namespace std;
int main()
{
int n;
cin>>n;
vector<int> a(n) ;
int sum = 0 ;
fo(i,n){
cin >> a[i] ;
sum+=a[i] ;
}
sort(a.begin(),a.end()) ;
int mean = sum/n ;
int a = 0 ;
int a2 = 0 ;
fo(i,n){
a+=(a[i]-mean)*(a[i]-mean) ;
}
fo(i,n){
a2+=(a[i]-(mean+1))*(a[i]-(mean+1)) ;
}
cout << min(a,as2)<< endl ;
return 0 ;
}
|
a.cc: In function 'int main()':
a.cc:27:9: error: conflicting declaration 'int a'
27 | int a = 0 ;
| ^
a.cc:19:17: note: previous declaration as 'std::vector<int> a'
19 | vector<int> a(n) ;
| ^
a.cc:30:10: error: no match for 'operator+=' (operand types are 'std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
30 | a+=(a[i]-mean)*(a[i]-mean) ;
| ~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:37:19: error: 'as2' was not declared in this scope; did you mean 'a2'?
37 | cout << min(a,as2)<< endl ;
| ^~~
| a2
|
s654835859
|
p04031
|
Java
|
import java.util.*;
/**
* C Main
*
* @date 2020.08.22
* @author 焼き鮭 <yaki-shake@up-tri.me>
*/
public class Main {
Scanner sc;
public static void main(String[] args) {
new Main().execute();
}
public void execute() {
this.sc = new Scanner(System.in);
int n = this.sc.nextInt();
int[] a = new int[n];
int sum = 0;
for (int i = 0; i < n; i++) {
a[i] = this.sc.nextInt();
sum += a[i];
}
double avg = sum * 1.0 / n;
int high = (int) (Math.ceil(avg));
int low = (int) (Math.floor(avg));
int totalCostAtHigh = 0;
for (int i = 0; i < n; i++) {
totalCostAtHigh += this.cost(a[i], high);
}
if (high == low) {
System.out.println(totalCostAtHigh);
return 0;
}
int totalCostAtLow = 0;
for (int i = 0; i < n; i++) {
totalCostAtLow += this.cost(a[i], low);
}
System.out.println(totalCostAtHigh < totalCostAtLow ? totalCostAtHigh : totalCostAtLow);
}
public int cost(int from, int to) {
if (from == to) {
return 0;
}
return (from - to) * (from - to);
}
}
|
Main.java:38: error: incompatible types: unexpected return value
return 0;
^
1 error
|
s416678781
|
p04031
|
C
|
#include<stdio.h>
void swap(int* a,int* b){
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void sorted_array(int* array,int n){
int i,j;
int min_i;
for(i=0;i<n-1;i++){
min_i = i;
for(j=i+1;j<n;j++){
if(arr[j]<min_i){
min_i=j;
}
}
swap(&arr[i],&arr[min_i]);
}
}
int min(int a,int b){
if(a>b) return b;
else return a;
}
int main(){
int n;
scanf("%d\n",&n);
int arr[n];
int i;
for(i=0;i<n;i++){
scanf("%d ",&arr[i]);
}
sorted_array(&arr,n);
int min,max;
min= arr[0],max= arr[n-1];
int min_sum = 1000000;
int k;
for(i=min;i<=max;i++){
int sum = 0;
for(j=0;j<n;j++){
sum = sum + (arr[j]-i)*(arr[j]-i);
}
k = sum;
int d = min(min_sum,k);
if(d==k){
min_sum = k;
}
}
printf("%d\n",min_sum);
return 0;
}
|
main.c: In function 'sorted_array':
main.c:14:10: error: 'arr' undeclared (first use in this function); did you mean 'array'?
14 | if(arr[j]<min_i){
| ^~~
| array
main.c:14:10: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:33:16: error: passing argument 1 of 'sorted_array' from incompatible pointer type [-Wincompatible-pointer-types]
33 | sorted_array(&arr,n);
| ^~~~
| |
| int (*)[n]
main.c:8:24: note: expected 'int *' but argument is of type 'int (*)[n]'
8 | void sorted_array(int* array,int n){
| ~~~~~^~~~~
main.c:40:9: error: 'j' undeclared (first use in this function)
40 | for(j=0;j<n;j++){
| ^
main.c:44:13: error: called object 'min' is not a function or function pointer
44 | int d = min(min_sum,k);
| ^~~
main.c:34:7: note: declared here
34 | int min,max;
| ^~~
|
s881524353
|
p04031
|
C
|
#include<stdio.h>
int main(){
int N;
scanf("%d",&N);
int a[N];
for(int i=0;i<N;i++){
scanf("%d",&a[i]);
}
int sum=0;
for(int i=-100;i<=100;i++){
for(int j=0;j<N;j++){
sum+=(a[j]-i)*(a[j]-i);
}
if(i==-100){
min=sum;
}else{
temp=sum;
}
if(temp<min){
temp=min;
}
sum=0;
}
printf("%d\n",min);
return 0;
}
|
main.c: In function 'main':
main.c:18:9: error: 'min' undeclared (first use in this function); did you mean 'main'?
18 | min=sum;
| ^~~
| main
main.c:18:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:20:9: error: 'temp' undeclared (first use in this function)
20 | temp=sum;
| ^~~~
|
s849889713
|
p04031
|
C
|
#include<stdio.h>
int main(){
int N;
scanf("%d",&N);
int a[N];
for(int i=0;i<N;i++){
scanf("%d",&a[i]);
}
int sum=0;
int min=0;
int temp=0;
for(int i=-100;i<=100;i++){
for(int j=0;j<N;j++){
sum+=(a[j]-i)*(a[j]-i);
}
if(j==-100){
min=sum;
}else{
temp=sum;
}
if(temp<sum){
temp=sum;
}
sum=0;
}
printf("%d\n",min);
return 0;
}
|
main.c: In function 'main':
main.c:19:10: error: 'j' undeclared (first use in this function)
19 | if(j==-100){
| ^
main.c:19:10: note: each undeclared identifier is reported only once for each function it appears in
|
s568125633
|
p04031
|
C
|
#include<stdio.h>
int main(){
int N;
scanf("%d",&N);
int a[N];
for(int i=0;i<N;i++){
scanf("%d",&a[i]);
}
int min=0;
int temp=0;
for(int i=-100;i<=100;i++){
for(int j=0;j<N;j++){
if(i==-100){
min+=(a[j]-i)*(a[j]-i);];
}else{
temp+=(a[j]-i)*(a[j]-i);
}
if(temp<min){
min=temp;
}
}
}
printf("%d\n",min);
return 0;
}
|
main.c: In function 'main':
main.c:17:36: error: expected statement before ']' token
17 | min+=(a[j]-i)*(a[j]-i);];
| ^
|
s725531033
|
p04031
|
C
|
#include <stdio.h>
int main (void){
long long N,A[101],B[101]i,j,k;
long long sum = 0;
long long min=10000*10000;
scanf("%lld",&N);
for(i=0;i<N;i++){
scanf("&lld",A[i]);
}
for(i=0;i<101;i++){
for(j=0;j<N;j++){
B[j] = (A[j]-i)*(A[j]-i);
sum +=B[j];
}
if(min>sum){
min=sum;
}
sum=0;
}
printf("%d",sum);
}
|
main.c: In function 'main':
main.c:5:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i'
5 | long long N,A[101],B[101]i,j,k;
| ^
main.c:9:13: error: 'i' undeclared (first use in this function)
9 | for(i=0;i<N;i++){
| ^
main.c:9:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:13: error: 'j' undeclared (first use in this function)
14 | for(j=0;j<N;j++){
| ^
main.c:15:17: error: 'B' undeclared (first use in this function)
15 | B[j] = (A[j]-i)*(A[j]-i);
| ^
|
s172884106
|
p04031
|
Java
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;
public class C {
public static StringBuilder output = new StringBuilder();
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int arr[] = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
Solver solver = new Solver();
solver.solve(arr);
System.out.println(output);
}
}
class Solver {
public void solve(int arr[]) {
int ans = Integer.MAX_VALUE;
for (int i = -100; i <= 100; i++) {
// Try each number to find min
int curr = 0;
for (int j = 0; j < arr.length; j++) {
curr += (arr[j] - i) * (arr[j] - i);
}
ans = Math.min(curr, ans);
// arr[idx] - i
}
C.output.append(ans);
}
}
|
Main.java:11: error: class C is public, should be declared in a file named C.java
public class C {
^
1 error
|
s284205446
|
p04031
|
C++
|
int arr[105]/** "Ever tried.
Ever failed.
No matter.
Try Again.
Fail again.
Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define Unique(n) (n).erase(unique(s(n)), (n).end())
#define NumofDigits(n) ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
}
ll arr[105];
int main()
{
ios_base::sync_with_stdio(0);
int n;
ll sum=0;
cin>>n;
for(int i=0; i<n; i++)
cin>>arr[i],sum+=arr[i];
ll avg=ceil((double)sum/(double)n);
ll ans=0;
for(int i=0; i<n; i++)
{
ll step=(arr[i]-avg)*(arr[i]-avg);
ans+=step;
}
cout<<ans;
}
;
|
In file included from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:7:
/usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:308:1: error: expected initializer before 'namespace'
308 | namespace std
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/in
|
s569610859
|
p04031
|
C++
|
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++) cin >> arr[i];
int ans = 0;
ll curr_min = INT_MAX;
for (int i = -100; i <= 100; i++) {
int curr = 0;
for (int j = 0; j < n; j++) {
curr += (arr[j] - i * arr[j] - i);
}
curr_min = min(curr_min, curr);
ans = min(ans, curr);
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:22:23: error: no matching function for call to 'min(long long int&, int&)'
22 | curr_min = min(curr_min, curr);
| ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:22:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
22 | curr_min = min(curr_min, curr);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:22:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
22 | curr_min = min(curr_min, curr);
| ~~~^~~~~~~~~~~~~~~~
|
s745213970
|
p04031
|
C++
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
using namespace std;
int main()
{
int n,ans=100000000;
cin>>n;
int a[n+5];
for(int i=0; i<n; i++) cin>>a[i];
for(int i=-100;i<=100;i++)
{
int cost=0;
for(int j=0;j<n;j++)
{
cost+=(i-a[j])*(i-a[j]);
}
ans=min(ans,cost);
}
cout<<ans<<endl;
}
}
|
a.cc:40:1: error: expected declaration before '}' token
40 | }
| ^
|
s051673554
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int c(int d,vector<int> v){
int e = 0;
int n = v.size();
for (int y=0;y<n;y++){
e =(v[y]-d)*(v[y]-d) + e;
}
return e;
}
int main() {
int a=0;
int n; cin>>n;
vector<int> v(n);
for (int i=0;i<n;i++){
cin>>v[i];
}
for (int u=0;u<n;u++){
a = v[u]+a;
}
int b = a/n;
cout << min(c(b,v),c(b+1,v));
|
a.cc: In function 'int main()':
a.cc:22:34: error: expected '}' at end of input
22 | cout << min(c(b,v),c(b+1,v));
| ^
a.cc:11:12: note: to match this '{'
11 | int main() {
| ^
|
s559546061
|
p04031
|
C++
|
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
int min_cost=100000000;
for(int i=-100;i<=100;i++){
int cost=0;
for(int j=0;j<n;j++){
int b=a[j]-i;
cost+=pow(b,2);
}
min_cost=min(min_cost,cost);
}
cout<<min_cost<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:3: error: 'vector' was not declared in this scope
6 | vector<int> a(n);
| ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
1 | #include<iostream>
+++ |+#include <vector>
2 | using namespace std;
a.cc:6:10: error: expected primary-expression before 'int'
6 | vector<int> a(n);
| ^~~
a.cc:8:10: error: 'a' was not declared in this scope
8 | cin>>a[i];
| ^
a.cc:14:13: error: 'a' was not declared in this scope
14 | int b=a[j]-i;
| ^
a.cc:15:13: error: 'pow' was not declared in this scope
15 | cost+=pow(b,2);
| ^~~
|
s642541390
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> A(N);
for(int i=0;i<N;i++){
cin >> A.at(i);
}
int min_cost=100000000;
for(int i=-100;i<101;i++){
int cost=0;
for(int j=0;j<N;j++){
int B=A.at(j)-i;
cost+=pow(B,2);
}
min_cost=min(min_cost,cost);
}
cout << min_cost << endl;
|
a.cc: In function 'int main()':
a.cc:20:28: error: expected '}' at end of input
20 | cout << min_cost << endl;
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s231065905
|
p04031
|
C++
|
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> a(n);
ll tmp = 0;
ll ans = 1e9;
rep(i,n){
cin >> a[i];
}
sort(ALL(a));
for(int i = -100;i<=100;i++){
tmp = 0;
rep(j,n){
temp += (a[j]-i)*(a[j]-i);
}
ans = min(tmp,ans);
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:21:13: error: 'temp' was not declared in this scope; did you mean 'tmp'?
21 | temp += (a[j]-i)*(a[j]-i);
| ^~~~
| tmp
|
s854845613
|
p04031
|
C++
|
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> a(n);
ll tmp = 0;
ll ans = 1e9;
rep(i,n){
cin >> a[i];
}
sort(ALL(a));
for(int i = -100;i<=100;i++){
tmp = 0;
rep(i,n){
temp += (a[i]-i)*(a[i]-i);
}
ans = min(tmp,ans);
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:21:13: error: 'temp' was not declared in this scope; did you mean 'tmp'?
21 | temp += (a[i]-i)*(a[i]-i);
| ^~~~
| tmp
|
s646163183
|
p04031
|
C++
|
//C - Be Together
int N;
int a[101];
int main()
{
int min = -101,max = 101,mincost;
scanf("%d",&N);
for (int i=1;i<=N;i++)
{
scanf("%d",&a[i]);
if (a[i]<min)
min = a[i];
if (a[i]>max)
max = a[i];
}
mincost = computeCost(min);
for (int j=min;j<=max;j++)
{
int cost = computeCost(j);
if (cost<mincost)
mincost = cost;
}
printf("%d",mincost);
}
int computeCost(int target)
{
int cost = 0;
for(int i=1;i<=N;i++)
{
cost += (a[i]-target)*(a[i]-target);
}
return cost;
}
|
a.cc: In function 'int main()':
a.cc:8:9: error: 'scanf' was not declared in this scope
8 | scanf("%d",&N);
| ^~~~~
a.cc:20:19: error: 'computeCost' was not declared in this scope
20 | mincost = computeCost(min);
| ^~~~~~~~~~~
a.cc:29:9: error: 'printf' was not declared in this scope
29 | printf("%d",mincost);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | //C - Be Together
|
s832047103
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i,m=1000000000,c=0;
cin>>n;
vector<int> arr(n);
for(i=0;i<n;i++)cin>>arr[i];
for(i=-100;i<=100;i++)
{
for(int w:arr)
cost+=(w-i)*(w-i);
m=min(m, cost);
}
cout<<m;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:25: error: 'cost' was not declared in this scope; did you mean 'cosl'?
12 | cost+=(w-i)*(w-i);
| ^~~~
| cosl
a.cc:13:26: error: 'cost' was not declared in this scope; did you mean 'cosl'?
13 | m=min(m, cost);
| ^~~~
| cosl
|
s880098217
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i,m=1000000000,c=0;
cin>>n;
vector<int> arr(n);
for (i=0;i<n; ++)cin>>arr[i];
for(i=-100;i<=100;i++)
{
for(int w:arr)
cost+=(w-i)*(w-i);
m=min(m, cost);
}
cout<<m;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:8:25: error: expected primary-expression before ')' token
8 | for (i=0;i<n; ++)cin>>arr[i];
| ^
a.cc:12:25: error: 'cost' was not declared in this scope; did you mean 'cosl'?
12 | cost+=(w-i)*(w-i);
| ^~~~
| cosl
a.cc:13:26: error: 'cost' was not declared in this scope; did you mean 'cosl'?
13 | m=min(m, cost);
| ^~~~
| cosl
|
s625137135
|
p04031
|
C++
|
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i,n) {
cin >> a[i];
}
int ans = INT_MAX;
for (int same = -100; same <= 100; same++)
{
int sum = 0;
rep(i,n) {
sum += (a[i]-same)*(a[i]-same);
}
ans = min(ans, sum);
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:15: error: 'INT_MAX' was not declared in this scope
21 | int ans = INT_MAX;
| ^~~~~~~
a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
9 | #include <map>
+++ |+#include <climits>
10 | using namespace std;
|
s107402864
|
p04031
|
C++
|
#include <iostream>
using namespace std;
const int N = 1e6 + 5;
const int inf = 1e9 + 7;
int a[N];
int main() {
int n, cost = inf, mn = inf, mx = -inf;
cin >> n;
for (int i = 0; i < n; i ++) {
cin >> a[i];
mn = min(mn, a[i]);
mx = max(mx, a[i]);
}
for (int i = mn; i <= mx; i ++) {
int sum = 0;
for (int j = 0; j < n; j ++) {
sum += (a[j] - i) * (a[j] - i);
}
if (sum < cost) {
cost = sum;
ans = i;
}
}
cout << cost << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:25:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
25 | ans = i;
| ^~~
| abs
|
s241275809
|
p04031
|
C++
|
#include <iostream>
#include <cmath>
#include <numeric>
#include <vector>
using namespace std;
// int main(){
// int N, temp;
// cin >> N;
// vector<int> A;
// for(int i = 0; i < N; i++){
// cin >> temp;
// A.push_back(temp);
// }
// // 配列だとaccumulateを使用できないため、vectorを使用した。
// double average = accumulate(A.begin(), A.end(), 0) / double(A.size());
// average = round(average); //平均を四捨五入する。
// int ans = 0;
// for(int i = 0; i < N; i++){
// ans += (average - A[i])*(average - A[i]);
// }
// cout << ans << endl;
// }
int main(){
int N, temp;
cin >> N;
int A[N];
for(int i = 0; i < N; i++){
cin >> A[N];
}
int minCost = 1000000;
for(int i = -100; i < 101; i++){
for(int n = 0; n < N; n++){
temp += (i - A[n]) * (i - A[n]);
}
if(temp < minConst) minCost = temp;
temp = 0;
}
}
|
a.cc: In function 'int main()':
a.cc:39:19: error: 'minConst' was not declared in this scope; did you mean 'minCost'?
39 | if(temp < minConst) minCost = temp;
| ^~~~~~~~
| minCost
|
s899986190
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int a[105],n;
int is_ok(int x)
{
int s=0;
for(int i=1; i<=n; i++)
s+=(a[i]-x)*(a[i]-x);
return s;
}
int main()
{
int i,r=0,l=105,iv=1e9,ans=0;
cin>>n;
for(i=1; i<=n; i++)
{
cin>>a[i];
r=max(r,a[i]);
l=min(l,a[i]);
}
sort(a+1,a+n+1);
for(i=l; i<=r; i++)
if(is_ok(i)<iv)
{
v=is_ok(i);
ans=i;
}
cout<<ans;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:25:25: error: 'v' was not declared in this scope; did you mean 'iv'?
25 | v=is_ok(i);
| ^
| iv
|
s811334711
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int a[105],n;
int is_ok(int x)
{
int s=0;
for(int i=1; i<=n; i++)
s+=(a[i]-x)*(a[i]-x);
return s;
}
int main()
{
int i,r=0,l=105,iv=1e9,ans=0;
cin>>n;
for(i=1; i<=n; i++)
{
cin>>a[i];
r=max(r,a[i]);
l=min(l,a[i]);
}
sort(a+1,a+n+1);
for(i=l; i<=r; i++)
if(is_ok(i)<iv)
{
v=is_ok(i);
ans=i;
}
cout<<ans;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:25:25: error: 'v' was not declared in this scope; did you mean 'iv'?
25 | v=is_ok(i);
| ^
| iv
|
s559483318
|
p04031
|
C
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
cin>>n;
int a[n+1];
int maxv;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++)
if(a[i]<0)
a[i]=0;
maxv=a[1];
for(i=1;i<=n;i++)
{
if(a[i]>maxv)
{
maxv=a[i];
}
}
cout<<maxv;
}
|
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s597525117
|
p04031
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
int n;
cin>>n;
vector<int> a(n);
rep(i,n)cin>>a[i];
int ans=MOD;
for(int i=-100;i<=100;i++){
int sum=0;
rep(j,n){
sum+=pow(a[j]-i,2);
}
ans=min(ans,sum)
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:19:25: error: expected ';' before '}' token
19 | ans=min(ans,sum)
| ^
| ;
20 | }
| ~
|
s168361736
|
p04031
|
C++
|
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
int n,i,j,min=1000000000,cost;
cin>>n;
int list[n];
for(i=0;i<n;i++)
cin>>list[i];
sort(list,list+n);
for(i=list[0];i<=list[n-1];i++)
{
cost=0
for(j=0;j<n;j++)
{
cost+=pow(i-list[j],2);
}
if(cost<min)
min=cost;
}
cout<<min;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:13: error: expected ';' before 'for'
15 | cost=0
| ^
| ;
16 | for(j=0;j<n;j++)
| ~~~
a.cc:16:21: error: expected ';' before ')' token
16 | for(j=0;j<n;j++)
| ^
| ;
|
s879622870
|
p04031
|
C++
|
n = int(input())
a = list(map(int, input().split()))
ans = 10000000
for i in range(-100, 101):
sm = 0
for x in a:
sm += (x-i) ** 2
ans = min(ans, sm)
print(ans)
|
a.cc:1:1: error: 'n' does not name a type
1 | n = int(input())
| ^
|
s034703341
|
p04031
|
C++
|
#include <iostream>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#pragma warning(disable: 4996)
int main()
{
int N;
int ret;
ret = scanf("%d", &N);
vector<int> v(N);
for (int i = 0; i < N; i++) {
ret = scanf("%d", &v[i]);
}
int sum = accumulate(v.begin(),v.end(),0);
double average = (double)sum/(double)N;
int average_int = round(average);
int result = 0;
for (int i = 0; i < N; i++) {
result += pow((v[i] - average_int), 2);
}
//// sort(v.begin(), v.end(), std::greater<int>());
//sort(v.begin(), v.end());
//int result = INT_MAX, temp;
//for (int i = v[0]; i <= v[N - 1]; i++) {
// temp = 0;
// for (int j = 0; j < N; j++) {
// temp += (v[j] - i)*(v[j] - i);
// }
// if (result > temp) {
// result = temp;
// }
//}
printf("%d\n", result);
return 0;
// std::cout << "Hello World!\n";
}
|
a.cc: In function 'int main()':
a.cc:25:23: error: 'round' was not declared in this scope
25 | int average_int = round(average);
| ^~~~~
a.cc:29:27: error: 'pow' was not declared in this scope
29 | result += pow((v[i] - average_int), 2);
| ^~~
|
s377590394
|
p04031
|
C++
|
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
//#define _DBG
int main()
{
uint32_t N;
int ret;
#ifdef _DBG
ret = scanf_s("%d", &N);
#else
ret = scanf("%d", &N);
#endif
vector<int> v(N);
for (size_t i = 0; i < N; i++) {
#ifdef _DBG
ret = scanf_s("%d", &v[i]);
#else
ret = scanf("%d", &v[i]);
#endif
}
// sort(v.begin(), v.end(), std::greater<int>());
sort(v.begin(), v.end());
int32_t result = INT_MAX,temp;
for (int32_t i = v[0]; i <= v[N-1]; i++) {
temp = 0;
for (uint32_t j = 0; j < N; j++) {
temp += (v[j] - i)*(v[j] - i);
}
if (result > temp) {
result = temp;
}
}
printf("%d\n", result);
return 0;
// std::cout << "Hello World!\n";
}
|
a.cc: In function 'int main()':
a.cc:14:9: error: 'uint32_t' was not declared in this scope
14 | uint32_t N;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <algorithm>
+++ |+#include <cstdint>
7 |
a.cc:20:28: error: 'N' was not declared in this scope
20 | ret = scanf("%d", &N);
| ^
a.cc:33:26: error: 'INT_MAX' was not declared in this scope
33 | int32_t result = INT_MAX,temp;
| ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
6 | #include <algorithm>
+++ |+#include <climits>
7 |
a.cc:35:17: error: 'temp' was not declared in this scope; did you mean 'tm'?
35 | temp = 0;
| ^~~~
| tm
a.cc:36:30: error: expected ';' before 'j'
36 | for (uint32_t j = 0; j < N; j++) {
| ^~
| ;
a.cc:36:38: error: 'j' was not declared in this scope
36 | for (uint32_t j = 0; j < N; j++) {
| ^
|
s593846548
|
p04031
|
C++
|
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
uint32_t N;
int ret;
ret = scanf_s("%d", &N);
vector<int> v(N);
uint32_t sum = 0;
for (size_t i = 0; i < N; i++) {
ret = scanf_s("%d", &v[i]);
}
// sort(v.begin(), v.end(), std::greater<int>());
sort(v.begin(), v.end());
int32_t result = 100,temp;
int32_t pos = 0;
for (int32_t i = v[0]; i < v[N-1]; i++) {
temp = 0;
for (uint32_t j = 0; j < N; j++) {
temp += (v[j] - i)*(v[j] - i);
}
if (result > temp) {
result = temp;
}
}
printf("%d\n", result);
return 0;
// std::cout << "Hello World!\n";
}
|
a.cc: In function 'int main()':
a.cc:12:9: error: 'uint32_t' was not declared in this scope
12 | uint32_t N;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <algorithm>
+++ |+#include <cstdint>
7 |
a.cc:15:30: error: 'N' was not declared in this scope
15 | ret = scanf_s("%d", &N);
| ^
a.cc:15:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
15 | ret = scanf_s("%d", &N);
| ^~~~~~~
| scanf
a.cc:18:17: error: expected ';' before 'sum'
18 | uint32_t sum = 0;
| ^~~~
| ;
a.cc:30:30: error: expected ';' before 'j'
30 | for (uint32_t j = 0; j < N; j++) {
| ^~
| ;
a.cc:30:38: error: 'j' was not declared in this scope
30 | for (uint32_t j = 0; j < N; j++) {
| ^
|
s061007353
|
p04031
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int a[100100];
int main(){
int n;cin>>n;
f(i,1,n) cin>>a[i];
sort(a+1,a+1+n);
cout<<a[(n+1)>>1];}
|
a.cc: In function 'int main()':
a.cc:6:5: error: 'i' was not declared in this scope
6 | f(i,1,n) cin>>a[i];
| ^
a.cc:6:3: error: 'f' was not declared in this scope
6 | f(i,1,n) cin>>a[i];
| ^
|
s320392472
|
p04031
|
C++
|
#include <bits/stdc++.h>
#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)
#define INF 1000000007
using ll = long long;
using namespace std;
typedef pair<int,int> P;
int main(){
int N;
int ave = 0,ans = 0;
cin >> N;
int a[200];
rep(i,N) cin >> a[i];
ave = accumulate(a,a+N);
ave = round((double)ave/N);
rep(i,N) ans += (a[i]-ave)*(a[i]-ave);
cout << ans;
//printf("%.15lf",ans);
cout << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:21: error: no matching function for call to 'accumulate(int [200], int*)'
21 | ave = accumulate(a,a+N);
| ~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/numeric:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
134 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
161 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate expects 4 arguments, 2 provided
|
s731570851
|
p04031
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n,a,mn,ans,as;
cin>>n;
vector<int>v;
while(n--)
{
cin>>a;
v.push_back(a);
}
sort(v.begin(),v.end());
for(int i=-1000;i<=1000;i++)
{
ans=0;
for(int j=0;j<v.size();j++)
{
ans=ans+((i-v[j])*(i-v[j]));
}
if(i==0)
{
mn=ans;
}2
else
{
mn=min(ans,mn);
}
}
cout<<mn<<endl;
}
|
a.cc: In function 'int main()':
a.cc:26:19: error: expected ';' before 'else'
26 | }2
| ^
| ;
27 |
28 | else
| ~~~~
|
s400417624
|
p04031
|
C
|
#include<bits/stdc++.h>
using namespace std;
int main ()
{
long long int sum= 0,count= 0;
int n,i;
cin >> n;
long long int ans = 1e18;
vector<int> arr(n);
for (i = 0 ; i<n ;i++)
{
cin >> arr[i];
sum += arr[i];
}
sum = sum /n;
for ( i = 0 ; i < n ;i++)
{
count += pow(arr[i]-sum,2);
}
ans = min (count,ans);
count = 0;
for ( i = 0 ; i < n ;i++)
{
count += pow(arr[i]-sum-1,2);
}
ans = min (count,ans);
count = 0;
for ( i = 0 ; i < n ;i++)
{
count += pow(arr[i]-sum+1,2);
}
ans = min (count,ans);
cout << ans <<endl;
}
|
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s849061821
|
p04031
|
C++
|
#include <bits/stdc++.h>
#define long long ll
using namespace std;
int main() {
init();
ll n,c=0,mi=INT_MAX;
cin>>n;
ll arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
for(int i=-100;i<=100;i++){
for(int o=0;o<n;o++){
c=pow(abs(i-arr[o]),2)+c;
}
mi=min(c,mi);
c=0;
}
cout<<mi;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:5:5: error: 'init' was not declared in this scope; did you mean 'int'?
5 | init();
| ^~~~
| int
a.cc:6:4: error: 'll' was not declared in this scope
6 | ll n,c=0,mi=INT_MAX;
| ^~
a.cc:7:9: error: 'n' was not declared in this scope; did you mean 'yn'?
7 | cin>>n;
| ^
| yn
a.cc:8:6: error: expected ';' before 'arr'
8 | ll arr[n];
| ^~~~
| ;
a.cc:10:10: error: 'arr' was not declared in this scope
10 | cin>>arr[i];
| ^~~
a.cc:13:9: error: 'c' was not declared in this scope
13 | c=pow(abs(i-arr[o]),2)+c;
| ^
a.cc:13:21: error: 'arr' was not declared in this scope
13 | c=pow(abs(i-arr[o]),2)+c;
| ^~~
a.cc:15:5: error: 'mi' was not declared in this scope; did you mean 'i'?
15 | mi=min(c,mi);
| ^~
| i
a.cc:15:12: error: 'c' was not declared in this scope
15 | mi=min(c,mi);
| ^
a.cc:18:10: error: 'mi' was not declared in this scope
18 | cout<<mi;
| ^~
|
s281067316
|
p04031
|
C++
|
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <list>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
int main(void)
{
int n;
cin >> n;
int a[n];
long long ans = 1000000000;
REP(i, n)
{
cin >> a[i];
}
for (int i = -100; i <= 100; i++)
{
long long tmp = 0;
REP(j, n)
{
tmp += (a[j] - i) * (a[j] - i);
}
ans = min(ans, tmp);
}
cout << ans << endl;
|
a.cc: In function 'int main()':
a.cc:44:25: error: expected '}' at end of input
44 | cout << ans << endl;
| ^
a.cc:26:1: note: to match this '{'
26 | {
| ^
|
s283855877
|
p04031
|
C++
|
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
/*CODE START HERE*/
int n, ans, p;
double sum;
int arr[105];
int main(){
ios::sync_with_stdio(0);
cin >> n;
sum = 0;
forn(i,n){
cin >> arr[i];
sum += arr[i];
}
sum = sum/n;
sum += 0.5;
p = (int)sum;
ans = 0;
forn(i,n){
ans += ( (arr[i]-p) * (arr[i]-p) );
}
int temp = 0;
forn(i,n){
temp += ( (arr[i]-p-1) * (arr[i]-p-1) );
}
ans = min(ans,temp);
int temp = 0;
forn(i,n){
temp += ( (arr[i]-p+1) * (arr[i]-p+1) );
}
ans = min(ans,temp);
cout << ans << "\n";
return 0;
}
|
a.cc: In function 'int main()':
a.cc:52:9: error: redeclaration of 'int temp'
52 | int temp = 0;
| ^~~~
a.cc:44:9: note: 'int temp' previously declared here
44 | int temp = 0;
| ^~~~
|
s194609507
|
p04031
|
C++
|
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
int a[n];
//int av=0;
for(int i=0;i<n;i++){
cin>>a[i];
}
int ans=1000000;
int sum=0;
for(int i=-100;i<=100;i++){//a
for(int j=0;j<n;j++){//an
sum+=(a[j]-i)*(a[j]-i);
}
if(sum<ans){
ans=sum;
sum=0;
}
}
cout<<ans;
|
a.cc: In function 'int main()':
a.cc:39:15: error: expected '}' at end of input
39 | cout<<ans;
| ^
a.cc:18:1: note: to match this '{'
18 | {
| ^
|
s060249459
|
p04031
|
C++
|
#include <iosream>
int main()
{
int N;
std::cin >> N;
int a[N];
int i;
int sum_a = 0;
int sum_aa = 0;
for (i = 0; i < N; i++) {
std::cin >> a[i];
sum_a += a[i];
sum_aa += a[i] * a[i];
}
int min = 40000;
for (i = -100; i <= 100; i++) {
int tmp = sum_aa - 2 * i * sum_a + N * i * i;
if (min > tmp) min = tmp;
}
std::cout << min;
return 0;
}
|
a.cc:1:10: fatal error: iosream: No such file or directory
1 | #include <iosream>
| ^~~~~~~~~
compilation terminated.
|
s276923814
|
p04031
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
int i;
int sum=0;
for(i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
float m=1.0;
m*=sum;
m/=n;
float x=m-floor(m);
if(x>=0.5)
{
int p=m+1;
int ans1=0;
for(i=0;i<n;i++)
ans+=pow(abs(a[i]-p),2);
// cout<<ans<<endl;
p=m;
int ans2=0;
for(i=0;i<n;i++)
ans+=pow(abs(a[i]-p),2);
cout<<min(ans1,ans2)<<endl;
}
else
{
int p=m+1;
int ans1=0;
for(i=0;i<n;i++)
ans+=pow(abs(a[i]-p),2);
// cout<<ans<<endl;
p=m;
int ans2=0;
for(i=0;i<n;i++)
ans+=pow(abs(a[i]-p),2);
cout<<min(ans1,ans2)<<endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:9: error: 'ans' was not declared in this scope; did you mean 'ans1'?
24 | ans+=pow(abs(a[i]-p),2);
| ^~~
| ans1
a.cc:29:9: error: 'ans' was not declared in this scope; did you mean 'ans2'?
29 | ans+=pow(abs(a[i]-p),2);
| ^~~
| ans2
a.cc:37:9: error: 'ans' was not declared in this scope; did you mean 'ans1'?
37 | ans+=pow(abs(a[i]-p),2);
| ^~~
| ans1
a.cc:42:9: error: 'ans' was not declared in this scope; did you mean 'ans2'?
42 | ans+=pow(abs(a[i]-p),2);
| ^~~
| ans2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.