submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s483375781
p03986
C++
#include<bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define int long long #define vec(a,n) vector<int> (a)((n)) #define Vec(a,n) vector<string> (a)((n)) using namespace std; signed main(){ string a; int s,ans=0; cin>>a; REP(i,n){ if(a[i] == 'S') s++; if(s!=0 && a[i] =='T'){ ans++; s--; } } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:19:15: error: 'n' was not declared in this scope 19 | REP(i,n){ | ^ a.cc:5:40: note: in definition of macro 'REP' 5 | #define REP(i, n) for (int i = 0; i < (n); ++i) | ^
s656909326
p03986
C++
#include<iostream> #include<ctype.h> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; inline int read(){ int x=0,f=0;char ch=getchar(); while(!isdigit(ch))f|=ch=='-',ch=getchar(); while(isdigit(ch))x=x*10+(ch^48),ch=getchar(); return f?-x:x; } string s; int er,ans; int main(){ cin>>s; int l=s.length(); for(int i=0;i<l;++i){ if(s[i]=='S')++er; if(s[i]=='T' && er>0)--er,ans++; } cout<<strlen(s)-ans-ans<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:22:22: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*' 22 | cout<<strlen(s)-ans-ans<<"\n"; | ^ | | | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/cstring:43, from a.cc:4: /usr/include/string.h:407:35: note: initializing argument 1 of 'size_t strlen(const char*)' 407 | extern size_t strlen (const char *__s) | ~~~~~~~~~~~~^~~
s210814375
p03986
C++
#include<cstdio> #include<stack> #include<iostream> #include<algorithm> using namespace std; #define MAXN 200000 stack <char> st; char str[MAXN + 5]; int main() { cin >> str; int len = strlen(str), Ans = 0; for (int i = 0; i < len; i++) if (str[i] == 'S') st.push('S'); else if (st.size() > 0) { Ans += 2; st.pop(); } cout << len - Ans; getchar(); getchar(); getchar(); }
a.cc: In function 'int main()': a.cc:11:19: error: 'strlen' was not declared in this scope 11 | int len = strlen(str), Ans = 0; | ^~~~~~ a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<algorithm> +++ |+#include <cstring> 5 | using namespace std; a.cc:15:25: error: 'Ans' was not declared in this scope 15 | Ans += 2; | ^~~ a.cc:18:23: error: 'Ans' was not declared in this scope 18 | cout << len - Ans; | ^~~
s645729270
p03986
C++
#include <cmath> #include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <map> #include <list> #include <time.h> #include <math.h> #include <random> #include <deque> #include <queue> #include <cassert> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <bitset> #include <sstream> using namespace std; typedef long long ll; mt19937 rnd(228); int main() { #ifdef ONPC freopen("a.in", "r", stdin); #endif ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; string t = ""; for (auto c : s) { if (c == "S") { t += c; } else { if (!t.empty() && t.back() == 'S') t.pop_back(); else t += c; } } cout << t << '\n'; }
a.cc: In function 'int main()': a.cc:39:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 39 | if (c == "S") | ~~^~~~~~
s177851250
p03986
C++
//#include <bits/stdc++.h> //#include <stdio.h> #include<iostream> #include<cstdio> #include<bitset> #include<algorithm> #include<vector> #include<list> #include<queue> #include<stack> #include<string> #include<string.h> #include<cmath> #include<utility> #include<functional> #include<map> #include<set> #include<cctype> #include<fstream> #include <numeric> #include <iomanip> #define FOR(i, a, b) for( int i=(a);i<=(b);i++) #define RFOR(i, a, b) for( int i=(a);i>=(b);i--) #define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++) #define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--) #define MOD 1000000007 using namespace std; using ll=long long; constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);} int main() { string N; int n=0; int nmax=0; int ans=0; cin >> N; for(int i=0;i<N.size;i++){ if(N[i]=='S'){ n++; if(n>nmax){nmax=n;} }else{ n--; } } cout << n*2<< endl; return 0; }
a.cc: In function 'int main()': a.cc:41:19: 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 '()' ?) 41 | for(int i=0;i<N.size;i++){ | ~~^~~~ | ()
s313739407
p03986
C++
#include<stdio.h> #include<iostream> #include<string> #include<math.h> #include<cmath> #include<algorithm> #include<map> #include<queue> #include<stack> #include<vector> #include<time.h> #include<ctime> #include<functional> #define int long long #define INT INT_MAX #define LONG LLONG_MAX #define f(i,n) for(int i=0;i<(n);i++) #define P pair<int,int> typedef long long ll; using namespace std; ll GCD(ll a, ll b) { if (b == 0)return a; return GCD(b, a%b); } ll LCM(ll a, ll b) { return a / GCD(a, b)*b; } ll mypow(ll a, ll b, ll c) { if (b == 0)return 1; if (b % 2)return mypow(a, b - 1, c)*a%c; else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c; } signed main() { string s; cin >> s; int x = 0, xx = 0, y = 0, yy = 0; f(i, s.size()) { if (s[i] == 'T') x++; else x--; xx=max(x,xx) } cout << xx * 2 << endl; getchar(); getchar(); return 0; }
a.cc: In function 'int main()': a.cc:44:29: error: expected ';' before '}' token 44 | xx=max(x,xx) | ^ | ; 45 | } | ~
s610890226
p03986
C++
#include<bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int mnx = 3e5 + 9; const int mod = 1e9 + 7; string x; ll cnt; int main(){ cin >> x; int ans = length(x), s = 0; for(int i=0; i<x.size(); i++) { if (x[i] == 'S') s++; else { if(s > 0) { ans -= 2; s--; } } } cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:15:11: error: 'length' was not declared in this scope 15 | int ans = length(x), s = 0; | ^~~~~~ a.cc:17:22: error: 's' was not declared in this scope 17 | if (x[i] == 'S') s++; | ^ a.cc:19:12: error: 's' was not declared in this scope 19 | if(s > 0) { | ^
s227941468
p03986
C++
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int a = (int)str.size(); int b = (int)str.size(); char ch[a+5]; for(int i = 0; i < (int)str.size(); ++i){ char ch[i] = str[i]; } for(int o; o<a+100; a++){ for(int i = 0;i < a; i++){ if(ch[i] == "S" && ch[i+1] == "T"){ for(int j; j < a;j++ ){ ch[i+j] = ch[i + j + 2]; } b = b-2; } } } cout << b << endl; }
a.cc: In function 'int main()': a.cc:12:25: error: array must be initialized with a brace-enclosed initializer 12 | char ch[i] = str[i]; | ^ a.cc:16:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 16 | if(ch[i] == "S" && ch[i+1] == "T"){ | ~~~~~~^~~~~~ a.cc:16:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 16 | if(ch[i] == "S" && ch[i+1] == "T"){ | ~~~~~~~~^~~~~~
s361302381
p03986
C++
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int a = (int)str.size(); int b = (int)str.size(); char ch[a+5] for(int i = 0; i < (int)str.size(); ++i){ char ch[i] = str[i]; } for(int o; o<a+100; a++){ for(int i = 0;i < a; i++){ if(ch[i] == "S" && ch[i+1] == "T"){ for(int j; j < a;j++ ){ ch[i+j] = ch[i + j + 2]; } b = b-2; } } } cout << b << endl; }
a.cc: In function 'int main()': a.cc:11:3: error: expected initializer before 'for' 11 | for(int i = 0; i < (int)str.size(); ++i){ | ^~~ a.cc:11:18: error: 'i' was not declared in this scope 11 | for(int i = 0; i < (int)str.size(); ++i){ | ^ a.cc:16:8: error: 'ch' was not declared in this scope 16 | if(ch[i] == "S" && ch[i+1] == "T"){ | ^~
s697000668
p03986
C++
#include<bits/stdc++.h> #include<string> using namespace std; int main(){ string str; cin >> str; for(int i=0;i!=200000;i++){ int a=str.find("ST"); if(a==-1){ break; } if(str.enpty()){ break; } str.erase(str.begin()+a,str.begin()+a+1); } cout << str.size() << endl; }
a.cc: In function 'int main()': a.cc:14:12: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'enpty'; did you mean 'empty'? 14 | if(str.enpty()){ | ^~~~~ | empty
s344932033
p03986
C++
#include<bits/stdc++.h> #include<string> using namespace std; int main(){ string str; cin >> str; for(int i=0;i!=100000){ int a=str.find("ST"); if(a==-1){ break; } str.erase(str.begin()+a,str.begin()+a+1); } cout << str.size() << endl; }
a.cc: In function 'int main()': a.cc:9:24: error: expected ';' before ')' token 9 | for(int i=0;i!=100000){ | ^ | ;
s595118638
p03986
C++
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int scnt=0,sum=0; for(int i=0;i<s.size();i++){ if(scnt>0&&s[i]=='T'){ scnt--; sum+=2; } if(s[i]=='S')scnt++; } cout<<s.size()-sum<<endl;j return 0; }
a.cc: In function 'int main()': a.cc:15:28: error: 'j' was not declared in this scope 15 | cout<<s.size()-sum<<endl;j | ^
s635034714
p03986
C++
#include <bits/stdc++.h> using namespace std; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { string s; cin>>s; int x = 0,ans = 0; rep(i,n){ if(s[i]=='S') x++; else x--; if(x<0) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:11: error: 'n' was not declared in this scope 12 | rep(i,n){ | ^ a.cc:4:40: note: in definition of macro 'rep' 4 | #define rep(i, n) for (int i = 0; i < (n); i++) | ^
s193130391
p03986
C++
#include <bits/stdc++.h> using namespace std; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { string s; cin>>s; bool a=true; while(a){ rep(i,s.size()-1) if(s[i]=='S'&&s[i+1]=='T'){ s.erase(s.begin()+i,s.begin()+i+2) a=false; break; } } cout << s.size() << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:51: error: expected ';' before 'a' 15 | s.erase(s.begin()+i,s.begin()+i+2) | ^ | ; 16 | a=false; | ~
s629146222
p03986
C++
#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; bool a=true; while(a){ rep(i,s.size()-1) if(s[i]=='S'&&s[i+1]=='T'){ s.erase(s.begin()+i,s.begin()+i+2) a=false; break; } } cout << s.size() << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:13: error: 'i' was not declared in this scope 10 | rep(i,s.size()-1) | ^ a.cc:10:9: error: 'rep' was not declared in this scope 10 | rep(i,s.size()-1) | ^~~
s216853620
p03986
C++
#include"stdafx.h" #include<iostream> #include<algorithm> #include<math.h> #include<cstdio> #include<ctype.h> #include<stdio.h> #include<set> #include<vector> #include<map> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<numeric> #include<string> using namespace std; typedef long long ll; ll dx[] = { 1,1,0,-1,-1,-1,0,1 }; ll dy[] = { 0,1,1,1,0,-1,-1,-1 }; ll prime(ll x) { ll i; if (x < 2)return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i*i <= x; i += 2) { if (x%i == 0) return 0; } return 1; } ll gcd(ll a, ll b) { if (a<b) { return gcd(b, a); } else if (a%b) { return gcd(b, a%b); } else { return b; } } ll MOD = 1000000007; int main() { string X; cin>>X; ll x=0,y=0; for(ll i=0; i<X.size(); i++){ if(X[i]=='S')x++; else x--,y++; } cout<<X.size()-y*2<<endl; }
a.cc:1:9: fatal error: stdafx.h: No such file or directory 1 | #include"stdafx.h" | ^~~~~~~~~~ compilation terminated.
s881508448
p03986
C++
#include<iostream> #include<algorithm> #include<math.h> #include<cstdio> #include<ctype.h> #include<stdio.h> #include<set> #include<vector> #include<map> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<numeric> #include<string> typedef long long ll; ll dx[] = { 1,1,0,-1,-1,-1,0,1 }; ll dy[] = { 0,1,1,1,0,-1,-1,-1 }; ll prime(ll x) { ll i; if (x < 2)return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i*i <= x; i += 2) { if (x%i == 0) return 0; } return 1; } ll gcd(ll a, ll b) { if (a<b) { return gcd(b, a); } else if (a%b) { return gcd(b, a%b); } else { return b; } } ll MOD = 1000000007; int main() { string X; cin>>X; ll x=0,y=0; for(ll i=0; i<X.size(); i++){ if(X[i]=='S')x++; else x--,y++; } cout<<X.size()-y*2<<endl; }
a.cc: In function 'int main()': a.cc:38:9: error: 'string' was not declared in this scope 38 | string X; | ^~~~~~ a.cc:38:9: 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:39:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 39 | cin>>X; | ^~~ | std::cin /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:39:14: error: 'X' was not declared in this scope 39 | cin>>X; | ^ a.cc:45:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 45 | cout<<X.size()-y*2<<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:45:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 45 | cout<<X.size()-y*2<<endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s469805181
p03986
C++
#include<iostream> #include<algorithm> #include<math.h> #include<cstdio> #include<ctype.h> #include<stdio.h> #include<set> #include<vector> #include<map> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<numeric> #include<string> ll dx[] = { 1,1,0,-1,-1,-1,0,1 }; ll dy[] = { 0,1,1,1,0,-1,-1,-1 }; ll prime(ll x) { ll i; if (x < 2)return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i*i <= x; i += 2) { if (x%i == 0) return 0; } return 1; } ll gcd(ll a, ll b) { if (a<b) { return gcd(b, a); } else if (a%b) { return gcd(b, a%b); } else { return b; } } ll MOD = 1000000007; int main() { string X; cin>>X; ll x=0,y=0; for(ll i=0; i<X.size(); i++){ if(X[i]=='S')x++; else x--,y++; } cout<<X.size()-y*2<<endl; }
a.cc:17:1: error: 'll' does not name a type 17 | ll dx[] = { 1,1,0,-1,-1,-1,0,1 }; | ^~ a.cc:18:1: error: 'll' does not name a type 18 | ll dy[] = { 0,1,1,1,0,-1,-1,-1 }; | ^~ a.cc:19:1: error: 'll' does not name a type 19 | ll prime(ll x) { | ^~ a.cc:29:1: error: 'll' does not name a type 29 | ll gcd(ll a, ll b) { | ^~ a.cc:35:1: error: 'll' does not name a type 35 | ll MOD = 1000000007; | ^~ a.cc: In function 'int main()': a.cc:37:9: error: 'string' was not declared in this scope 37 | string X; | ^~~~~~ a.cc:37:9: 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:38:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 38 | cin>>X; | ^~~ | std::cin /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:38:14: error: 'X' was not declared in this scope 38 | cin>>X; | ^ a.cc:39:9: error: 'll' was not declared in this scope 39 | ll x=0,y=0; | ^~ a.cc:40:15: error: expected ';' before 'i' 40 | for(ll i=0; i<X.size(); i++){ | ^~ | ; a.cc:40:21: error: 'i' was not declared in this scope 40 | for(ll i=0; i<X.size(); i++){ | ^ a.cc:41:20: error: 'x' was not declared in this scope 41 | if(X[i]=='S')x++; | ^ a.cc:42:12: error: 'x' was not declared in this scope 42 | else x--,y++; | ^ a.cc:42:16: error: 'y' was not declared in this scope; did you mean 'yn'? 42 | else x--,y++; | ^ | yn a.cc:44:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 44 | cout<<X.size()-y*2<<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:44:18: error: 'y' was not declared in this scope; did you mean 'yn'? 44 | cout<<X.size()-y*2<<endl; | ^ | yn a.cc:44:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 44 | cout<<X.size()-y*2<<endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s838536491
p03986
C++
#include<iostream> #include<string> #include<algorithm> #include<cmath> #include<iomanip> #include<cstring> #include<map> #include<vector> #include<queue> #include<stack> #include<climits> #include<set> #include<utility> using namespace std; typedef long long int ll; typedef pair<int, int> P; const ll MOD=1e9+7; int main(){ stack<> s; string x; cin >> x; for(int i=0; i<x.size(); i++){ if(x[i]=='S'){ s.push(1); } else { if(s.top()!=1 || s.empty()){ s.push(0); } else if(s.top()=='S'){ s.pop(); } } } cout << s.size() << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:15: error: wrong number of template arguments (0, should be at least 1) 21 | stack<> s; | ^ In file included from /usr/include/c++/14/stack:63, from a.cc:10: /usr/include/c++/14/bits/stl_stack.h:99:11: note: provided for 'template<class _Tp, class _Sequence> class std::stack' 99 | class stack | ^~~~~ a.cc:26:27: error: request for member 'push' in 's', which is of non-class type 'int' 26 | s.push(1); | ^~~~ a.cc:28:30: error: request for member 'top' in 's', which is of non-class type 'int' 28 | if(s.top()!=1 || s.empty()){ | ^~~ a.cc:28:44: error: request for member 'empty' in 's', which is of non-class type 'int' 28 | if(s.top()!=1 || s.empty()){ | ^~~~~ a.cc:29:35: error: request for member 'push' in 's', which is of non-class type 'int' 29 | s.push(0); | ^~~~ a.cc:30:37: error: request for member 'top' in 's', which is of non-class type 'int' 30 | } else if(s.top()=='S'){ | ^~~ a.cc:31:35: error: request for member 'pop' in 's', which is of non-class type 'int' 31 | s.pop(); | ^~~ a.cc:35:19: error: request for member 'size' in 's', which is of non-class type 'int' 35 | cout << s.size() << endl; | ^~~~
s811177806
p03986
C++
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; for(int i=0;i<s.size();i++){ if(s[i]=='S'&&s[i+1]=='T'){ s=s.substr(0,i)+s.substr(i+2,s.size()-i-2); i=-1; } } else cout<<s.size()<<endl; return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: 'else' without a previous 'if' 12 | else cout<<s.size()<<endl; | ^~~~
s251484164
p03986
C++
#include<iostream> using namespace std; int main(){ int s,t,i,length,count; string N; s = 0; t = 0; count = 0; cin >> N; length = N.size(); for(i=0;i<length;i++){ if(N[i] == 'S'){ s++; if(s-t=>0) count++; } else{ t++; if(s-t=>0) count++; } } cout << length-2*count << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:14:14: error: expected primary-expression before '>' token 14 | if(s-t=>0) | ^ a.cc:19:14: error: expected primary-expression before '>' token 19 | if(s-t=>0) | ^
s147864027
p03986
C++
#include<iostream> using namespace std; int main(){ int s,t,i,length,count; string N; s = 0; t = 0; count = 0; cin >> N; length = N.size(); for(i=0;i<length;i++){ if(N[i] == 'S'){ S++; if(S-T=>0) count++; } else{ T++; if(S-T=>0) count++; } } cout << length-2*count << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:13:7: error: 'S' was not declared in this scope 13 | S++; | ^ a.cc:14:12: error: 'T' was not declared in this scope 14 | if(S-T=>0) | ^ a.cc:14:14: error: expected primary-expression before '>' token 14 | if(S-T=>0) | ^ a.cc:18:7: error: 'T' was not declared in this scope 18 | T++; | ^ a.cc:19:10: error: 'S' was not declared in this scope 19 | if(S-T=>0) | ^ a.cc:19:14: error: expected primary-expression before '>' token 19 | if(S-T=>0) | ^
s452099031
p03986
C++
using System; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; namespace Solution { class Solution { static void Main(string[] args) { string s = System.Console.ReadLine(); for(int i = 0; i < 100000; i++) { s = Regex.Replace(s, "ST", string.Empty); } System.Console.WriteLine(s.Length); } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Linq; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Collections.Generic; | ^~~~~~ a.cc:4:7: error: expected nested-name-specifier before 'System' 4 | using System.Text.RegularExpressions; | ^~~~~~ a.cc:9:26: error: 'string' has not been declared 9 | static void Main(string[] args) | ^~~~~~ a.cc:9:35: error: expected ',' or '...' before 'args' 9 | static void Main(string[] args) | ^~~~ a.cc:19:6: error: expected ';' after class definition 19 | } | ^ | ; a.cc: In static member function 'static void Solution::Solution::Main(int*)': a.cc:11:13: error: 'string' was not declared in this scope 11 | string s = System.Console.ReadLine(); | ^~~~~~ a.cc:14:17: error: 's' was not declared in this scope 14 | s = Regex.Replace(s, "ST", string.Empty); | ^ a.cc:14:21: error: 'Regex' was not declared in this scope 14 | s = Regex.Replace(s, "ST", string.Empty); | ^~~~~ a.cc:16:13: error: 'System' was not declared in this scope 16 | System.Console.WriteLine(s.Length); | ^~~~~~ a.cc:16:38: error: 's' was not declared in this scope 16 | System.Console.WriteLine(s.Length); | ^
s894596681
p03986
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i) #define REP(i,n) FOR(i,0,n) int main() { string s; cin >> s; stack<char> S; REP(i,s.size()) { if (s[i] == 'S') S.push(s[i]); else { if (S.back() == 'S') S.pop(); else S.push(s[i]); } } cout << S.size() << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:13: error: 'class std::stack<char>' has no member named 'back' 13 | if (S.back() == 'S') S.pop(); | ^~~~
s664550662
p03986
C++
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; stack<char> S; REP(i,s.size()) { if (s[i] == 'S') S.push(s[i]); else { if (S.back() == 'S') S.pop(); else S.push(s[i]); } } cout << S.size() << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:7: error: 'i' was not declared in this scope 7 | REP(i,s.size()) { | ^ a.cc:7:3: error: 'REP' was not declared in this scope 7 | REP(i,s.size()) { | ^~~
s823409043
p03986
C++
#include <iostream> #include<algorithm> #include<stdio.h> #include<stdlib.h> #include <string.h> #include<cmath> using namespace std; int ss[1000008]= {0}; int main() { char s[1000008]= {0}; int i,j,x,n,r=0; scanf("%s",s); for(i=0,j=0; s[i]!=0; i++) { if(s[i]=='S') { ss[j]=i; j++; } } while(777) { r=0; int p=0 for(i=ss[p]; ss[p]!=0; p++) { int f=1; if(s[i]=='S') { int k=i; for(j=i+1;; j++) { if(s[j]==0) { f=0; break; } if(s[j]=='0')continue; if(s[j]=='T')break; if(s[j]=='S') { f=0; break; } } if(f) { s[k]='0'; s[j]='0'; r++; } } } if(!r)break; } r=0; for(i=0; s[i]!=0; i++)if(s[i]!='0')r++; printf("%d\n",r); return 0; }
a.cc: In function 'int main()': a.cc:26:15: error: expected ',' or ';' before 'for' 26 | for(i=ss[p]; ss[p]!=0; p++) | ^~~ a.cc:26:41: error: expected ';' before ')' token 26 | for(i=ss[p]; ss[p]!=0; p++) | ^ | ;
s975865685
p03986
Java
import java.util.*; public class AGC05a{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); sc.close(); Deque<Character> deq = new ArrayDeque<Character>(); int count = 0; for(int i = 0; i < str.length(); i++){ if(str.charAt(i) == 'S'){ deq.push('e'); }else{ Character temp = deq.poll(); if(temp == null){ count++; } } } System.out.println(count + deq.size()); } }
Main.java:2: error: class AGC05a is public, should be declared in a file named AGC05a.java public class AGC05a{ ^ 1 error
s492421228
p03986
C++
def finalLength(sample): foo = len(sample) tmp = 0 for c in sample: if c=='S': tmp += 1 elif tmp>0: tmp -= 1 foo -= 2 return foo def main(): sample = raw_input().strip() print finalLength(sample) if __name__ == '__main__': main()
a.cc:16:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 16 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'def' does not name a type 1 | def finalLength(sample): | ^~~
s001674034
p03986
C++
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define rc(x) return cout<<x<<endl,0 #define pb push_back #define in insert #define er erase #define fr first #define sc second using namespace std; typedef long long ll; const long long llnrm=LLONG_MAX; const int nrm=INT_MAX; const int nrn=INT_MIN; const int nmax=1e5+5; const int mod=1e9+7; const long long llim=1e18; const int lim=1e8; int ans,a[101]; string s; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); // freopen("solution.in","r",stdin); //freopen("solution.out","w",stdout); cin>>s; len=s.size(); for(int i=0;i<s.size()-1;i++) { if(s[i]=='S' && s[i+1]=='T') { s.erase(i,2); i-=2; len-=2; } } cout<<len<<endl; return 0; }
a.cc: In function 'int main()': a.cc:26:9: error: 'len' was not declared in this scope 26 | len=s.size(); | ^~~
s812983623
p03986
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <iostream> #include <fstream> #include <string> #include <cmath> #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <queue> #include <deque> #include <functional> char x[200005]; int main(void) { char input; int i = 0; while (1) { scanf("%c", &input); if (input == '\n') { x[i] = '\0'; break; } x[i] = input; if (input == 'T') { if (i > 0 && x[i - 1] == 'S') { i -= 2; } } i++; } printf("%d\n", strlen(x)); return 0; }
main.c:2:10: fatal error: iostream: No such file or directory 2 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s483964541
p03986
C++
#include <iostream> #include <algorithm> #include <string> #include <stack> using namespace std; int main() { string s; cin >> s; stack<char> st; for (auto x : s) { if (x == 'S') st.push(x); else if (st.top() == x) st.push(); st.pop(); } cout << st.size(); return 0; }
a.cc: In function 'int main()': a.cc:15:40: error: no matching function for call to 'std::stack<char>::push()' 15 | else if (st.top() == x) st.push(); | ~~~~~~~^~ In file included from /usr/include/c++/14/stack:63, from a.cc:4: /usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = char; _Sequence = std::deque<char, std::allocator<char> >; value_type = char]' 258 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = char; _Sequence = std::deque<char, std::allocator<char> >; value_type = char]' 263 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate expects 1 argument, 0 provided
s683814295
p03986
C++
#include<iostream> #include<string> using namespace std; int main(){ string str; cin>>str; for(int i=0;i<str.size()-1;i++){ if(str[i]=='S'&&str[i+1]=='T'){ flag=0; str=str.substr(0,i)+str.substr(i+2,str.size()-i-1); i--; } if(str.size()==0||str.size()==1){ flag=1; break; } } cout<<str.size()<<endl; return 0; }
a.cc: In function 'int main()': a.cc:9:7: error: 'flag' was not declared in this scope 9 | flag=0; | ^~~~ a.cc:14:7: error: 'flag' was not declared in this scope 14 | flag=1; | ^~~~
s303582813
p03986
C++
X = input() i = 0 while i < len(X): # print(i) while i + 1 < len(X) and X[i:i+2] != 'ST': i += 1 if i + 1 >= len(X): break X = X[:i] + X[i+2:] i -= 1 print(len(X))
a.cc:5:7: error: invalid preprocessing directive #print 5 | # print(i) | ^~~~~ a.cc:6:42: warning: multi-character character constant [-Wmultichar] 6 | while i + 1 < len(X) and X[i:i+2] != 'ST': | ^~~~ a.cc:1:1: error: 'X' does not name a type 1 | X = input() | ^
s622365607
p03986
Java
package agc0.agc005; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class MainA { public static void main(String[] args) throws IOException { BufferedReader input =new BufferedReader (new InputStreamReader (System.in)); String str = input.readLine( ); while(str.contains("ST")){ str = str.replace("ST", ""); } System.out.println(str.length()); } }
Main.java:7: error: class MainA is public, should be declared in a file named MainA.java public class MainA { ^ 1 error
s968722221
p03986
C++
5 aabac 3 1 a 1 b 1 c
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s139585743
p03986
C++
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { string s; cin >> s; int minx = INT_MAX, x = 0; for (int i = 0; i < s.size(); i++){ if (s[i] == 'T')x--; else x++; minx = min(minx, x); } cout << minx << endl; }
a.cc: In function 'int main()': a.cc:7:20: error: 'INT_MAX' was not declared in this scope 7 | int minx = INT_MAX, x = 0; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include<algorithm> +++ |+#include <climits> 4 | using namespace std; a.cc:9:33: error: 'x' was not declared in this scope 9 | if (s[i] == 'T')x--; else x++; | ^ a.cc:9:43: error: 'x' was not declared in this scope 9 | if (s[i] == 'T')x--; else x++; | ^ a.cc:10:34: error: 'x' was not declared in this scope 10 | minx = min(minx, x); | ^
s012794313
p03986
C++
#include <stack> #include <cstdio> #include <vector> char x[1<<19]; int solve(void) { std::stack<char> st; int len = strlen(x); for(int i = 0; i < len; i++) { if(x[i] == 'S') st.push(x[i]); else if(x[i] == 'T' && (st.empty() || st.top() == 'T') st.push(x[i]); else st.pop(); } return st.size(); } int main(void) { fgets(x, 1 << 19, stdin); printf("%d", solve()); return 0; }
a.cc: In function 'int solve()': a.cc:7:15: error: 'strlen' was not declared in this scope 7 | int len = strlen(x); | ^~~~~~ a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <vector> +++ |+#include <cstring> 4 | char x[1<<19]; a.cc:10:63: error: expected ';' before 'st' 10 | else if(x[i] == 'T' && (st.empty() || st.top() == 'T') st.push(x[i]); | ^~~ | ; a.cc:11:9: error: expected primary-expression before 'else' 11 | else st.pop(); | ^~~~ a.cc:10:78: error: expected ')' before 'else' 10 | else if(x[i] == 'T' && (st.empty() || st.top() == 'T') st.push(x[i]); | ~ ^ | ) 11 | else st.pop(); | ~~~~
s917849437
p03986
C
#include <stack> #include <cstdio> #include <vector> char x[1<<19]; int solve(void) { std::stack<char> st; int len = strlen(x); for(int i = 0; i < len; i++) { if(x[i] == 'S') st.push(x[i]); else if(x[i] == 'T' && (st.empty() || st.top() == 'T') st.push(x[i]); else st.pop(); } return st.size(); } int main(void) { fgets(x, 1 << 19, stdin); printf("%d", solve()); return 0; }
main.c:1:10: fatal error: stack: No such file or directory 1 | #include <stack> | ^~~~~~~ compilation terminated.
s828056811
p03986
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #define LL long long #define RG register using namespace std; #define N 800000 inline int gi() { RG int w=0; RG bool q=1; RG char c=getchar(); while ((c<'0'||c>'9') && c!='-') c=getchar(); if (c=='-') q=0,c=getchar(); while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar(); return q? w:-w; } #define mod 924844033 int n,fac[N],inv[N]; int head[N],next[N<<1],to[N<<1],siz[N]; int ans[N],s[N]; int q[N],fa[N],pre[N]; #define dec(x,y) if (((x)-=(y))<0) (x)+=mod inline int qpow(int x,int y) { int ans=1; while (y) { if (y&1) ans=1LL*ans*x%mod; x=1LL*x*x%mod;y>>=1; } return ans; } namespace NTT{ int a[N],b[N],c[N],d[N],R[N],ans[N]; struct C{ long double x,y; }A[N],B[N]; inline C operator + (const C &a,const C &b) { return (C){a.x+b.x,a.y+b.y}; } inline C operator - (const C &a,const C &b) { return (C){a.x-b.x,a.y-b.y}; } inline C operator * (const C &a,const C &b) { return (C){a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x}; } const long double pi=acos(-1); inline void fft(int n,C *a,int f) { int i,k,o;C wn,w,x,y; for (i=0;i<n;i++) if (R[i]>i) swap(a[i],a[R[i]]); for (i=1;i<n;i<<=1) { wn=(C){cos(pi/i),sin(f*pi/i)}; for (o=0;o<n;o+=i<<1) { w=(C){1,0}; for (k=0;k<i;k++,w=w*wn) { x=a[o+k],y=a[o+k+i]*w; a[o+k]=x+y; a[o+k+i]=x-y; } } } } inline void work(int m) { int n,L=-1,i;LL x; for (n=1;n<=m<<1;n<<=1) L++; for (i=1;i<n;i++) R[i]=R[i>>1]>>1|(i&1)<<L; for (i=0;i<=m;i++) c[i]=a[i]&32767,a[i]>>=15,d[i]=b[i]&32767,b[i]>>=15; for (i=0;i<n;i++) A[i]=(C){(double)c[i],0},B[i]=(C){(double)d[i],0}; fft(n,A,1); fft(n,B,1); for (i=0;i<n;i++) A[i]=A[i]*B[i]; fft(n,A,-1); for (i=m<<1;i>m;i--) { x=A[i].x/n+0.5; ans[i]=(x%=mod); dec(ans[i],(x<<15)%mod); } for (i=0;i<n;i++) A[i]=(C){(double)a[i],0},B[i]=(C){(double)b[i],0}; fft(n,A,1); fft(n,B,1); for (i=0;i<n;i++) A[i]=A[i]*B[i]; fft(n,A,-1); for (i=m<<1;i>m;i--) { x=A[i].x/n+0.5; ans[i]=(ans[i]+(((x%mod)<<15%mod)<<15)-(x<<15))%mod; } for (i=0;i<n;i++) A[i]=(C){(double)a[i]+c[i],0},B[i]=(C){(double)b[i]+d[i],0}; fft(n,A,1); fft(n,B,1); for (i=0;i<n;i++) A[i]=A[i]*B[i]; fft(n,A,-1); for (i=m<<1;i>m;i--) { x=A[i].x/n+0.5; ans[i]=(ans[i]+((x%mod)<<15))%mod; } } } int main() { int n=gi(),i,j,a,b,tot=0,l,r,k; for (i=1;i<n;i++) { a=gi(),b=gi(); to[++tot]=b,next[tot]=head[a],head[a]=tot; to[++tot]=a,next[tot]=head[b],head[b]=tot; } for (i=fac[0]=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod; inv[n]=qpow(fac[n],mod-2); for (i=n;i;i--) inv[i-1]=1LL*inv[i]*i%mod; for (i=1;i<=n;i++) ans[i]=fac[n]*(inv[n-1-i]+1LL*inv[n-i]*i%mod)%mod; for (l=0,q[r=1]=1;l!=r;) for (i=head[k=q[++l]];i;i=next[i]) if (to[i]!=fa[k]) fa[q[++r]=to[i]]=k; for (s[i=n]--;i;i--) s[++siz[k=q[i]]]++,siz[fa[k]]+=siz[k],s[n-siz[k]]++; for (i=0,j=n;i<=n;i++,j--) NTT::b[i]=inv[j],NTT::a[i]=1LL*fac[i]*s[i]%mod; NTT::work(n); for (i=1;i<=n;i++) if ((ans[i]-=NTT::ans[i+n])<0) ans[i]+=mod; for (i=1;i<=n;i++) printf("%d\n",int(1LL*ans[i]*inv[i]%mod)); return 0; }
a.cc: In function 'int gi()': a.cc:11:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 11 | RG int w=0; | ^ a.cc:12:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 12 | RG bool q=1; | ^ a.cc:13:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 13 | RG char c=getchar(); | ^ a.cc: In function 'int main()': a.cc:97:29: error: reference to 'next' is ambiguous 97 | to[++tot]=b,next[tot]=head[a],head[a]=tot; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:21:13: note: 'int next [1600000]' 21 | int head[N],next[N<<1],to[N<<1],siz[N]; | ^~~~ a.cc:98:29: error: reference to 'next' is ambiguous 98 | to[++tot]=a,next[tot]=head[b],head[b]=tot; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:21:13: note: 'int next [1600000]' 21 | int head[N],next[N<<1],to[N<<1],siz[N]; | ^~~~ a.cc:104:60: error: reference to 'next' is ambiguous 104 | for (l=0,q[r=1]=1;l!=r;) for (i=head[k=q[++l]];i;i=next[i]) if (to[i]!=fa[k]) fa[q[++r]=to[i]]=k; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:21:13: note: 'int next [1600000]' 21 | int head[N],next[N<<1],to[N<<1],siz[N]; | ^~~~
s747305713
p03986
C++
1 #include<bits/stdc++.h> 2 3 4 #define sz(a) int((a).size()) 5 #define pb push_back 6 7 #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 8 #define present(c,x) ((c).find(x) != (c).end()) 9 #define cpresent(c,x) (find(all(c),x) != (c).end()) 10 using namespace std; 11 12 typedef long long ll; 13 14 int main() 15 { 16 string s; 17 cin>>s; 18 19 int l=s.length(); 20 int i=0; 21 while(i!=l-1) 22 { 23 if(s[i]=='S'&&s[i+1]=='T') 24 { 25 s.erase(i,2); 26 i--; 27 } 28 else 29 i++; 30 31 } 32 cout<<s.length(); 33 }
a.cc:1:5: error: stray '#' in program 1 | 1 #include<bits/stdc++.h> | ^ a.cc:4:6: error: stray '#' in program 4 | 4 #define sz(a) int((a).size()) | ^ a.cc:5:6: error: stray '#' in program 5 | 5 #define pb push_back | ^ a.cc:7:6: error: stray '#' in program 7 | 7 #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) | ^ a.cc:8:6: error: stray '#' in program 8 | 8 #define present(c,x) ((c).find(x) != (c).end()) | ^ a.cc:9:6: error: stray '#' in program 9 | 9 #define cpresent(c,x) (find(all(c),x) != (c).end()) | ^ a.cc:1:3: error: expected unqualified-id before numeric constant 1 | 1 #include<bits/stdc++.h> | ^ a.cc:7:62: error: 'i' does not name a type 7 | 7 #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) | ^ a.cc:7:78: error: 'i' does not name a type 7 | 7 #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) | ^ a.cc:11:2: error: expected unqualified-id before numeric constant 11 | 11 | ^~ a.cc:13:2: error: expected unqualified-id before numeric constant 13 | 13 | ^~
s744632805
p03986
C++
#include <iostream> #include <stack> #include <string> using namespace std; void PRF(string T, int f[]){ int m = T.length(); int k; f[0] = -1; for(int i = 1; i<m; i++){ k=f[i-1]; while(k>=0){ if(T[k] == T[i-1]){ break; } else{ k = f[k]; } } f[i] = k+1; } } void KMP(string T, string String){ bool fnd = false; int Tl = T.length(); int Sl = String.length(); int tmp[Tl]; PRF(T, tmp); int i=0; int k=0; while(i<Sl){ if(k==-1){ i++; k=0; } else if(String[i]==T[k]){ i++; k++; if(k==Tl){ fnd=true; for(int j=i; i<i-Tl; i--){ String.pop(); } } } else{ k = tmp[k]; } } while(fnd){ KMP(T, String); } cout<<String.length(); } int main() { string String, T; cin>>String; T="ST"; KMP(T, String); }
a.cc: In function 'void KMP(std::string, std::string)': a.cc:45:48: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pop' 45 | String.pop(); | ^~~
s466946058
p03986
C++
#include <iostream> #include <stack> #include <string> using namespace std; void prefixKMP(string T, int f[]){ int m = T.length(); int k; f[0] = -1; for(int i = 1; i<m; i++){ k=f[i-1]; while(k>=0){ if(T[k] == T[i-1]){ break; } else{ k = f[k]; } } f[i] = k+1; } } void KMPcheck(string T, string S){ bool fnd = false; string z; int m = T.length(); int n = S.length(); int tmp[m]; int z = 0; prefixKMP(T, tmp); int i=0; int k=0; while(i<n){ if(k==-1){ i++; k=0; } else if(S[i]==T[k]){ i++; k++; if(k==m){ fnd=true; for(int j=i; i<i-m; i--){ S.pop(); } } } else{ k = tmp[k]; } } while(fnd){ KMPcheck(T, S); } cout<<S.length(); } int main() { string S, T; cin>>S; for(int i=0;i<F.length(), i++){ S[i]=F[i]; } T="ST"; KMPcheck(T, S); }
a.cc: In function 'void KMPcheck(std::string, std::string)': a.cc:29:9: error: conflicting declaration 'int z' 29 | int z = 0; | ^ a.cc:25:16: note: previous declaration as 'std::string z' 25 | string z; | ^ a.cc:46:43: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pop' 46 | S.pop(); | ^~~ a.cc: In function 'int main()': a.cc:64:15: error: 'F' was not declared in this scope 64 | for(int i=0;i<F.length(), i++){ | ^ a.cc:64:30: error: expected ';' before ')' token 64 | for(int i=0;i<F.length(), i++){ | ^ | ;
s788008456
p03986
C++
s = gets.chomp countS = 0 count = s.length s.each_char do |e| countS += 1 if e == "S" if(e == "T" and countS > 0) count -= 2 countS -= 1 end end puts count
a.cc:1:1: error: 's' does not name a type 1 | s = gets.chomp | ^
s205907469
p03986
C++
#include <bits/stdc++.h> using namespace std; #define ll long long string x; int main(){ cin >> x; ll pos = 0; ll ans = 0; while(1){ if(x == "ST"){ cout << 0 << endl; return 0; } while(pos + 1 < x.length() && x.substr(pos,2) != "ST"){ pos++; } if(pos + 1 == x.length()){ cout << x.length() << endl; return 0; }else{ cout << "newstring: " << newstring << endl; x = newstring; pos--; } } }
a.cc: In function 'int main()': a.cc:23:32: error: 'newstring' was not declared in this scope 23 | cout << "newstring: " << newstring << endl; | ^~~~~~~~~
s283851136
p03986
C++
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific #include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline #include <vector> using namespace std; int main(void) { string x; cin >> x; ul n = x.size(); vector<bool> b; b.push_back(x[0] == 'S'); for (int i = 1; i < n; ++i) { if (x[i] == 'T') { if(b.back()) b.erase(b.end() - 1); else b.push_back(false); } else { b.push_back(true); } } cout << b.size() << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:9: error: 'ul' was not declared in this scope 10 | ul n = x.size(); | ^~ a.cc:14:29: error: 'n' was not declared in this scope 14 | for (int i = 1; i < n; ++i) | ^
s722022984
p03986
C++
#include <iostream> #include <string> #include <stack> #include <stdin.h> using namespace std; int main(){ char* x; cin >> x; string st = "ST"; // スタックを準備する stack<char> stack; for (int i = 0; i < strlen(x); i++){ if (x[i] == 'T') { if(stack.top() == 'S'){ stack.pop(); } else { stack.push(x[i]); } } else { stack.push(x[i]); } } }
a.cc:4:10: fatal error: stdin.h: No such file or directory 4 | #include <stdin.h> | ^~~~~~~~~ compilation terminated.
s418865388
p03986
C++
#include <iostream> #include <string> #include <stack> using namespace std; int main(){ char* x; cin >> x; string st = "ST"; // スタックを準備する stack<char> stack; for (int i = 0; i < strlen(x); i++){ if (x[i] == 'T') { if(stack.top() == 'S'){ stack.pop(); } else { stack.push(x[i]); } } else { stack.push(x[i]); } } }
a.cc: In function 'int main()': a.cc:14:23: error: 'strlen' was not declared in this scope 14 | for (int i = 0; i < strlen(x); i++){ | ^~~~~~ a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <stack> +++ |+#include <cstring> 4 |
s279772918
p03986
C++
// TEMPLATES ----------------------------------------------------------------------------------------------------------- #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> using namespace std; // types typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; // utils #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) // constants const int INF = INT_MAX / 3; // MAIN ---------------------------------------------------------------------------------------------------------------- int main() { cin.tie(0); ios::sync_with_stdio(false); string str; cin >> str; // while (cin >> a) {} stack<char> s; for (auto c : str) { if (c == 'S') { s.push(c); } else { if (!s.empty() && s.top() == 'S') { s.pop(); } else { s.push(c); } } } cout << s.size() << endl; return 0; }
a.cc:41:17: error: 'INT_MAX' was not declared in this scope 41 | const int INF = INT_MAX / 3; | ^~~~~~~ a.cc:24:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 23 | #include <ctime> +++ |+#include <climits> 24 |
s498414192
p03986
C++
cin.tie(0); ios::sync_with_stdio(false); string str; cin >> str; // while (cin >> a) {} stack<char> s; for (auto c : str) { if (c == 'S') { s.push(c); } else { if (!s.empty() && s.top() == 'S') { s.pop(); } else { s.push(c); } } } cout << s.size() << endl;
a.cc:1:5: error: 'cin' does not name a type 1 | cin.tie(0); | ^~~ a.cc:2:5: error: 'ios' does not name a type 2 | ios::sync_with_stdio(false); | ^~~ a.cc:4:5: error: 'string' does not name a type 4 | string str; | ^~~~~~ a.cc:5:5: error: 'cin' does not name a type 5 | cin >> str; | ^~~ a.cc:9:5: error: 'stack' does not name a type 9 | stack<char> s; | ^~~~~ a.cc:11:5: error: expected unqualified-id before 'for' 11 | for (auto c : str) { | ^~~ a.cc:23:5: error: 'cout' does not name a type 23 | cout << s.size() << endl; | ^~~~
s905937749
p03986
C++
#include<iostream> #include<algorithm> using namespace std; string x; int s,t,i; main() { cin>>x; for(i=0;i;x.size();i++){ if(x[i]=='T') t++; else s++; } cout<<max(s,t)*2<<endl; }
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~ a.cc: In function 'int main()': a.cc:9:21: warning: ignoring return value of '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]', declared with attribute 'nodiscard' [-Wunused-result] 9 | for(i=0;i;x.size();i++){ | ~~~~~~^~ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/basic_string.h:1076:7: note: declared here 1076 | size() const _GLIBCXX_NOEXCEPT | ^~~~ a.cc:9:23: error: expected ')' before ';' token 9 | for(i=0;i;x.size();i++){ | ~ ^ | ) a.cc:9:27: error: expected ';' before ')' token 9 | for(i=0;i;x.size();i++){ | ^ | ;
s222161222
p03986
C++
#include<bits/stdc++.h> using namespace std; char s[200005]; int n; int solve(int i, int j){ if (j == n)return 0; if (s[i] == 'S' && s[j] == 'T'){ if (i > 0){ return solve(i - 1, j + 1) + 2; } return solve(j + 1, j + 2) + 2; } return solve(i + 1, j + 1); } int main(){ gets(s); n = strlen(s); cout << (n - solve(0, 1))<<endl; return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 17 | gets(s); | ^~~~ | getw
s184272232
p03986
C
r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2);
main.c:1:1: warning: data definition has no type or storage class 1 | r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2); | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] main.c:1:3: error: return type defaults to 'int' [-Wimplicit-int] 1 | r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2); | ^~~~ main.c: In function 'main': main.c:1:3: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:20: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration] 1 | r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2); | ^~~~~~~ main.c:1:1: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' +++ |+#include <stdio.h> 1 | r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2); main.c:1:47: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2); | ^~~~~~ main.c:1:47: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:47: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:47: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:1: error: expected declaration or statement at end of input 1 | r;main(c){for(;~(c=getchar());)r+=c>83?!!r:-1;printf("%d",~r*2); | ^
s118027371
p03986
C++
#include <iostream> #include <string> #include <stack> using namespace std; int main() { string x; cin>>x; stack<char> s; for(e: x) { if (e=='T' and s.size() and s.top()=='S') s.pop(); else s.push(e); } cout<<s.size()<<endl; } #include <iostream> #include <string> #include <stack> using namespace std; int main() { string x; cin>>x; stack<char> s; for(e: x) { if (e=='T' and s.size() and s.top()=='S') s.pop(); else s.push(e); } cout<<s.size()<<endl; }
a.cc: In function 'int main()': a.cc:11:10: error: found ':' in nested-name-specifier, expected '::' 11 | for(e: x) { | ^ | :: a.cc:11:9: error: 'e' has not been declared 11 | for(e: x) { | ^ a.cc:18:1: error: expected primary-expression before '}' token 18 | } | ^ a.cc:17:26: error: expected ')' before '}' token 17 | cout<<s.size()<<endl; | ^ | ) 18 | } | ~ a.cc:11:8: note: to match this '(' 11 | for(e: x) { | ^ a.cc:18:1: error: expected primary-expression before '}' token 18 | } | ^ a.cc: At global scope: a.cc:24:5: error: redefinition of 'int main()' 24 | int main() | ^~~~ a.cc:6:5: note: 'int main()' previously defined here 6 | int main() | ^~~~ a.cc: In function 'int main()': a.cc:29:10: error: found ':' in nested-name-specifier, expected '::' 29 | for(e: x) { | ^ | :: a.cc:29:9: error: 'e' has not been declared 29 | for(e: x) { | ^ a.cc:36:1: error: expected primary-expression before '}' token 36 | } | ^ a.cc:35:26: error: expected ')' before '}' token 35 | cout<<s.size()<<endl; | ^ | ) 36 | } | ~ a.cc:29:8: note: to match this '(' 29 | for(e: x) { | ^ a.cc:36:1: error: expected primary-expression before '}' token 36 | } | ^
s126566055
p03986
C++
// #include <iostream> #include <cstdio> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <map> #include <set> #include <array> #include <numeric> #include <functional> #include<list> #include<queue> #include<deque> #include<algorithm> #include<utility> #include<complex> using namespace std; #define REP(i,m,n) for(int i=m;i<(n);i++) #define rep(i,n) REP(i,0,n) #define ALL(x) (x).begin(),(x).end() typedef long long ll; typedef pair<int, int> pii; const ll inf = INT_MAX; const double eps = 1e-10; const double pi = acos(-1.0); const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}}; string op(const string str){ string ret = str; auto pos = str.find("ST"); if(pos == -1){return str;} ret = str.substr(0, pos) + str.substr(pos+2, str.length()); return ret; } int main(){ string str, st; cin >> str; for(;;){ st = op(str); if(st == str) break; str = st; } // cout << st << endl; cout << st.length() << endl; return 0; }
a.cc:29:16: error: 'INT_MAX' was not declared in this scope 29 | const ll inf = INT_MAX; | ^~~~~~~ a.cc:19:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 18 | #include<complex> +++ |+#include <climits> 19 |
s059813935
p03986
Java
import java.util.Scanner; public class Mondai1 { public static void main(String[] args) { Scanner scan = null; try { scan = new Scanner(System.in); System.out.println(replace(scan.nextLine()).length()); } finally { if (scan != null) { scan.close(); } } } private static String replace(String str) { if (str.contains("ST")) { return replace(str.replace("ST", "")); } return str; } }
Main.java:3: error: class Mondai1 is public, should be declared in a file named Mondai1.java public class Mondai1 { ^ 1 error
s464816235
p03986
C++
#include <iostream> #include<string> using namespace std; string str; int main() { cin>>str; for(int n=0;n<str.size();n++){if(str=="ST")str.clear(); if(*(str.begin()+n)=='S'&&*(str.begin()+n+1)=='T'){ str.erase(str.begin()+n); str.erase(str.begin()+n); n--;} cout<<str.size()<<endl; return 0;}
a.cc: In function 'int main()': a.cc:14:15: error: expected '}' at end of input 14 | return 0;} | ^ a.cc:6:16: note: to match this '{' 6 | int main() { | ^
s488436720
p03986
C++
str = STDIN.gets.chomp result = str count = 0 while str.size > count result = result.sub("ST" , "") count += 1 end STDOUT.puts result.size
a.cc:1:1: error: 'str' does not name a type 1 | str = STDIN.gets.chomp | ^~~
s897195641
p03986
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ string s; cin>>s; stack<string> st; for(int i=0;i<s.size();i++){ if(s[i]=='S') st.push(s[i]); else{ if(st.top()=='S') st.pop(); else st.push(s[i]); } } //cout<<st.size()<<endl; return 0; }
a.cc: In function 'int main()': a.cc:11:26: error: no matching function for call to 'std::stack<std::__cxx11::basic_string<char> >::push(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)' 11 | if(s[i]=='S') st.push(s[i]); | ~~~~~~~^~~~~~ In file included from /usr/include/c++/14/stack:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:160, from a.cc:1: /usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >; value_type = std::__cxx11::basic_string<char>]' 258 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_stack.h:258:30: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::stack<std::__cxx11::basic_string<char> >::value_type&' {aka 'const std::__cxx11::basic_string<char>&'} 258 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >; value_type = std::__cxx11::basic_string<char>]' 263 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_stack.h:263:25: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::stack<std::__cxx11::basic_string<char> >::value_type&&' {aka 'std::__cxx11::basic_string<char>&&'} 263 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:13:18: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} and 'char') 13 | if(st.top()=='S') st.pop(); | ~~~~~~~~^~~~~ | | | | | char | __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type {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: /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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 13 | if(st.top()=='S') st.pop(); | ^~~ 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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 13 | if(st.top()=='S') st.pop(); | ^~~ 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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 13 | if(st.top()=='S') st.pop(); | ^~~ /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:13:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 13 | if(st.top()=='S') st.pop();
s680045100
p03986
Java
public class Solution { public static void main(String[] args) { try (java.util.Scanner sc = new java.util.Scanner(System.in)) { StringBuilder sb = new StringBuilder(); char[] a = sc.next().toCharArray(); int i = 0; java.util.Deque<Character> stack = new java.util.ArrayDeque<>(); while (i != a.length) { stack.push(a[i]); while (++i != a.length && a[i] == 'T' && !stack.isEmpty() && stack.peek() == 'S') { stack.pop(); } } System.out.println(stack.size()); } // end try } // end main() } // end Solution
Main.java:1: error: class Solution is public, should be declared in a file named Solution.java public class Solution { ^ 1 error
s859436459
p03986
C++
#include <iostream> #include <stdio.h> using namespace std; int main() { char x[200000]; int depth=0; int ans=0; cin >> x; for(int i=0;x[i]!='\0' && i < ;++i){ if(x[i]=='S'){ ++depth; ++ans; }else if(x[i]=='T' && depth>0){ --depth; --ans; }else{ ans++; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:35: error: expected primary-expression before ';' token 11 | for(int i=0;x[i]!='\0' && i < ;++i){ | ^
s118326383
p03986
C++
fack you
a.cc:1:1: error: 'fack' does not name a type 1 | fack you | ^~~~
s474681285
p03986
C++
#include <iostream> #include <cstring> using namespace std; S char s[200010]; int l, T; int main() { scanf("%s", s); while (s[++l]); int i = 0; while (1) { if (s[i++] == 'S') { T--; l-=2; } else T++; if(T==l/2) break; } printf("%d\n", T*2); return 0; }
a.cc:5:1: error: 'S' does not name a type 5 | S | ^ a.cc: In function 'int main()': a.cc:10:17: error: 's' was not declared in this scope 10 | scanf("%s", s); | ^
s354344154
p03986
C++
#include <bits/stdc++.h> using namespace std; int main() { string s; int a=s.length(); long i,ans=0; for(i=a-1;i>=0;i--) { if(s[i]=='S') {ans++;continue;} break; } printf("%ld\n",n-ans); return 0; }
a.cc: In function 'int main()': a.cc:17:24: error: 'n' was not declared in this scope 17 | printf("%ld\n",n-ans); | ^
s272690120
p03986
Java
public class Solution { public static void main(String[] args) { try (java.util.Scanner sc = new java.util.Scanner(System.in)) { StringBuilder sb = new StringBuilder(); char[] s = sc.next().toCharArray(); int len = s.length; for (int i = 1, j = 0; i < s.length; i++) { if (s[j] == 'S' && s[i] == 'T') { len -= 2; if (j != 0) { j--; } else { j = i + 1; i = j; } } else j++; } System.out.println(len); } } }
Main.java:1: error: class Solution is public, should be declared in a file named Solution.java public class Solution { ^ 1 error
s821625614
p03986
Java
public class Atcoder_20161001_A { public static void Main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); sc.close(); int s_cnt = s.length(); StringBuilder sb = new StringBuilder(); for (int l = s_cnt / 2; l >= 1; l--) { sb = new StringBuilder(); for (int m = 1; m <= l; m++) { sb.append("S"); } for (int m = 1; m <= l; m++) { sb.append("T"); } s = s.replaceAll(sb.toString(), ""); if (s.indexOf("ST", 0) == -1) break; } System.out.println(s.length()); } }
Main.java:1: error: class Atcoder_20161001_A is public, should be declared in a file named Atcoder_20161001_A.java public class Atcoder_20161001_A { ^ Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Atcoder_20161001_A Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Atcoder_20161001_A 3 errors
s398967640
p03986
Java
public class Main{ public static void main(String[] args) { final String check_str = "ST"; Scanner sc = new Scanner(System.in); String s = sc.next(); sc.close(); int s_cnt = s.length(); StringBuilder sb = new StringBuilder(); for (int l = s_cnt / 2; l >= 1; l--) { sb = new StringBuilder(); for (int m = 1; m <= l; m++) { sb.append("S"); } for (int m = 1; m <= l; m++) { sb.append("T"); } s = s.replaceAll(sb.toString(), ""); if (s.indexOf(check_str, 0) == -1) break; } System.out.println(s.length()); } }
Main.java:5: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:5: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s841047005
p03986
C++
#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <map> #include <regex> using namespace std; typedef long long ll; string s; string search = "ST"; std::regex reg(R"(\{ST\}+)"); int main() { ios::sync_with_stdio(false); cin >> s; s = regex_replace(s, r, ""); size_t found = s.find("ST"); //cout << found << endl; while (found != string::npos) { string temp = s.substr(0,found); temp.append(s.substr(found+2, s.length()-found+2)); s = temp; s = regex_replace(s, r, ""); found = s.find("ST"); } //*/ cout << s.length() << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:26: error: 'r' was not declared in this scope 23 | s = regex_replace(s, r, ""); | ^
s200490738
p03986
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; string X; cin>>X; while(1){ if(n==X.length())break; for(int i=0;i<X.length();i++){ if(X[i]=='S'&&X[i+1]=='T'){ X.erase(X.begin()+i,X.begin()+i+2); X[i]=X[i+1]=x; } } n=X.length(); } cout<<X.length()<<endl; return 0; }
a.cc: In function 'int main()': a.cc:14:21: error: 'x' was not declared in this scope 14 | X[i]=X[i+1]=x; | ^
s005591482
p03986
C++
#include <iostream> using namespace std; int main(void){ int i=0,j,k,tlen,slen=0,stlen=0; string s; cin >> s; for(;(s[i]=='T')&&(i<s.length());i++){} while(i<s.length()){ j=i; for(;(s[i]=='S')&&(i<s.length());i++){} slen+=i-j; k=i; for(;(s[i]=='T')&&(i<s.length());i++){} tlen=i-k; if(slen>tlen){ stlen+=tlen*2; slen=slen-tlen; }else{ stlen+=slen*2; slen=0 } } cout << s.length()-stlen; }
a.cc: In function 'int main()': a.cc:20:10: error: expected ';' before '}' token 20 | slen=0 | ^ | ; 21 | } | ~
s947564407
p03986
Java
import java.util.Scanner; public class Atcoder_20161001_A { public static void main(String[] args) { final String check_str = "ST"; Scanner sc = new Scanner(System.in); String s = sc.next(); sc.close(); while(true){ s = s.replaceFirst(check_str, ""); if (s.indexOf(check_str, 0) == -1) break; } System.out.println(s.length()); } }
Main.java:3: error: class Atcoder_20161001_A is public, should be declared in a file named Atcoder_20161001_A.java public class Atcoder_20161001_A { ^ 1 error
s510647316
p03986
C++
#include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <utility> #include <unordered_set> #include <unordered_map> #include <stack> #include <queue> #include <deque> #include <functional> #include <numeric> #include <complex> #include <iomanip> using namespace std; #define bitcount(n) __builtin_popcount(n) #define debug(n) cout << n << endl; #define PREC(n) setprecision(n) #define DOTPREC(n) fixed << setprecision(n) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vpii; #define fst first #define scd second #define PB push_back #define MP make_pair #define rep(i,x) for(int i=0;i<(x);++i) #define rep1(i,x) for(int i=1;i<=(x);++i) #define rrep(i,x) for(int i=(x)-1;i>=0;--i) #define rrep1(i,x) for(int i=(x);i>=1;--i) #define FOR(i,a,x) for(int i=(a);i<(x);++i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define omajinai ios::sync_with_stdio(false); cin.tie(0) template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;} template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;} const int inf = 1e9; const ll linf = 3e18; const double eps = 1e-9; const ll MOD = 1000000007; string s; int main(void) { omajinai; cin >> s; ll count = 0; rrep(i, N) { if (s[i] == 'T') break; count++; } cout << count * 2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:68:13: error: 'N' was not declared in this scope 68 | rrep(i, N) { | ^ a.cc:45:30: note: in definition of macro 'rrep' 45 | #define rrep(i,x) for(int i=(x)-1;i>=0;--i) | ^
s561013603
p03986
Java
import java.util.Scanner; public class A { static Scanner sc; public static void main(String[] args) { String x; sc = new Scanner(System.in); x = sc.next(); long n = x.length(); char[] X = x.toCharArray(); long len= n; for(long i=0; i<n-1; i++){ if(X[(int) i]=='S' && X[(int) (i+1)]=='T'){ len-=2; long j=i; while(j-1>=0 && X[(int) (j-1)]=='S'){ if(X[(int) (i+2)]=='T'){ i++; j--; len-=2; } else { break; } } } } System.out.println(len); } }
Main.java:3: error: class A is public, should be declared in a file named A.java public class A { ^ 1 error
s658494481
p03986
C++
#include<iostream> using namespace std; int main() { string s; cin >> s; string::sizetype index i; bool b = 1; unsigned int u = 0; while(b){ i = s.find("ST"); if(index == string::npos){ b = 0; } else { s.erase(i); s.erase(i); u = u + 1; } } cout << s.length(); return 0; }
a.cc: In function 'int main()': a.cc:7:17: error: 'sizetype' is not a member of 'std::string' {aka 'std::__cxx11::basic_string<char>'} 7 | string::sizetype index i; | ^~~~~~~~ a.cc:11:17: error: 'i' was not declared in this scope 11 | i = s.find("ST"); | ^ a.cc:12:20: error: 'index' was not declared in this scope 12 | if(index == string::npos){ | ^~~~~
s307365801
p03986
C++
#include <stdio.h> #include <algorithm> using namespace std; int N, a[212345], tmp = 0; __int64 ans; int main(void) { scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d", &a[i]); } for (int l = 0; l < N; ++l) { for (int r = l; r < N; ++r) { for (int i = l; i <= r; ++i) { if (i == l) { tmp = a[i]; } if (tmp > a[i]) { tmp = a[i]; } } ans += tmp; } } printf("%I64d", ans); return 0; }
a.cc:7:1: error: '__int64' does not name a type; did you mean '__int64_t'? 7 | __int64 ans; | ^~~~~~~ | __int64_t a.cc: In function 'int main()': a.cc:19:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 19 | ans += tmp; | ^~~ | abs a.cc:23:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 23 | printf("%I64d", ans); | ^~~ | abs
s518560918
p03986
C++
#include<cstdio> using namespace std; char str[200001] = {}; void sort(int n){ int j,k; for(j = n;str[j] != '\0';j++){ str[j] = str[j +2]; } } int main(){ int i; gets(str); for(i = 0;i <= 200000 ;i++){ if(str[i] == 'S'){ if(str[i + 1] == 'T'){ str[i] == '\0'; str[i + 1] == '\0'; sort(i); i--; } } } puts(str); return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 15 | gets(str); | ^~~~ | getw
s908085221
p03986
Java
import java.io.*; import java.util.Scanner; public class STring { public static void main(String[] args){ Scanner reader = new Scanner(System.in); // Reading from System.in int i; String input = reader.next(); // Scans the next token of the input as an int. String current = ""; for(i=0;i<200000;i++){ if(!input.contains("ST")) break; input = input.substring(i); current = input; } //System.out.println(current); if(current.isEmpty()) System.out.println(0); System.out.println(current.length()+1); } }
Main.java:4: error: class STring is public, should be declared in a file named STring.java public class STring { ^ 1 error
s885153416
p03986
Java
import java.util.Scanner; public class ProblemA { public static void Main(String[] args) { StringBuilder sb; Scanner sc = new Scanner(System.in); sb = new StringBuilder(sc.nextLine()); sc.close(); String pattern = "ST"; int patternIndex; do{ patternIndex = sb.indexOf(pattern); if(patternIndex >= 0) { sb.delete(patternIndex, patternIndex+2); } } while(patternIndex >= 0); System.out.println(sb.length()); } }
Main.java:3: error: class ProblemA is public, should be declared in a file named ProblemA.java public class ProblemA { ^ 1 error
s142526430
p03986
Java
import java.util.Scanner; public class ProblemA { public static void main(String[] args) { StringBuilder sb; Scanner sc = new Scanner(System.in); sb = new StringBuilder(sc.nextLine()); sc.close(); String pattern = "ST"; int patternIndex; do{ patternIndex = sb.indexOf(pattern); if(patternIndex >= 0) { sb.delete(patternIndex, patternIndex+2); } } while(patternIndex >= 0); System.out.println(sb.length()); } }
Main.java:3: error: class ProblemA is public, should be declared in a file named ProblemA.java public class ProblemA { ^ 1 error
s563922590
p03986
C++
#include <iostream> #include <cstring> #include <algorithm> #define REP(i,n) for(int i=0;i<(n);++i) #define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i) #define CLEAR(a,v) memset(a,v,sizeof(a)) #define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0])) using namespace std; int main(){ string S; cin >> S; int s = 0, t = 0; int len = S.size(); REP(i,len){ if(S[i] == 'S'){ s++; }else{ if(s == 0){ t++; }else{ s--; } } } cout << s+t << endl;r }
a.cc: In function 'int main()': a.cc:26:25: error: 'r' was not declared in this scope 26 | cout << s+t << endl;r | ^
s860241236
p03986
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String ST = "ST"; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder line = new StringBuilder(br.readLine()); int stIndex; while (!((stIndex = line.indexOf(ST)) == -1)) { line.delete(stIndex, stIndex + 2); } System.out.println(line.length()); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s617785178
p03986
C++
package AtCoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String ST = "ST"; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder line = new StringBuilder(br.readLine()); int stIndex; while (!((stIndex = line.indexOf(ST)) == -1)) { line.delete(stIndex, stIndex + 2); } System.out.println(line.length()); } }
a.cc:1:1: error: 'package' does not name a type 1 | package AtCoder; | ^~~~~~~ a.cc:3:1: error: 'import' does not name a type 3 | import java.io.BufferedReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.IOException; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.io.InputStreamReader; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: expected unqualified-id before 'public' 7 | public class Main { | ^~~~~~
s982781306
p03986
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import javax.script.ScriptException; public class Main { public static String ST = "ST"; public static void main(String[] args) throws IOException, ScriptException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder line = new StringBuilder(br.readLine()); int stIndex; while (!((stIndex = line.indexOf(ST)) == -1)) { line.delete(stIndex, stIndex + 2); } System.out.println(line.length()); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import javax.script.ScriptException; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: expected unqualified-id before 'public' 7 | public class Main { | ^~~~~~
s460044624
p03986
C++
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { int len; int i; int ans; char *a = (char *)malloc(200004); scanf("%s", a); len = strlen(a); ans = len; for (i = 0; i < len;) { if (a[i] == 'S' && a[i + 1] == 'T') { memmove(&a[i], &a[i + 2], len - i); --i; } else { ++i; } } printf("%d\n", strlen(a)); }
a.cc:5:1: error: '::main' must return 'int' 5 | void main() | ^~~~
s834554416
p03986
Java
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class AtCoder { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws Exception { String in = br.readLine(); long num = (long) Math.pow(10, 10000); Pattern p = Pattern.compile("ST"); Matcher m = p.matcher(in); long i = 0; while (m.find() && i < num) { in = m.replaceFirst(""); m = p.matcher(in); i++; } System.out.println(in.length()); } }
Main.java:6: error: class AtCoder is public, should be declared in a file named AtCoder.java public class AtCoder { ^ 1 error
s516540674
p03986
C++
#include <bits/stdc++.h> using namespace std; const int N = 1234567; char s[N], st[N]; int main() { gets(s); int n = strlen(s); int e = 0; for (int i = 0; i < n; i++) { if (e > 0 && st[e - 1] == 'S' && s[i] == 'T') { e--; } else { st[e++] = s[i]; } } printf("%d\n", e); return 0; }
a.cc: In function 'int main()': a.cc:10:3: error: 'gets' was not declared in this scope; did you mean 'getw'? 10 | gets(s); | ^~~~ | getw
s873933941
p03986
Java
import java.util.*; public class main{ public static void main(String[] args){ Scanner scan=new Scanner(System.in); String str=scan.next(); String strb; for(int i=0;i<200000;i++){ strb=str; str=str.replaceFirst("ST",""); if(str.equals(strb)) break; } System.out.print(str.length()); } }
Main.java:3: error: class main is public, should be declared in a file named main.java public class main{ ^ 1 error
s645491174
p03986
Java
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class AtCoder { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws Exception { String in = br.readLine(); long num = (long) Math.pow(10, 10000); Matcher m = Pattern.compile("ST").matcher(in); long i = 0; while (m.find() && i < num) { in = m.replaceFirst(""); i++; } System.out.println(in.length()); } }
Main.java:6: error: class AtCoder is public, should be declared in a file named AtCoder.java public class AtCoder { ^ 1 error
s862208810
p03986
C++
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> #include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <set> #include <map> #include <numeric> #include <unordered_map> #include <unordered_set> #include <complex> //cin.sync_with_stdio(false); //streambuf using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; using vi = vector<int>; using vll = vector<ll>; using vpii = vector<pii>; using ti3 = tuple<int, int, int>; using vti3 = vector<ti3>; template<class T, class T2> using umap = unordered_map<T, T2>; template<class T> using uset = unordered_set<T>; template<class T> void cmin(T &a, const T&b) { if (a > b)a = b; } #define ALL(a) a.begin(),a.end() #define rep(i,a) for(int i=0;i<a;i++) #define rep1(i,a) for(int i=1;i<=a;i++) const ll mod = 1000000007; #ifndef INT_MAX const int INT_MAX = numeric_limits<signed>().max(); #endif template <class T> inline void hash_combine(size_t & seed, const T & v) { hash<T> hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } namespace std { template<typename S, typename T> struct hash<pair<S, T>> { inline size_t operator()(const pair<S, T> & v) const { size_t seed = 0; hash_combine(seed, v.first); hash_combine(seed, v.second); return seed; } }; // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t& seed, Tuple const& tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename ... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const& tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...> >::apply(seed, tt); return seed; } }; } umap<ti3, ll> memo; ll pow(ll base, ll i, ll mod) { ll a = 1; while (i) { if (i & 1) { a *= base; a %= mod; } base *= base; base %= mod; i /= 2; } return a; } class unionfind { vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う public: unionfind(int n) :par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); } int find(int x) { if (par[x] == x)return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); par[y] = x; size_[x] += size_[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return size_[find(x)]; } }; ll gcd(ll a, ll b) { while (b) { ll c = a%b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } int popcnt(unsigned long long a) { a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555); a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333); a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f); a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff); a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff); return (a & 0xffffffff) + (a >> 32); } template<class T, class Func = function<T(T, T)>> class segtree { vector<T> obj; int offset; Func updater; T e; int bufsize(int num) { int i = 1; for (; num >i; i <<= 1); offset = i - 1; return (i << 1) - 1; } T query(int a, int b, int k, int l, int r) { if (r <= a || b <= l)return e; if (a <= 1 && r <= b)return obj[k]; else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r)); } public: T query(int a, int b) {//[a,b) return query(a, b, 0, 0, offset + 1); } void updateall(int l = 0, int r = -1) { if (r < 0)r = offset + 1; l += offset, r += offset; do { l = l - 1 >> 1, r = r - 1 >> 1; for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]); } while (r) } void update(int k, T &a) { k += offset; obj[k] = a; while (k) { k = k - 1 >> 1; obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]); } } segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {} segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) { copy(vec.begin(), vec.end(), obj.begin() + offset); updateall(); } typename vector<T>::refrence operator[](int n) { return obj[n + offset]; } }; int main() { string s; cin >> s; int x = s.size(); int cs = 0; for (auto a : s) { if (a == 'S')cs++; else { if (cs) { cs--; x-=2; } } } cout << x << endl; }
a.cc: In member function 'void segtree<T, Func>::updateall(int, int)': a.cc:174:9: error: expected ';' before '}' token 174 | } | ^
s369904732
p03986
C++
#include <iostream> #include <string> using namespace std; main(){ string x; int a; int start=0; int end=0; a=x.length(); for(int i=0;i<a;i++){ if(x[i]=='T'){ start++; }else{ break; } } for(int i=(a-1);i>=0;i--){ if(x[i]=='S'){ end++; }else{ break } } cout << a-start-end <<endl; }
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:24:30: error: expected ';' before '}' token 24 | break | ^ | ; 25 | } | ~
s903597034
p03986
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; using vvb = vector<vb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vvd = vector<vd>; #define REP(i,n) for(ll i=0, i##_len=(ll)(n); i<i##_len; ++i) #define ALL(c) (c).begin(), (c).end() #define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i) #define TEN(x) ((ll)1e##x) const ll mod = TEN(9) + 7; int main() { #ifdef INPUT_FROM_FILE ifstream cin("sample.in"); ofstream cout("sample.out"); #endif cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(50); string s; cin >> s; ll l = 0, r = s.size() - 1; while (s[l] == 'T') l++; while (s[r] == 'S') r--; ll ma = max(l, s.size() - r - 1); cout << ma * 2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:20: error: no matching function for call to 'max(ll&, long long unsigned int)' 31 | ll ma = max(l, s.size() - r - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 31 | ll ma = max(l, s.size() - r - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 31 | ll ma = max(l, s.size() - r - 1); | ~~~^~~~~~~~~~~~~~~~~~~~~
s338925595
p03987
Java
import utils.SegmentTree; import java.io.*; import java.util.*; import java.util.Map.Entry; import java.util.function.Function; /** * Created by Katushka on 11.03.2020. */ public class Main { public static final Comparator<int[]> COMPARATOR = Comparator.comparingInt(o -> o[0]); static Integer[] readArray(int size, InputReader in) { Integer[] a = new Integer[size]; for (int i = 0; i < size; i++) { a[i] = in.nextInt(); } return a; } static long[] readLongArray(int size, InputReader in) { long[] a = new long[size]; for (int i = 0; i < size; i++) { a[i] = in.nextLong(); } return a; } static void sortArray(int[] a) { Random random = new Random(); for (int i = 0; i < a.length; i++) { int randomPos = random.nextInt(a.length); int t = a[i]; a[i] = a[randomPos]; a[randomPos] = t; } Arrays.sort(a); } interface AssociativeFunction<A> { A apply(A a, A b); } static class SegTree<A, B> { private final AssociativeFunction<A> func; private final A start; private final Function<B, A> converter; private int size; private final A[] tree; SegTree(B[] a, AssociativeFunction<A> func, Function<Integer, A[]> arrayConstructor, A start, Function<B, A> converter) { this.func = func; this.start = start; this.converter = converter; size = 1; while (size < a.length) { size *= 2; } tree = arrayConstructor.apply(2 * size - 1); build(a, 0, 0, size, converter); } private void build(B[] a, int x, int lx, int rx, Function<B, A> converter) { if (rx - lx == 1) { if (lx < a.length) { tree[x] = converter.apply(a[lx]); } } else { int m = (rx + lx) / 2; build(a, 2 * x + 1, lx, m, converter); build(a, 2 * x + 2, m, rx, converter); tree[x] = func.apply(tree[2 * x + 1], tree[2 * x + 2]); } } public void set(int i, B v) { set(i, v, 0, 0, size); } private void set(int i, B v, int x, int lx, int rx) { if (rx - lx == 1) { tree[x] = converter.apply(v); return; } int m = (rx + lx) / 2; if (i >= m) { set(i, v, 2 * x + 2, m, rx); } else { set(i, v, 2 * x + 1, lx, m); } tree[x] = func.apply(tree[2 * x + 1], tree[2 * x + 2]); } public A result(int l, int r) { return result(l, r, 0, 0, size); } private A result(int l, int r, int x, int lx, int rx) { if (l >= rx || lx >= r) { return start; } if (lx >= l && rx <= r) { return tree[x]; } int m = (lx + rx) / 2; return func.apply(result(l, r, 2 * x + 1, lx, m), result(l, r, 2 * x + 2, m, rx)); } } public static void main(String[] args) throws FileNotFoundException { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = in.nextInt(); Integer[] a = readArray(n, in); int[] pos = new int[n + 1]; for (int i = 0; i < n; i++) { pos[a[i]] = i; } SegTree<Integer, Integer> segTree = new SegTree<>(a, Math::min, t -> { Integer[] res = new Integer[t]; Arrays.fill(res, Integer.MAX_VALUE); return res; }, Integer.MAX_VALUE, integer -> integer); long ans = solve(0, n, segTree, pos, n); out.println(ans); out.close(); } private static long solve(int l, int r, SegTree<Integer, Integer> segTree, int[] pos, int n) { int min = segTree.result(l, r); int p = pos[min]; long ans = (p - l + 1) * (r - p) * min; if (r - l > 1) { if (p > l) { ans += solve(l, p, segTree, pos, n); } if (p < r - 1) { ans += solve(p + 1, r, segTree, pos, n); } } return ans; } private static void outputArray(long[] ans, PrintWriter out) { StringBuilder str = new StringBuilder(); for (long an : ans) { str.append(an).append(" "); } out.println(str); } private static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { createTokenizer(); } return tokenizer.nextToken(); } private void createTokenizer() { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } public String nextString() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public char nextChar() { return next().charAt(0); } public int[] nextInts() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { createTokenizer(); } List<Integer> res = new ArrayList<>(); while (tokenizer.hasMoreElements()) { res.add(Integer.parseInt(tokenizer.nextToken())); } int[] resArray = new int[res.size()]; for (int i = 0; i < res.size(); i++) { resArray[i] = res.get(i); } return resArray; } } }
Main.java:1: error: package utils does not exist import utils.SegmentTree; ^ 1 error
s864956477
p03987
C++
#include <bits/stdc++.h> #include "../lib/segmenttree/segtree_update_min.hpp" #include "../lib/segmenttree/segtree_update_max.hpp" using namespace std; #define SZ(x) (int)(x.size()) #define REP(i, n) for(int i=0;i<(n);++i) #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define RREP(i, n) for(int i=(int)(n);i>=0;--i) #define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i) #define ALL(a) (a).begin(),(a).end() #define DUMP(x) cerr<<#x<<" = "<<(x)<<endl #define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<int, int>; const double eps = 1e-8; const ll MOD = 1000000007; const int INF = INT_MAX / 2; const ll LINF = LLONG_MAX / 2; template <typename T1, typename T2> bool chmax(T1 &a, const T2 &b) { if(a < b) {a = b; return true;} return false; } template <typename T1, typename T2> bool chmin(T1 &a, const T2 &b) { if(a > b) {a = b; return true;} return false; } template<typename T1, typename T2> ostream& operator<<(ostream &os, const pair<T1, T2> p) { os << p.first << ":" << p.second; return os; } template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { REP(i, SZ(v)) { if(i) os << " "; os << v[i]; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); int n; cin >> n; vector<P> v(n); REP(i, n) { cin >> v[i].first; v[i].second = i; } sort(ALL(v)); vll vmi(n, INF), vma(n, -INF); SegmentTreeUpdMin<ll> stmi(vmi); SegmentTreeUpdMax<ll> stma(vma); ll ans = 0; REP(i, n) { int now = v[i].first; int idx = v[i].second; ll l = stma.query(0, idx+1); ll r = stmi.query(idx, n); if(l == -INF) l = -1; if(r == INF) r = n; ans += (idx - l) * (r - idx) * now; stmi.update(idx, idx); stma.update(idx, idx); } cout << ans << endl; }
a.cc:2:10: fatal error: ../lib/segmenttree/segtree_update_min.hpp: No such file or directory 2 | #include "../lib/segmenttree/segtree_update_min.hpp" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s771795902
p03987
C++
#include<algorithm> #include<iostream> #include<string.h> #include<utility> #include<stdio.h> #include<vector> #include<string> #include<math.h> #include<cmath> #include<queue> #include<stack> #include<deque> #include<map> #pragma warning(disable:4244) #define PI 3.1415926536 #pragma GCC optimize(2) using namespace std; typedef long long ll; typedef unsigned long long ull; const ll ll_inf = 9223372036854775807; const int int_inf = 2147483647; const short short_inf = 32767; const char char_inf = 127; ll GCD(ll a, ll b) { return a ? GCD(b, a % b) : a; } inline ll read() { ll c = getchar(), Nig = 1, x = 0; while (!isdigit(c) && c != '-')c = getchar(); if (c == '-')Nig = -1, c = getchar(); while (isdigit(c))x = ((x << 1) + (x << 3)) + (c ^ '0'), c = getchar(); return Nig * x; } inline void out(ll a) { if (a < 0)putchar('-'), a = -a; if (a >= 10)out(a / 10); putchar(a % 10 + '0'); } ll qpow(ll x, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1)res = (res * x) % mod; x = (x * x) % mod; n >>= 1; } return res; } #define read read() ll dp[250000][40]; ll n; ll RMQ(ll s, ll v) { ll k = (ll)(log(v - s + 1) * 1.0 / log(2.0)); return save[dp[s][k]] < save[dp[v - ((ll)1 << k) + 1][k]] ? dp[s][k] : dp[v - ((ll)1 << k) + 1][k]; } ll save[250000]; ll sum = 0; bool judge(ll l, ll r) { if (l == r) { sum += (ll)save[l]; return 1; } return 0; } void dfs(ll L, ll R) { if (judge(L, R))return; ll temp = RMQ(L, R); sum = sum + (ll)(temp - L + 1) * (R - temp + 1) * save[temp]; if (L <= temp - 1)dfs(L, temp - 1); if (R >= temp + 1)dfs(temp + 1, R); } void ANS(int i, int j) { dp[i][j] = save[dp[i][j - 1]] < save[dp[i + ((ll)1 << (j - 1))][j - 1]] ? dp[i][j - 1] : dp[i + ((ll)1 << (j - 1))][j - 1]; } int main() { n = read; for (ll i = 0; i < n; i++)save[i] = read; for (ll i = 0; i < n; i++)dp[i][0] = i; for (ll j = 1; ((ll)1 << j) <= n; j++) for (ll i = 0; i + ((ll)1 << j) - 1 < n; i++)ANS(i, j); dfs(0, n - 1); cout << sum << endl; }
a.cc: In function 'll RMQ(ll, ll)': a.cc:52:16: error: 'save' was not declared in this scope 52 | return save[dp[s][k]] < save[dp[v - ((ll)1 << k) + 1][k]] ? dp[s][k] : dp[v - ((ll)1 << k) + 1][k]; | ^~~~
s948791370
p03987
C++
#include <iostream> #include <cstring> #include <set> #include <vector> #include <algorithm> #define MOD 1000000007 using namespace std; int n, arr[200010], cvp; vector<pair<int, int> > index; set<int> step; int main(void){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++){ cin>>arr[i]; index.push_back(make_pair(arr[i], i)); } sort(index.begin(), index.end()); cvp=index[0].second*(n-index[0].second+1); step.insert(index[0].second); for (int i = 1; i < n; ++i){ int bas, son; set<int>::iterator it=step.lower_bound(index[i].second); if(it==step.end())son=n+1; else son=*it; if(it==step.begin())bas=0; else{ it--; bas=*it; } cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second); step.insert(index[i].second); } cout<<cvp; return 0; }
a.cc:10:25: error: 'std::vector<std::pair<int, int> > index' redeclared as different kind of entity 10 | vector<pair<int, int> > index; | ^~~~~ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from a.cc:2: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'int main()': a.cc:20:23: error: overloaded function with no contextual type information 20 | index.push_back(make_pair(arr[i], i)); | ^~~~~~~~~ a.cc:22:20: error: overloaded function with no contextual type information 22 | sort(index.begin(), index.end()); | ^~~~~ a.cc:22:35: error: overloaded function with no contextual type information 22 | sort(index.begin(), index.end()); | ^~~ a.cc:23:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 23 | cvp=index[0].second*(n-index[0].second+1); | ^ a.cc:23:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 23 | cvp=index[0].second*(n-index[0].second+1); | ^ a.cc:24:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 24 | step.insert(index[0].second); | ^ a.cc:27:61: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 27 | set<int>::iterator it=step.lower_bound(index[i].second); | ^ a.cc:35:27: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 35 | cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second); | ^ a.cc:35:43: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 35 | cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second); | ^ a.cc:35:69: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 35 | cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second); | ^ a.cc:36:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 36 | step.insert(index[i].second); | ^
s186358275
p03987
C++
include<iostream> #include<cstdio> #define int long long using namespace std; int n,top,minn; const int N=1000010; int a[N],zhan[N],r[N],l[N]; long long ans; signed main() { cin>>n; for(int i=1;i<=n;++i)scanf("%lld",&a[i]); for(int i=1;i<=n;++i)r[i]=n+1,l[i]=0; for(int i=1;i<=n;++i) { while(top&&a[zhan[top]]>a[i])r[zhan[top--]]=i; l[i]=zhan[top]; zhan[++top]=i; } for(int i=1;i<=n;++i)ans+=(r[i]-i)*(i-l[i])*a[i]; cout<<ans; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:11:5: error: 'cin' was not declared in this scope 11 | cin>>n; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<cstdio> +++ |+#include <iostream> 3 | #define int long long a.cc:21:5: error: 'cout' was not declared in this scope 21 | cout<<ans; | ^~~~ a.cc:21:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s815916631
p03987
C++
#include <iostream> #include <string> #include <map> #include <queue> #include <algorithm> #include <vector> #include <math.h> #include <bitset> #include <cmath> #include <set> #include <queue> typedef long long ll; #define rep(i,s,n)for(ll i = s;i<n;i++) #define repe(i,s,n)for(ll i = s;i<=n;i++) #define rep_r(i,s,n)for(ll i = n;i>s;i--) #define rep_re(i,s,n)for(ll i = n;i>=s;i--) using namespace std; static const ll MOD = 1e9 + 7; static const ll INF = 1e25; static const ll MAX_N = 100001; ll a[200001]; ll p[200001]; ll l[200001]; ll r[200001]; set<ll> s; int main() { ll n; cin >> n; repe(i, 1, n) { cin >> a[i]; p[a[i]] = i; } ll ans = 0; s.insert(0); s.insert(n + 1); repe(i, 1, n) { s.insert(p[i]); set<ll>::iterator itr = s.upper_bound(p[i]); set<ll>::iterator itl = s.lower_bound(p[i]); ll l, r; if (itr == (--s.end())) { r = n; } else { r = *(++itr) - 1;
a.cc:20:23: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '1.0000000000000001e+25' to '9223372036854775807' [-Woverflow] 20 | static const ll INF = 1e25; | ^~~~ a.cc: In function 'int main()': a.cc:47:42: error: expected '}' at end of input 47 | r = *(++itr) - 1; | ^ a.cc:46:22: note: to match this '{' 46 | else { | ^ a.cc:47:42: error: expected '}' at end of input 47 | r = *(++itr) - 1; | ^ a.cc:37:23: note: to match this '{' 37 | repe(i, 1, n) { | ^ a.cc:47:42: error: expected '}' at end of input 47 | r = *(++itr) - 1; | ^ a.cc:28:12: note: to match this '{' 28 | int main() { | ^
s082442612
p03987
C++
#include <iostream> #include <set> using namespace std; using ll = long long; int main(){ int N; cin >> N; ll place[N + 1] for (int i = 0; i <= N; ++i) { ll a; cin >> a; place[a] = i; } ll ans = 0; set<ll> used = {0, N + 1}; for (int i = 0; i <=N; ++i) { ll r, l; auto itr = used.lower_bound(place[i]); r=*itr l=*(--itr) ans += i * (place[i] - l) * (r - place[i]); used.insert(place[i]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: expected initializer before 'for' 12 | for (int i = 0; i <= N; ++i) | ^~~ a.cc:12:25: error: 'i' was not declared in this scope 12 | for (int i = 0; i <= N; ++i) | ^ a.cc:26:45: error: 'place' was not declared in this scope 26 | auto itr = used.lower_bound(place[i]); | ^~~~~
s744304111
p03987
C++
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <random> #include <tuple> #include <iomanip> #include <cstring> using namespace std; typedef long long ll; //typedef pair<int,int> Pint; //typedef pair<ll, ll> P; //typedef pair<ll, pair<ll, ll>> P; //typedef tuple<int,int,int> T; typedef vector<ll> vec; typedef vector<vec> mat; #define rep(i, n) for(ll i = 0; i < (n); i++) #define revrep(i, n) for(ll i = (n-1); i >= 0; i--) #define pb push_back #define f first #define s second //const ll INFL = 1LL << 60;//10^18 = 2^60 const ll INFL = 1LL << 60; const int INF = 1 << 30;//10^9 ll MOD = 1e9 + 7; //ll MOD = 998244353; vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0}; vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0}; ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll pow_long(ll x, ll k){ ll res = 1; while(k > 0){ if(k % 2) res *= x; x *= x; k /= 2; } return res; } ll pow_mod(ll x, ll k){ x %= MOD; x += MOD; x %= MOD; ll res = 1; while(k > 0){ if(k % 2){ res *= x; res %= MOD; } x *= x; x %= MOD; k /= 2; } return res; } ll inverse(ll x){return pow_mod(x, MOD - 2);}; //最大公約数 ll gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a % b); } //最小公倍数 ll lcm(ll x, ll y){return x / gcd(x, y) * y;}; //コンビネーション const int MAXcomb = 200010; ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb]; //facはn!,finvは1/n! //invは逆元 void COMinit(){ fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for(int i = 2; i < MAXcomb; i++){ fac[i] = fac[i-1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD; finv[i] = finv[i-1] * inv[i] % MOD; } } ll comb(int n, int k){ if(n < k) return 0; if(n < 0 || k < 0) return 0; return fac[n] * finv[k] % MOD * finv[n-k] % MOD; } int main(void){ ll N; cin >> N; vector<ll> A(N), B(N); rep(i, N){ cin >> A[i]; A[i]--; B[A[i]] = i; } ll ans = 0; set<ll> S; S.insert(-1); S.insert(N); rep(i, N){ ll pos = B[i]; auto right = lower_bound(pos); auto left = right; left--; ll l = *left; ll r = *right; ans += (i+1) * (pos-l) * (r-pos); S.insert(pos); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:116:29: error: no matching function for call to 'lower_bound(ll&)' 116 | auto right = lower_bound(pos); | ~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)' 1530 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)' 1963 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate expects 4 arguments, 1 provided
s549225317
p03987
C++
#include <algorithm> #include <bits/stdc++.h> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X)) #define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X)) #define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++) #define all(X) (X).begin(), (X).end() #define sortDecending(X) sort(all(X), greater<ll>()) //降順 #define sortAscending(X) sort(all(X)) //昇順 #define pb push_back #define mp make_pair #define fi first #define sc second #define print(x) cout << x << endl #define printDouble(x) cout << fixed << setprecision(13) << x << endl typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb; typedef priority_queue<ll, vl> decendingQueue; //降順 typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順 const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ll INF = 9 * 1e18; const ll MOD = 1e9 + 7; long long gcd(long long m, long long n) { if (m < n) return gcd(n, m); if (n == 0) return m; return gcd(n, m % n); } long long lcm(long long m, long long n) { // m * nでlong型のオーバフローを発生させないため、先に割り算から行う return m * (n / gcd(m, n)); } // a + b + cをprimeで割った値を返す long long addMod(long long a, long long b) { return (a + b) % MOD; } long long minusMod(long long a, long long b) { return (a + MOD - b) % MOD; } long long multipleMod(long long a, long long b) { return (a * b) % MOD; } vector<long long> SieveOfEratosthenes(int max) { vector<long long> sieve; vector<long long> primes; for (int i = 1; i < max + 1; ++i) { sieve.push_back(i); } sieve[0] = 0; for (int i = 2; i < max + 1; ++i) { if (sieve[i - 1] != 0) { primes.push_back(sieve[i - 1]); for (int j = 2 * sieve[i - 1]; j < max + 1; j += sieve[i - 1]) { sieve[j - 1] = 0; } } } return primes; } class Combination { private: vector<long long> fac_; vector<long long> finv_; vector<long long> inv_; long long prime_; public: Combination(long long n, long long prime) { fac_ = vector<long long>(n + 1); finv_ = vector<long long>(n + 1); inv_ = vector<long long>(n + 1); prime_ = prime; fac_[0] = fac_[1] = 1; finv_[0] = finv_[1] = 1; inv_[1] = 1; for (long long i = 2; i <= n; i++) { fac_[i] = fac_[i - 1] * i % prime_; inv_[i] = prime_ - inv_[prime_ % i] * (prime_ / i) % prime_; finv_[i] = finv_[i - 1] * inv_[i] % prime_; } } // nCk long long getCombination(long long n, long long k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac_[n] * (finv_[k] * finv_[n - k] % prime_) % prime_; } }; class UnionFindTree { private: vector<int> par; vector<int> rnk; vector<int> siz; public: UnionFindTree(int n) { par.assign(n, -1); rnk.assign(n, -1); siz.assign(n, -1); for (int i = 0; i < n; ++i) { par[i] = i; rnk[i] = 0; siz[i] = 1; } } int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } bool same(int x, int y) { return find(x) == find(y); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; siz[y] += siz[x]; } else { par[y] = x; siz[x] += siz[y]; if (rnk[x] == rnk[y]) ++rnk[x]; } } int size(int x) { x = find(x); return siz[x]; } }; class Edge { public: ll from; ll to; ll cost; Edge() {} Edge(ll from, ll to, ll cost) { this->from = from; this->to = to; this->cost = cost; } bool operator<(const Edge &edge) const { return cost < edge.cost; //昇順 } }; class Graph { public: ll nodes; // ノード数 vector<Edge> edges; Graph() {} Graph(ll nodes) { this->nodes = nodes; } void addEdge(ll from, ll to, ll cost) { this->edges.push_back(Edge(from, to, cost)); } }; // クラスカル法 // 連結グラフの最小全域木を求める class Kruskal { private: Graph graph; vector<Edge> MinimumSpanningTree; ll minimumCost; void searchMinimumSpanningTree() { UnionFindTree uf(graph.nodes); sort(all(graph.edges)); itrep(edge, graph.edges) { if (!uf.same(edge->from, edge->to)) { uf.unite(edge->from, edge->to); MinimumSpanningTree.push_back(*edge); } } } public: Kruskal(Graph graph) { this->graph = graph; } ll getMinimumSpanningTreeCost() { searchMinimumSpanningTree(); ll cost = 0; itrep(it, MinimumSpanningTree) { cost += it->cost; } return cost; } }; // ダイクストラ法 O((E+V)logV) // 最小経路問題を解くためのアルゴリズム。辺の重みに負数を含む場合は利用不可 class Dijkstra { private: Graph graph; map<ll, vector<Edge>> fromPaths; vl distances; vl srcs; public: Dijkstra(Graph graph) { this->graph = graph; itrep(edge, graph.edges) { fromPaths[edge->from].push_back(*edge); fromPaths[edge->to].push_back(Edge(edge->to, edge->from, edge->cost)); } } void searchMinimumPathFrom(ll src) { // 複数回呼ばれる度に計算する this->distances = vl(graph.nodes + 1, INF); this->srcs = vl(graph.nodes + 1, INF); priority_queue<ll> pq; distances[src] = 0; srcs[src] = -1; pq.push(src); while (!pq.empty()) { int u = pq.top(); pq.pop(); itrep(edge, fromPaths[u]) { int v = edge->to; int w = edge->cost; if (distances[v] > distances[u] + w) { distances[v] = distances[u] + w; srcs[v] = u; pq.push(v); } } } }; ll getDistance(ll n) { return this->distances[n]; } ll getFrom(ll n) { return this->srcs[n]; } }; // ベルマンフォード O(|V||E|) // 非負コストが含まれていても最短経路問題を解くためのアルゴリズム。閉路の検出も可能 class BellmanFord { private: Graph graph; // 閉路が含まれるかは個々のノードごとに管理する必要あり vector<bool> hasNegativeCycles; vector<ll> distances; public: BellmanFord(Graph graph) { this->graph = graph; this->distances = vector<ll>(this->graph.nodes + 1, INF); this->hasNegativeCycles = vector<bool>(this->graph.nodes + 1, false); } void searchMinimumPathFrom(ll src) { this->distances[src] = 0; for (ll i = 0; i < graph.nodes - 1; i++) { itrep(edge, graph.edges) { ll u = edge->from; ll v = edge->to; ll w = edge->cost; if (this->distances[u] + w < this->distances[v]) { this->distances[v] = this->distances[u] + w; } } } itrep(edge, graph.edges) { ll u = edge->from; ll v = edge->to; ll w = edge->cost; if (this->distances[u] + w < this->distances[v]) { this->hasNegativeCycles[v] = true; } if (this->hasNegativeCycles[u] == true) { this->hasNegativeCycles[v] = true; } } } ll getDistance(ll n) { return this->distances[n]; } bool hasNegativeCycle(ll n) { return this->hasNegativeCycles[n]; } }; void solve(long long N, std::vector<long long> a) { vl pos(N + 1); rep(i, 0, N) { pos[a[i]] = i; } set<ll> checked{0, N + 1}; ll ans = 0; rep(n, 1, N + 1) { ll right = *upper_bound(all(checked), pos[n]); ll left = *(--upper_bound(all(checked), pos[n])); ans += (pos[n] - left) * (right - pos[n]) * n; checked.insert(pos[i]); } print(ans); } int main() { long long N; scanf("%lld", &N); std::vector<long long> a(N); for (int i = 0; i < N; i++) { scanf("%lld", &a[i]); } solve(N, std::move(a)); return 0; }
a.cc: In function 'void solve(long long int, std::vector<long long int>)': a.cc:330:24: error: 'i' was not declared in this scope 330 | checked.insert(pos[i]); | ^
s840284881
p03987
C++
明天AGC005写完,CF1188写完
a.cc:1:1: error: '\U0000660e\U00005929AGC005\U00005199\U00005b8c\U0000ff0cCF1188\U00005199\U00005b8c' does not name a type 1 | 明天AGC005写完,CF1188写完 | ^~~~~~~~~~~~~~~~~~~~~~~~~~