submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s276096402
p03695
C++
// need #include <iostream> #include <algorithm> // data structure #include <bitset> //#include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> //#include <array> //#include <tuple> //#include <unordered_map> //#include <unordered_set> #include <complex> //#include <deque> #include<valarray> // stream //#include <istream> //#include <sstream> //#include <ostream> #include <fstream> // etc #include <cassert> #include <functional> #include <iomanip> //#include <typeinfo> //#include <chrono> #include <random> #include <numeric> #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int i=0; i<n; ++i){MACRO_VEC_ROW_Scan(i, __VA_ARGS__);} template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); } template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest&...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { std::cin >> t[p]; } template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest&...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define OUT(d) std::cout<<d; #define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d; #define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d; #define SP std::cout<<" "; #define TAB std::cout<<"\t"; #define BR std::cout<<"\n"; #define ENDL std::cout<<std::endl; #define FLUSH std::cout<<std::flush; #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i; #define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i; #define ALL(a) (a).begin(),(a).end() #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<int(n);++i) #define RREP(i, n) for(int i=(n)-1;i>=0;--i) #define FORLL(i, a, b) for(ll i=ll(a);i<ll(b);++i) #define RFORLL(i, a, b) for(ll i=ll(b)-1;i>=ll(a);--i) #define REPLL(i, n) for(ll i=0;i<ll(n);++i) #define RREPLL(i, n) for(ll i=ll(n)-1;i>=0;--i) #define PAIR std::pair<int, int> #define PAIRLL std::pair<ll, ll> #define IN(a, x, b) (a<=x && x<b) #define SHOW(d) {std::cerr << #d << "\t:" << d << "\n";} #define SHOWVECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";} #define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}} #define SHOWPAIR(p) {std::cerr << #p << "\t:(" << p.first << ",\t" << p.second << ")\n";} #define SHOWPAIRVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr<<'('<<yyy.first<<", "<<yyy.second<<") ";}std::cerr << "\n";}} #define SHOWPAIRVECTOR(v) {for(const auto& xxx:v){std::cerr<<'('<<xxx.first<<", "<<xxx.second<<") ";}std::cerr<<"\n";} #define SHOWQUEUE(a) {auto tmp(a);std::cerr << #a << "\t:";while(!tmp.empty()){std::cerr << tmp.front() << " ";tmp.pop();}std::cerr << "\n";} template<typename T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; } template<typename T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; } #define EXCEPTION(msg) throw std::string("Exception : " msg " [ in ") + __func__ + " : " + std::to_string(__LINE__) + " lines ]" #define TRY(cond, msg) try {if (cond) EXCEPTION(msg);}catch (std::string s) {std::cerr << s << std::endl;} //void CHECKTIME(std::function<void()> f) { auto start = std::chrono::system_clock::now(); f(); auto end = std::chrono::system_clock::now(); auto res = std::chrono::duration_cast<std::chrono::nanoseconds>((end - start)).count(); std::cerr << "[Time:" << res << "ns (" << res / (1.0e9) << "s)]\n"; } #define int ll using ll = long long; using ull = unsigned long long; constexpr int INFINT = 1 << 30; // 1.07x10^ 9 constexpr int INFINT_LIM = (1LL << 31) - 1; // 2.15x10^ 9 constexpr ll INFLL = 1LL << 60; // 1.15x10^18 constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62); // 9.22x10^18 constexpr double EPS = 1e-7; constexpr int MOD = 1000000007; constexpr double PI = 3.141592653589793238462643383279; signed main() { INIT; VAR(int, n); VEC(int, a, n); std::set<int> set; int cnt = 0; REP(i, n) { int t = a[i]; if (t < 400) set.insert(1); else if (t < 800) set.insert(2); else if (t < 1200) set.insert(3); else if (t < 1600) set.insert(4); else if (t < 2000) set.insert(5); else if (t < 2400) set.insert(6); else if (t < 2800) set.insert(7); else if (t < 3200) set.insert(8); else ++cnt; } int min = std::max(set.size(), 1u); int max = std::min(set.size() + cnt, 8LL); OUT(min)SP OUT(max)BR; return 0; }
a.cc: In function 'int main()': a.cc:111:27: error: no matching function for call to 'max(std::set<long long int>::size_type, unsigned int)' 111 | int min = std::max(set.size(), 1u); | ~~~~~~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /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:111:27: note: deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'unsigned int') 111 | int min = std::max(set.size(), 1u); | ~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /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:111:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int' 111 | int min = std::max(set.size(), 1u); | ~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:112:27: error: no matching function for call to 'min(long long unsigned int, long long int)' 112 | int max = std::min(set.size() + cnt, 8LL); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:112:27: note: deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int') 112 | int max = std::min(set.size() + cnt, 8LL); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:112:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int' 112 | int max = std::min(set.size() + cnt, 8LL); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
s446971877
p03695
C++
#pragma comment(linker, "/STACK:64000000") #include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <cassert> #include <ctime> #include <sstream> #include <algorithm> #include <functional> #include <numeric> #include <string> #include <vector> #include <queue> #include <stack> #include <map> #include <set> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define ll long long #define pii pair < int, int > #define pll pair < long long, long long> #define ull unsigned long long #define y1 stupid_cmath #define left stupid_left #define right stupid_right #define vi vector <int> #define sz(a) (int)a.size() #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) #define all(a) a.begin(), a.end() #define sqr(x) ((x) * (x)) const int inf = (int)1e9; const int mod = inf + 7; const double eps = 1e-9; const double pi = acos(-1.0); int get(int x) { if (x >= 3200) return 0; return x / 400 + 1; } int main(){ /* * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red */ int n; set<int> s; cin >> n; int x; int cnt = 0; while(n--) { cin >> x; if (get(x) == 0) cnt++; else s.insert(get(x)); } cout << s.size() << " " << min(8, s.size() + cnt) << endl; return 0; }
a.cc: In function 'int main()': a.cc:75:35: error: no matching function for call to 'min(int, std::set<int>::size_type)' 75 | cout << s.size() << " " << min(8, s.size() + cnt) << endl; | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:75:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'}) 75 | cout << s.size() << " " << min(8, s.size() + cnt) << endl; | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:10: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:75:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 75 | cout << s.size() << " " << min(8, s.size() + cnt) << endl; | ~~~^~~~~~~~~~~~~~~~~~~
s146140718
p03695
C++
#pragma comment(linker, "/STACK:64000000") #include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <cassert> #include <ctime> #include <sstream> #include <algorithm> #include <functional> #include <numeric> #include <string> #include <vector> #include <queue> #include <stack> #include <map> #include <set> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define ll long long #define pii pair < int, int > #define pll pair < long long, long long> #define ull unsigned long long #define y1 stupid_cmath #define left stupid_left #define right stupid_right #define vi vector <int> #define sz(a) (int)a.size() #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) #define all(a) a.begin(), a.end() #define sqr(x) ((x) * (x)) const int inf = (int)1e9; const int mod = inf + 7; const double eps = 1e-9; const double pi = acos(-1.0); int get(int x) { if (x >= 3200) return 0; return x / 400 + 1; } int main(){ /* * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red */ int n; set<int> s; cin >> n; int x; int cnt = 0; while(n--) { cin >> x; if (get(x) == 0) cnt++; else s.insert(get(x)) } cout << s.size() << " " << min(8, s.size() + cnt) << endl; return 0; }
a.cc: In function 'int main()': a.cc:72:30: error: expected ';' before '}' token 72 | else s.insert(get(x)) | ^ | ; 73 | } | ~ a.cc:75:35: error: no matching function for call to 'min(int, std::set<int>::size_type)' 75 | cout << s.size() << " " << min(8, s.size() + cnt) << endl; | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:75:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'}) 75 | cout << s.size() << " " << min(8, s.size() + cnt) << endl; | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:10: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:75:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 75 | cout << s.size() << " " << min(8, s.size() + cnt) << endl; | ~~~^~~~~~~~~~~~~~~~~~~
s940020892
p03696
Java
import java.math.BigInteger; import java.util.*; public class B { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s=sc.next(); int ob=0; int cb=0; boolean check=false; Deque<Character> dq=new LinkedList<>(); for(int i=0;i<n;i++) { dq.addLast(s.charAt(i)); } Stack<Character> st=new Stack<>(); for(int i=0;i<n;i++) { if(st.isEmpty()) { st.push(s.charAt(i)); continue; } if(st.peek()=='('&&s.charAt(i)==')') { st.pop(); continue; } st.push(s.charAt(i)); } while(!st.isEmpty()) { if(st.peek()=='(') { dq.addLast(')'); st.pop(); }else { dq.addFirst('('); st.pop(); } } for(char i:dq) { System.out.print(i); } System.out.println(); } } class Solution{ public static int minSum(int arr[], int n, int k) { int dp[][][]=new int[n+1][k+1][100001]; for(int i=0;i<=n;i++){ for(int j=0;j<=k;j++){ for(int kk=0;kk<100001;kk++) dp[i][j][kk]=-1; } } int ans=solve(arr,n,n,k,dp,100000); return ans; } static int solve(int arr[],int nn,int n,int k,int dp[][][],int prev){ if(k==1){ int ans=100001; for(int i=0;i<n;i++){ ans=Math.min(ans,arr[i]); } return ans>prev?100001:ans; } if(n==0){ return 100001; } if(dp[n][k][prev]!=-1) { return dp[n][k][prev]; } int ans=100001; if(arr[n-1]<=prev){ ans=Math.min(ans, Math.min(solve(arr,nn,n-1,k-1,dp,arr[n-1])+arr[n-1],solve(arr,nn,n-1,k,dp,prev))); }else{ ans=Math.min(ans, solve(arr,nn,n-1,k,dp,prev)); } return dp[n][k][prev]=ans; } }
Main.java:4: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s833909931
p03696
C++
#include <bits/stdc++.h> using namespace std; #define for0(i, n) for (int i = 0; i < (int)(n); ++i) #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) #define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) #define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) #define forr1(i, n) for (int i = (int)(n); i >= 1; --i) #define deb(x) cout << #x << "= " << x << endl #define pb push_back #define all(x) x.begin(), x.end() #define sortall(x) sort(all(x)) #define tr(x) for(auto it = x.begin(); x != x.end(); it++) #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define MOD 1000000007 typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> vll; typedef vector<vll> vvll; typedef double ld; int main() { fast; int t=1; while(t--){ //begin code here int n; cin>>n; string s; cin>>s; string beginning, ending; int balance=0; for0(i,n){ if(s[i]=='('){ balance++; } else{ balance--; } if(balance<0){ beginning+='(' } } for0(i, balance){ ending+=')'; } cout << beginning + s + ending ; } }
a.cc: In function 'int main()': a.cc:45:31: error: expected ';' before '}' token 45 | beginning+='(' | ^ | ; 46 | } | ~
s610541735
p03696
C++
void solve() { ll n; cin>>n; string s; cin>>s; ll cnt=0; string t=""; for(ll i=0;i<n;i++) { if(s[i]==')' && cnt==0) t='('+t; else if(s[i]==')') cnt--; else cnt++; t+=s[i]; } while(cnt>0) { t+=')'; cnt--; } cout<<t; return; }
a.cc: In function 'void solve()': a.cc:3:9: error: 'll' was not declared in this scope 3 | ll n; | ^~ a.cc:4:9: error: 'cin' was not declared in this scope 4 | cin>>n; | ^~~ a.cc:4:14: error: 'n' was not declared in this scope 4 | cin>>n; | ^ a.cc:5:9: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:6:14: error: 's' was not declared in this scope 6 | cin>>s; | ^ a.cc:7:11: error: expected ';' before 'cnt' 7 | ll cnt=0; | ^~~~ | ; a.cc:8:15: error: expected ';' before 't' 8 | string t=""; | ^~ | ; a.cc:9:15: error: expected ';' before 'i' 9 | for(ll i=0;i<n;i++) | ^~ | ; a.cc:9:20: error: 'i' was not declared in this scope 9 | for(ll i=0;i<n;i++) | ^ a.cc:11:33: error: 'cnt' was not declared in this scope; did you mean 'int'? 11 | if(s[i]==')' && cnt==0) | ^~~ | int a.cc:12:25: error: 't' was not declared in this scope 12 | t='('+t; | ^ a.cc:17:17: error: 't' was not declared in this scope 17 | t+=s[i]; | ^ a.cc:19:15: error: 'cnt' was not declared in this scope; did you mean 'int'? 19 | while(cnt>0) | ^~~ | int a.cc:21:17: error: 't' was not declared in this scope 21 | t+=')'; | ^ a.cc:24:9: error: 'cout' was not declared in this scope 24 | cout<<t; | ^~~~ a.cc:24:15: error: 't' was not declared in this scope 24 | cout<<t; | ^
s256805939
p03696
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s; cin >> s; int cnt)=0; int cnt(=0; stack<char> st; for(int i=0;i<n;++i){ if(!st.empty()){ if(st.top()=='(' && s[i]==')')st.pop(); else st.push(s[i]); } else st.push(s[i]); } while(!st.empty()){ if(st.top()=='(')cnt)++; else cnt(++; st.pop(); } cout << string(cnt(,'(') << s << string(cnt),')'); }
a.cc: In function 'int main()': a.cc:10:12: error: expected initializer before ')' token 10 | int cnt)=0; | ^ a.cc:11:14: error: expected primary-expression before '=' token 11 | int cnt(=0; | ^ a.cc:21:29: error: expected ';' before ')' token 21 | if(st.top()=='(')cnt)++; | ^ | ; a.cc:22:19: error: expected primary-expression before ';' token 22 | else cnt(++; | ^ a.cc:25:29: error: 'cnt' cannot be used as a function 25 | cout << string(cnt(,'(') << s << string(cnt),')'); | ^ a.cc:25:20: error: expected primary-expression before '(' token 25 | cout << string(cnt(,'(') << s << string(cnt),')'); | ^ a.cc:25:25: error: expected primary-expression before ',' token 25 | cout << string(cnt(,'(') << s << string(cnt),')'); | ^ a.cc:25:24: error: 'cnt' cannot be used as a function 25 | cout << string(cnt(,'(') << s << string(cnt),')'); | ~~~^~~~~~ a.cc:25:49: error: no matching function for call to 'std::__cxx11::basic_string<char>::basic_string(int&)' 25 | cout << string(cnt(,'(') << s << string(cnt),')'); | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/basic_string.h:800:9: note: candidate: 'template<class _Tp, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Tp&, const _Alloc&) [with <template-parameter-2-2> = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 800 | basic_string(const _Tp& __t, const _Alloc& __a = _Alloc()) | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:800:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/bits/stl_pair.h:60, 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/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]': /usr/include/c++/14/bits/basic_string.h:149:8: required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = int; _Res = void; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 149 | using _If_sv = enable_if_t< | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:797:30: required from here 797 | template<typename _Tp, typename = _If_sv<_Tp, void>> | ^~~~~~~~ /usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, void>' 2711 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:788:9: note: candidate: 'template<class _Tp, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Tp&, size_type, size_type, const _Alloc&) [with <template-parameter-2-2> = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 788 | basic_string(const _Tp& __t, size_type __pos, size_type __n, | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:788:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:765:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 765 | basic_string(_InputIterator __beg, _InputIterator __end, | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:765:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:669:7: note: candidate: 'template<class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 669 | basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()) | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:669:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:646:7: note: candidate: 'template<class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 646 | basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:646:7: note: template argument deduction/substitution failed: a.cc:25:46: note: cannot convert 'cnt' (type 'int') to type 'const char*' 25 | cout << string(cnt(,'(') << s << string(cnt),')'); | ^~~ /usr/include/c++/14/bits/basic_string.h:721:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 721 | basic_string(basic_string&& __str, const _Alloc& __a) | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:721:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:716:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 716 | basic_string(const basic_string& __str, const _Alloc& __a) | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:716:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:711:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 711 | basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:711:45: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<char>' 711 | basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/basic_string.h:682:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 682 | basic_string(basic_string&& __str) noexcept | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:682:35: note: no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>&&' 682 | basic_string(basic_string&& __str) noexcept | ~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:624:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 624 | basic_string(const _CharT* __s, size_type __n, | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:624:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:604:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 604 | basic_string(const basic_string& __str, size_type __pos, | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:604:7: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:586:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 586 | basic_string(const basic_string& __str, size_type __pos, | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:586:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:569:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 569 | basic_string(const basic_string& __str, size_type __pos, | ^~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:569:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:552:7: note: candidate:
s883849875
p03696
C++
#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; typedef long long int lli; typedef unsigned long long int ulli; #define vec(s) vector<s>; #define vvec(s) vector<vector<s>> ; typedef vector<lli> vi; typedef vector<vi> vvi; typedef pair<lli,lli> pii; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define YN(x) cout<<(bool x?"Yes":"No")<<endl; #define out(s) cout<<s<<endl; #define pb(s) push_back(s); #define sp " "; #define INF 10000000000 #define all(s) s.begin(),s.end() void vout(vector<int> v){ for(int i=0;i<v.size();i++) cout<<v.at(i)<<endl; } int main(){ string s; lli n; lli c=0; string fr,ba; cin>>n>>s; rep(i,n){ if(s[i]=='(') c++; else c--; } while(c!=0){ if(c>0){ fr='('+fr; c--; } else{ ba=ba+')'; c++ } } out(fr<<s<<ba); }
a.cc: In function 'int main()': a.cc:39:16: error: expected ';' before '}' token 39 | c++ | ^ | ; 40 | } | ~
s003335759
p03696
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; string s; cin >> n >> s; ll left = 0; ll right = 0; ll pi = 0; for(int i = 0; i < n; i++){ if(s[i] == '(') left++; if(s[i] == ')') right++; if(left < right){ left++; pi++; } for(int i = 0; i < pi; i++){ cout << '('; } cout << s; for(int i = 0; i < left - right; i++) cout << ')'; cout << endl; }
a.cc: In function 'int main()': a.cc:30:2: error: expected '}' at end of input 30 | } | ^ a.cc:5:1: note: to match this '{' 5 | { | ^
s322523391
p03696
C++
6 )))())
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 6 | ^
s855913239
p03696
Java
import java.util.Scanner; public class Maiin { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); int left = 0; StringBuilder l = new StringBuilder(""); StringBuilder r = new StringBuilder(""); for (int i = 0; i < n; i++) { String ss = s.substring(i, i + 1); if (ss.equals("(")) { left++; } else { if (left == 0) { l.append("("); } else { left--; } } } for (int i = 0; i < left; i++) { r.append(")"); } System.out.println(l.toString() + s + r.toString()); } }
Main.java:5: error: class Maiin is public, should be declared in a file named Maiin.java public class Maiin { ^ 1 error
s454367090
p03696
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) #include <vector> using namespace std; int main(){ int n; cin >> n; string s; cin >> s; vector<int> checked(n,0); int pair = 0; int right = 0; int left = 0; rep(i, n-1){ if(s[i] == '(' && !checked[i]){ //left++; for(int m = i + 1; m < n; m++){ if(s[m] == ')' && !checked[m]){ checked[i] = 1; checked[m] = 1; pair++; break; } } } if(s[i] == '('){ left++; } } right = n - left; if(pair){ int times = left - right; if(times > 0){ // ')' を増やす cout << s; rep(i, times) cout << ')'; cout << "\n; }else if(times < 0){ // '(' を増やす rep(i, times*-1) cout << '('; cout << s << endl; }else{ cout << s << endl; } }else{ rep(i, left) cout << '('; cout << s; rep(i, right) cout << ')'; cout << endl; } return 0; }
a.cc:36:15: warning: missing terminating " character 36 | cout << "\n; | ^ a.cc:36:15: error: missing terminating " character 36 | cout << "\n; | ^~~~ a.cc: In function 'int main()': a.cc:37:5: error: expected primary-expression before '}' token 37 | }else if(times < 0){ // '(' を増やす | ^
s380374231
p03696
Java
class Main { static int mod = (int) (Math.pow(10,9)+7); // static int mod = 998244353; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String S = sc.next(); char[] c = S.toCharArray(); int lcnt=0; int rcnt=0; int fcnt=0; while(c[fcnt]==')') { fcnt++; } for(int i=fcnt;i<N;i++) { if(c[i]=='(')lcnt++; else rcnt++; } char[] ap = new char[1000]; for(int i=0;i<fcnt;i++) { System.out.print("("); } if(lcnt>rcnt) { System.out.print(S); for(int i=0;i<lcnt-rcnt;i++) { System.out.print(")"); } System.out.println(""); } else { for(int i=0;i<rcnt-lcnt;i++) { System.out.print("("); } System.out.print(S); System.out.println(""); } } }
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
s037160753
p03696
C++
#include <iostream> #include <string> using namespace std; string reduce(string s) { auto pos = s.find("()"); if (pos == string::npos) { return s; } return reduce(s.erase(pos, 2)); } int main() { int N; string S; cin >> N >> S; string T = reduce(S); int l = count(T.begin(), T.end(), '('); int r = count(T.begin(), T.end(), ')'); string ans; ans.append(r, '(').append(S).append(l, ')'); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:22:17: error: 'count' was not declared in this scope 22 | int l = count(T.begin(), T.end(), '('); | ^~~~~
s692108515
p03696
C++
#include<bits/stdc++.h> #include <iostream> #include <string> #include <cmath> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORR(i,a,b)for(ll i=(a);i<=(b);i++) #define repR(i,n) for(ll i=n;i>=0;i--) #define all(v)(v).begin(),(v).end() #define rall(v)(v).rbegin(),(v).rend() #define F first #define S second #define pb push_back #define pu push #define COUT(x) cout<<(x)<<endl #define PQ priority_queue<ll> #define PQR priority_queue<ll,vector<ll>,greater<ll>> #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define mp make_pair #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define sz(x) (int)(x).size() typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MOD = 1000000007LL; const ll INF = 1LL << 60; using vll = vector<ll>; using vb = vector<bool>; using vvb = vector<vb>; using vvll = vector<vll>; using vstr = vector<string>; using pll = pair<ll, ll>; int main(){ ll n; string s; cin>>n; cin>>s; ll r=0; ll l=0; rep(i,n){ if(s[i]=='('){ r++; } else if(r>0&&s[i]==')'){ r--; } } for(int i=n-1;i>=0;i--){ if(s[i]==')'){ l++; } else if(l>0&&s[i]=='('){ l--; } } vector<char> lll(0),rr(0) while(l){ lll.pb('('); l--; } while(r){ rr.pb(')'); r--; } rep(i,sz(lll)){ cout<<lll[i]; } cout<<s; rep(i,sz(rr)){ cout<<rr[i]; } }
a.cc: In function 'int main()': a.cc:60:3: error: expected ',' or ';' before 'while' 60 | while(l){ | ^~~~~
s353486805
p03696
C++
#include<bits/stdc++.h> #include <iostream> #include <string> #include <cmath> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORR(i,a,b)for(ll i=(a);i<=(b);i++) #define repR(i,n) for(ll i=n;i>=0;i--) #define all(v)(v).begin(),(v).end() #define rall(v)(v).rbegin(),(v).rend() #define F first #define S second #define pb push_back #define pu push #define COUT(x) cout<<(x)<<endl #define PQ priority_queue<ll> #define PQR priority_queue<ll,vector<ll>,greater<ll>> #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define mp make_pair #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define sz(x) (int)(x).size() typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MOD = 1000000007LL; const ll INF = 1LL << 60; using vll = vector<ll>; using vb = vector<bool>; using vvb = vector<vb>; using vvll = vector<vll>; using vstr = vector<string>; using pll = pair<ll, ll>; int main(){ ll n; string s; cin>>n; cin>>s; ll r=0; ll l=0; rep(i,n){ if(s[i]=='('){ r++; } else if(r>0&&s[i]==')'){ r--; } } for(int i=n-1;i>=0;i--){ if(s[i]==')'){ l++; } else if(l>0&&s[i]=='('){ l--; } } vector<char> ll(0),rr(0) while(l){ ll.pb('('); l--; } while(r){ rr.pb(')'); r--; } rep(i,sz(ll)){ cout<<ll[i]; } cout<<s; rep(i,sz(rr)){ cout<<rr[i]; } }
a.cc: In function 'int main()': a.cc:6:12: error: expected primary-expression before 'long' 6 | #define ll long long | ^~~~ a.cc:59:16: note: in expansion of macro 'll' 59 | vector<char> ll(0),rr(0) | ^~ a.cc:65:5: error: 'rr' was not declared in this scope; did you mean 'r'? 65 | rr.pb(')'); | ^~ | r a.cc:6:12: error: expected primary-expression before 'long' 6 | #define ll long long | ^~~~ a.cc:7:39: note: in definition of macro 'rep' 7 | #define rep(i, n) for (ll i = 0; i < (n); i++) | ^ a.cc:68:9: note: in expansion of macro 'sz' 68 | rep(i,sz(ll)){ | ^~ a.cc:68:12: note: in expansion of macro 'll' 68 | rep(i,sz(ll)){ | ^~ a.cc:6:12: error: expected ')' before 'long' 6 | #define ll long long | ^~~~ a.cc:7:39: note: in definition of macro 'rep' 7 | #define rep(i, n) for (ll i = 0; i < (n); i++) | ^ a.cc:68:9: note: in expansion of macro 'sz' 68 | rep(i,sz(ll)){ | ^~ a.cc:68:12: note: in expansion of macro 'll' 68 | rep(i,sz(ll)){ | ^~ a.cc:25:20: note: to match this '(' 25 | #define sz(x) (int)(x).size() | ^ a.cc:7:39: note: in definition of macro 'rep' 7 | #define rep(i, n) for (ll i = 0; i < (n); i++) | ^ a.cc:68:9: note: in expansion of macro 'sz' 68 | rep(i,sz(ll)){ | ^~ a.cc:7:41: error: expected ')' before ';' token 7 | #define rep(i, n) for (ll i = 0; i < (n); i++) | ~ ^ a.cc:68:3: note: in expansion of macro 'rep' 68 | rep(i,sz(ll)){ | ^~~ a.cc:6:12: error: expected primary-expression before 'long' 6 | #define ll long long | ^~~~ a.cc:69:11: note: in expansion of macro 'll' 69 | cout<<ll[i]; | ^~ a.cc:72:12: error: 'rr' was not declared in this scope; did you mean 'r'? 72 | rep(i,sz(rr)){ | ^~ a.cc:7:39: note: in definition of macro 'rep' 7 | #define rep(i, n) for (ll i = 0; i < (n); i++) | ^ a.cc:72:9: note: in expansion of macro 'sz' 72 | rep(i,sz(rr)){ | ^~
s867415235
p03696
C++
#include <iostream> #include <sstream> #include <algorithm> #include <functional> #include <iterator> #include <numeric> #include <cstdint> #include <cmath> #include <bitset> #include <string> #include <list> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #define N_TIMES(i, n) for ( uint64_t i = 0; i < n; ++i ) #define N_TIMES_REV(i, n) for ( int64_t i = n - 1; i >= 0; --i ) using namespace std; int main() { uint64_t N; cin >> N; string S; cin >> S; vector<int64_t> d(S.size() + 1, 0); N_TIMES(n, S.size()) { d[n + 1] = d[n] + ((S[n] == '(') ? +1 : -1); } debug(d); int64_t min_d = *min_element(d.begin(), d.end()); string left(-min_d, '('); string right(d[S.size()] - min_d, ')'); string T = left + S + right; cout << T << endl; return 0; }
a.cc: In function 'int main()': a.cc:33:3: error: 'debug' was not declared in this scope 33 | debug(d); | ^~~~~
s827706595
p03696
C++
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; string str; string s2; int left(0), right(0); while (n--) { char c; cin >> c; if (s2.empty() || !(s2.back() == '(' && c == ')')) { s2 += c; c == '(' ? left++ : right++; } else if (!s2.empty()) { s2.back() == '(' ? left-- : right--; s2.pop(); } str += c; } cout << string('(', right) << str << string(')', left); return 0; }
a.cc: In function 'int main()': a.cc:18:10: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'pop' 18 | s2.pop(); | ^~~
s447757079
p03696
C++
#include <iostream> #include <string> int main() { int n; cin >> n; string str; string s2; int left(0), right(0); while (n--) { char c; cin >> c; if (s2.empty() || !(s2.back() == '(' && c == ')')) { s2 += c; c == '(' ? left++ : right++; } else if (!s2.empty()) { s2.back() == '(' ? left-- : right--; s2.pop(); } str += c; } cout << string('(', right) << str << string(')', left); return 0; }
a.cc: In function 'int main()': a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 6 | cin >> n; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:7:3: error: 'string' was not declared in this scope 7 | string str; | ^~~~~~ a.cc:7:3: note: suggested alternatives: In file included from /usr/include/c++/14/iosfwd:41, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ In file included from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:8:9: error: expected ';' before 's2' 8 | string s2; | ^~~ | ; a.cc:13:9: error: 's2' was not declared in this scope 13 | if (s2.empty() || !(s2.back() == '(' && c == ')')) { | ^~ a.cc:20:5: error: 'str' was not declared in this scope; did you mean 'std'? 20 | str += c; | ^~~ | std a.cc:22:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 22 | cout << string('(', right) << str << string(')', left); | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:22:33: error: 'str' was not declared in this scope; did you mean 'std'? 22 | cout << string('(', right) << str << string(')', left); | ^~~ | std
s763825671
p03696
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll MOD = 1000000007; const ll INF = 9999999999; template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;} template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;} template<class T> inline T powerM(T a,T b){if (b==0) return a; T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; } int main() { int n; cin >>N; string s; cin >>s; int parL=0, parR=0; for (int i=0; i<n; i++){ if (s.at(i) == '('){ parR++; }else if (s.at(i) == ')'){ if (parR == 0) parL++; else parR--; } } for (int i=0; i<parL; i++) cout <<'('; cout <<s; for (int i=0; i<parR; i++) cout <<')'; cout <<endl; }
a.cc: In function 'int main()': a.cc:16:16: error: 'N' was not declared in this scope 16 | int n; cin >>N; | ^
s766899484
p03696
C
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; int main(){ int n; cin >> n; string s; cin >> s; stack<char> stk; rep(i,n){ if(!stk.empty() && (stk.top() == '(' && s.at(i) == ')')){ stk.pop(); }else{ stk.push(s.at(i)); } } int lcnt = 0; int rcnt = 0; while(!stk.empty()){ if(stk.top() == '('){ lcnt++; }else if(stk.top() == ')'){ rcnt++; } stk.pop(); } string result; rep(i,rcnt) result += '('; result += s; rep(i,lcnt) result += ')'; cout << result << endl; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s417654025
p03696
C++
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; string s; cin >> n >> s; int l = 0, r = 0; int x = n; for(int i = 0; i < n; i++){ if(s[i] == '(') l++; else r++; int d = l-r; x = min(x, d); } for(int i = 0; i < -x; i++) cout << "("; cout << s; for(int i = 0; i < d-x; i++) cout << ")"; cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:24: error: 'd' was not declared in this scope 20 | for(int i = 0; i < d-x; i++) cout << ")"; | ^
s375943333
p03696
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) #define bit(n) (1LL << (n)) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1000000007; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int N; cin >> N; string S; cin >> S; string T = S; rep(i, N) { rep(j, T.size() - 1) { if (T[j] == '(' && T[j + 1] == ')') { T.erase(T.begin() + j, T.begin() + j + 2); continue; } } } int cnt_l = 0, cnt_r = 0; if (i != 0) { rep(i, T.size()) { if (T[i] == ')') cnt_r++; else cnt_l++; } } reverse(all(S)); rep(i, cnt_r) { S.pb('('); } reverse(all(S)); rep(i, cnt_l) { S.pb(')'); } cout << S << endl; }
a.cc: In function 'int main()': a.cc:51:7: error: 'i' was not declared in this scope 51 | if (i != 0) { | ^
s381419896
p03696
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define co(a) cout<<a<<endl #define sz size #define bgn begin() #define en end() #define pb(a) push_back(a) #define pop pop_back #define V vector #define P pair template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } //template<> void cou(vector<vector<char>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } int gcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return f; } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; double b=sqrt(a); for(int i=3;i<=b;i+=2){ if(a%i==0){ return false; } } return true; } struct Union{ vector<int> par; Union(int n){ par= vector<int>(n, -1); } int find(int x){ if(par[x]<0) return x; else return par[x]=find(par[x]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } signed main(){ int a,c=0,d=0; cin>>a; string b; cin>>b; fo(i,b.size()){ if(c==0&&b[i]==')'){ b.insert(b.bgn,'('); i++; d=0; continue; } if(c>0&&b[i]==')'){ c--; d=1; continue; } if(d&&b[i]=='('){ fo(j,c) b.insert(b.bgn+i,')'); i+=c-1; c=0; d=0; continue; } if(b[i]=='('){ c++; continue; } if(i==b.sz-1){ fo(i,c) b.insert(b.bgn+i,')'); break; } } cout<<b<<endl; }
a.cc: In function 'int main()': a.cc:10:12: 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 '()' ?) 10 | #define sz size | ^ a.cc:176:13: note: in expansion of macro 'sz' 176 | if(i==b.sz-1){ | ^~
s100134898
p03696
C++
#include<iostream> #include<vector> #include<string> #include<cmath> #include<algorithm> #include <numeric> #include<map> #include<unordered_map> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;++i) #define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++) #define ALL(a) (a).begin(),(a).end() int main(){ int n; cin >> n; string s; cin >> s; int no = 0; while(s[no++] == ')' && no < n)s.insert(0, "("), no++; int cnt = 0; int pos = 0; rep(i, s.size()){ if(s[i] == '(')cnt++; else cnt--; while(cnt < 0)s.insert(pos, "("), cnt++, i++; pos = i; } while(cnt < 0)s.insert(0, "("), cnt++; while(cnt > 0)s.insert(s.size(), ")"), cnt-- cout << s; }
a.cc: In function 'int main()': a.cc:34:49: error: expected ';' before 'cout' 34 | while(cnt > 0)s.insert(s.size(), ")"), cnt-- | ^ | ; ...... 37 | cout << s; | ~~~~
s442747629
p03696
C++
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define print(x) cout << (x) << endl; #define sz(x) int(x.size()) ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll LLINF = 1LL<<60; const int INF = 1<<29; const int MOD = 1000000007; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void){ cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); int N; cin >> N; string S; cin >> S; int need_left = 0; int pointer = 0; rep(i,S.size()){ if(S[i] == '(') ++pointer; else{ if(pointer == 0) ++need_left++; else --pointer; } } int need_right = pointer; string res = ""; for (int i = 0; i < need_left; ++i) res += '('; res += S; for (int i = 0; i < need_right; ++i) res += ')'; cout << res << endl; }
a.cc: In function 'int main()': a.cc:39:37: error: lvalue required as increment operand 39 | if(pointer == 0) ++need_left++; | ~~~~~~~~~^~
s995953228
p03696
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, i, count = 0, add = 0; string s; cin >> n >> s; for(i = 0; i < s.size(); i++){ if(s.at(i) == ')'){ count++; add = max(add, count); } else{ count--; add = max(add, count); } } for(i = 0; i < add; i++){ cout << "("; } cout << s; for(i = 0; i < addadd-count; i++){ cout << ")"; } cout << endl; }
a.cc: In function 'int main()': a.cc:24:18: error: 'addadd' was not declared in this scope 24 | for(i = 0; i < addadd-count; i++){ | ^~~~~~
s901599732
p03696
C++
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string S; cin >> S; string result; int a = 0; for(int i = 0;i < N;++i){ if(S[i] == '('){ a = a + 1; } if(S[i] == ')'){ if(a > 0){ a = a - 1; std::string result = result + ")"; }else{ std::string result = result + "("; std::string result = result + ")"; } } } if(a > 0){ for(a;a > 0;a = a - 1;){ std::string result = result + ")"; } } cout << result << endl; }
a.cc: In function 'int main()': a.cc:24:23: error: redeclaration of 'std::string result' 24 | std::string result = result + ")"; | ^~~~~~ a.cc:23:23: note: 'std::string result' previously declared here 23 | std::string result = result + "("; | ^~~~~~ a.cc:30:25: error: expected ')' before ';' token 30 | for(a;a > 0;a = a - 1;){ | ~ ^ | ) a.cc:30:26: error: expected primary-expression before ')' token 30 | for(a;a > 0;a = a - 1;){ | ^
s723528927
p03696
C++
8 ))))((((
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 8 | ^
s578199597
p03696
C++
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; string S; cin >> S; int l_sum = 0; vector<int> V; for (int i = 0; i < N; i++) { if (S[i] == '(') { l_sum++; } else l_sum--; V.push_back(l_sum); } int min = *min_element(V.begin(), V.end()); if (V[N-1] - min > 0) { string temp(V[N-1] - min , ')'); S += temp; } if (min < 0) { string temp( -min , '('); S = temp + S; } cout << S << '\n'; }
a.cc: In function 'int main()': a.cc:23:16: error: 'min_element' was not declared in this scope 23 | int min = *min_element(V.begin(), V.end()); | ^~~~~~~~~~~
s399582358
p03696
C++
#include <bits/stdc++.h> using namespace std; int N; string S; void abc064d() { int cnt[2] = {0, 0}; string res = S; if (S[0] == '(') { cnt[0]++; } else { cnt[1]++; } for (int i = 1; i < N; i++) { if (S[i] == '(') { cnt[0]++; } else if (S[i] == ')') { cnt[1]++; } if (S[i - 1] == ')' && S[i] == '(') { cout << ")( is found\n"; int d = abs(cnt[0] - cnt[1]); if (cnt[0] > cnt[1]) { for (int j = 0; j < d; j++) { res = res + ")"; cnt[1]++; } else { for (int j = 0; j <= d; j++) { res = "(" + res; cnt[0]++; } } } } } int d = abs(cnt[0] - cnt[1]); if (cnt[0] > cnt[1]) { for (int j = 0; j < d; j++) { res = res + ")"; cnt[1]++; } } else { for (int j = 0; j < d; j++) { res = "(" + res; cnt[0]++; } } cout << res << "\n"; return; } int main() { cin >> N >> S; abc064d(); return 0; }
a.cc: In function 'void abc064d()': a.cc:33:9: error: expected '}' before 'else' 33 | else { | ^~~~ a.cc:28:28: note: to match this '{' 28 | if (cnt[0] > cnt[1]) { | ^ a.cc: At global scope: a.cc:42:15: error: 'cnt' was not declared in this scope; did you mean 'int'? 42 | int d = abs(cnt[0] - cnt[1]); | ^~~ | int a.cc:42:24: error: 'cnt' was not declared in this scope; did you mean 'int'? 42 | int d = abs(cnt[0] - cnt[1]); | ^~~ | int a.cc:43:3: error: expected unqualified-id before 'if' 43 | if (cnt[0] > cnt[1]) { | ^~ a.cc:49:3: error: expected unqualified-id before 'else' 49 | else { | ^~~~ a.cc:56:3: error: 'cout' does not name a type 56 | cout << res << "\n"; | ^~~~ a.cc:57:3: error: expected unqualified-id before 'return' 57 | return; | ^~~~~~ a.cc:58:1: error: expected declaration before '}' token 58 | } | ^
s888286313
p03696
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int r=0;l=0; string s; cin>>s; for(int i=0;i<n;i++){ if(s[i]=='('){ l++; }else{ if(l>0){ l--; }else{ r++; } } } for(int i=0;i<r;i++){ cout<<'('; } cout<<s; for(int i=0;i<l;i++){ cout<<')'; } }
a.cc: In function 'int main()': a.cc:6:11: error: 'l' was not declared in this scope 6 | int r=0;l=0; | ^
s792483822
p03696
C++
#include<bits/stdc++.h> int main(){ int n; cin>>n; string s; cin>>s; int cnt1=0,cnt2=0; for(int i=0; i<n; i++){ cin>>s[i]; if(s[i]=='('){cnt1++;} else{ if(cnt1>0){cnt1--;} else b++; } } if(b>0){ for(int i=0; i<b; i++){ cout<<'('; } } cout<<s; if(a>0){ for(int i=0; i<a; i++){ cout<<')'; } } cout<<endl; }
a.cc: In function 'int main()': a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 4 | cin>>n; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:5:3: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:5:3: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:6:8: error: 's' was not declared in this scope 6 | cin>>s; | ^ a.cc:13:12: error: 'b' was not declared in this scope 13 | else b++; | ^ a.cc:16:6: error: 'b' was not declared in this scope 16 | if(b>0){ | ^ a.cc:18:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 18 | cout<<'('; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:21:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 21 | cout<<s; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:22:6: error: 'a' was not declared in this scope 22 | if(a>0){ | ^ a.cc:27:11: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 27 | cout<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s747730830
p03696
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; string s;cin>.s; string t="",u=""; vector<string> v={}; int a=0; for(int i=0;i<n-1;i++){ if(s[i]==')'&&s[i+1]=='('){ v.push_back(substr(a,i-a+1)); a=i+1; } } v.push_back(substr(a,n-a)); for(int i=0;i<v.size();i++){ int l=0,r=0; for(int j=0;j<v[i].size();j++){ if(v[i][j]==')') l++; if(v[i][j]=='(') r++; } if(l>r){ for(int k=0;k<l-r;k++){ t+="("; } } if(l<r){ for(int k=0;k<r-l;k++){ u+=")"; } } } cout<<t+s+u<<endl; }
a.cc: In function 'int main()': a.cc:5:16: error: expected primary-expression before '.' token 5 | string s;cin>.s; | ^ a.cc:11:19: error: 'substr' was not declared in this scope; did you mean 'strstr'? 11 | v.push_back(substr(a,i-a+1)); | ^~~~~~ | strstr a.cc:15:15: error: 'substr' was not declared in this scope; did you mean 'strstr'? 15 | v.push_back(substr(a,n-a)); | ^~~~~~ | strstr
s333646916
p03696
C++
//smartphone #include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int i=0;i<n;++i) int main(){ int n,a=0,b=0;cin>>n;if(!n)cout<<"()",return 0; string s;cin>>s;rep(i,n){ a+=s[i]-'('?-1:1; b=min(a,b);}b=max(0,-b); if(a<0)rep(i,-a)s.insert(0,"(");else rep(i,a)s.push_back(')'); rep(i,b-abs(a)){s.insert(0,"(");s.push_back(')');}cout<<s; }
a.cc: In function 'int main()': a.cc:6:40: error: expected primary-expression before 'return' 6 | int n,a=0,b=0;cin>>n;if(!n)cout<<"()",return 0; | ^~~~~~
s191274754
p03696
C++
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<utility> #include<numeric> #include<vector> #include<map> #include<unordered_map> #include<set> #include<tuple> #include<stack> #include<queue> #include<functional> #include<iterator> #include<cmath> #include<cctype> using namespace std; typedef long long ll; typedef pair<int,int> P; const int INF = 1e9; const ll LINF = 1e18; struct edge{int to,cost;}; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n >> s; int head=0; int l=0,r=0,ml=0; char prev='-'; for(int i=0;i<n;i++){ if(s[i]=='('){ if(prev != ')') l++; //(((((( else{ //))))( if(ml+l < r) { head+=r-(ml+l); ml = 0; else if(ml+l > r){ ml += l - r; }else{ ml = 0; } r=0; l=1; //自分の prev='('; } }else{//) if(prev!='(') r++; //))))) else{//(((() r++; prev=')'; } } if(i==0) prev = s[0]; } // cout << head << " " << ml << " " << l << " " << r << "\n"; head += max(r-l-ml,0); for(int i=0;i<head;i++) cout << "("; cout << s; for(int i=0;i<ml+l-r;i++) cout << ")"; cout << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:48:33: error: expected '}' before 'else' 48 | else if(ml+l > r){ | ^~~~ a.cc:45:46: note: to match this '{' 45 | if(ml+l < r) { | ^
s752350217
p03696
C++
include <iostream> #include <algorithm> #include <cmath> #include <limits> #include <vector> #include <cstdio> #include <bits/stdc++.h> #include <set> #include <map> #include <stdio.h> #include <stack> #include <queue> #include <deque> #include <numeric> #define MAX 100000007 using namespace std; using ll = long long; map <int ,int> mpa,mpb; typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P>> pque; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int N,M; cin >> N >> M; int a[M],b[M]; ll c[M]; ll ans=0; ll dp[1001]; for(int i=0;i<M;i++){ cin >> a[i] >> b[i] >> c[i]; c[i]=-c[i]; a[i]=a[i]-1; b[i]=b[i]-1; } for(int i=0;i<N;i++){ dist[i]=MAX; } dist[0]=0; for(int loop=0;loop<N-1;loop++){ for(int i=0;i<M;i++){ if(a[i]==INF) continue; if(dist[b[i]] > dist[a[i]]+c[i]){ dist[b[i]]=dist[a[i]]+c[i]; } } } ans =dist[N-1]; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
s813907620
p03696
C++
#include <bits/stdc++.h> using namespace std; int main() { string s; string le, ri; int n = 0; int l = 0, r = 0; cin >> n >> s; for (int i = 0; i < n; i++) if (s[i] == ')') l++; for (int i = 0; i < n; i++) if (s[i] == '(') r++; for (int i = 0; i < n; i++) { if (s[i] == '(') { for (int j = i + 1; j < n; j++) { if (s[j] == ')') { a--; r--; l--; break; } } } } for (int i = 0; i < l; i++) ri += '('; for (int i = 0; i < r; i++) le += ')'; cout << ri << s << le << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:21: error: 'a' was not declared in this scope 18 | a--; | ^
s466280765
p03696
C++
#include <bits/stdc++.h> using namespace std; int main() { string s; string le, ri; int n = 0; int l = 0, r = 0; cin >> n >> s; for (int i = 0; i < n; i++) if (s[i] == ')') l++; for (int i = 0; i < n; i++) if (s[i] == '(') r++; for (int i = 0; i < n; i++) { if (s[i] == '(') { for (int j = i + 1; j < n; j++) { if (s[j] == ')') { a--; r--; l--; break; } } } } for (int i = 0; i < l; i++) ri += '('; for (int i = 0; i < r; i++) le += ')'; cout << ri << s << le << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:21: error: 'a' was not declared in this scope 18 | a--; | ^
s595938600
p03696
C++
#include<iostream> #include<string> using namespace std; int main() { int N; string s; cin >> N >> s; int x = 1e9 + 1; int d; for(int i = 0; i <= N; i++) { string ss = s.substr(0, i); int l = count(ss.begin(), ss.end(), '('); int r = count(ss.begin(), ss.end(), ')'); d = l - r; x = min(x, d); } string ans = string(-x, '(') + s + string(d-x, ')'); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'count' was not declared in this scope 14 | int l = count(ss.begin(), ss.end(), '('); | ^~~~~
s181252385
p03696
Java
import org.apache.commons.lang3.*; import java.util.*; public class Main { public void main(Scanner sc) { int n = sc.nextInt(); String s = sc.next(); int lastClose = s.lastIndexOf(')'); lastClose = lastClose == -1 ? n : lastClose; int firstOpen = s.indexOf('('); firstOpen = firstOpen == -1 ? 0 : firstOpen; int head = 0; for (int i = 0; i <= lastClose; i++) { head += (s.charAt(i) == ')') ? 1 : -1; } head = Math.max(0, head); int foot = 0; for (int i = n - 1; i >= firstOpen; i--) { foot += (s.charAt(i) == '(') ? 1 : -1; } foot = Math.max(0, foot); System.out.println(StringUtils.repeat('(', head) + s + StringUtils.repeat(')', foot)); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); new Main().main(sc); sc.close(); } }
Main.java:1: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.*; ^ Main.java:28: error: cannot find symbol System.out.println(StringUtils.repeat('(', head) + s + StringUtils.repeat(')', foot)); ^ symbol: variable StringUtils location: class Main Main.java:28: error: cannot find symbol System.out.println(StringUtils.repeat('(', head) + s + StringUtils.repeat(')', foot)); ^ symbol: variable StringUtils location: class Main 3 errors
s804755669
p03696
C++
#include <bits/stdc++.h> using namespace std; string s; int n,d,c; int main() { cin>>n>>s; for(int i=0;i<n;i++){if(s[i]=='(')c++;else c--;d=min(c,d); for(int i=0;i<-d;i++)cout<<'(';cout<<s; for(int i=0;i<c-d;i++)cout<<')'; }
a.cc: In function 'int main()': a.cc:10:2: error: expected '}' at end of input 10 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s803844935
p03696
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <cmath> #include <cstdlib> #include <tuple> using ll = long long; using namespace std; #define modmod 1000000007 int main(){ int N; string S; cin >> N >> S; int left=0, right=0; string result; for(int i = 0; i < N; i ++){ if(S[i] == '('){ left++; }else{ right++; } result.push_back(S[i]); if(right > left){ result.insert(ans.begin(),'('); left++; } } for(int i = 0; i < left-right; i ++){ result.push_back(')'); } printf("%s",result.c_str()); return 0; }
a.cc: In function 'int main()': a.cc:28:27: error: 'ans' was not declared in this scope; did you mean 'abs'? 28 | result.insert(ans.begin(),'('); | ^~~ | abs
s605788543
p03696
C++
#include <iostream> #include <vector> #include <string> #include <tuple> using namespace std; pair<int,int> count_bra(string str){ vector<int> d(str.length()+1); d[0] = 0; for(int j=0;j<str.length();j++){ if(str[j] == '(') d[j+1] = d[j] + 1; if(str[j] == ')') d[j+1] = d[j] - 1; } return make_pair(*min_element(d.begin()+1, d.end()), d[str.length()]); } int main(){ int N; string S; cin >> N >> S; int x,d; tie(x,d) = count_bra(S); cout << x << " " << d << endl; for(int i=0;i<abs(x);i++){ S = '(' + S; } for(int i=0;i<d+abs(x);i++){ S.push_back(')'); } cout << S << endl; return 0; }
a.cc: In function 'std::pair<int, int> count_bra(std::string)': a.cc:15:23: error: 'min_element' was not declared in this scope 15 | return make_pair(*min_element(d.begin()+1, d.end()), d[str.length()]); | ^~~~~~~~~~~
s232142852
p03696
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; string s; cin>>n>>s; int l=0,r=0,d=0; for(int i=0;i<s.size();++i){ if(s[i]=='(') ++l; else ++r; chmax(d,r-l); } string ans(d,'('); ans+=s; ans.append(l+d-r,')'); cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:12:17: error: 'chmax' was not declared in this scope 12 | chmax(d,r-l); | ^~~~~
s997006966
p03696
C++
#include <bits/stdc++.h> using namespace std; #define loop(i, a, b) for(int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define all(a) (a).begin(),(a).end() using namespace std; const int MOD = 1e9 + 7, INF = 1e9; using vi = vector <int>; using vvi = vector <vi>; int main(){ int n; string s; cin >> n >> s; int num_right = 0; rep(i, n){ if(s[i] == ')')num_right++; } int num_left = num_right; if(num_right > num_left) rep(i, num_right - num_left) cout << "("; cout << s << endl; else{ cout << s; rep(i, num_left - num_right) cout << ")"; cout << endl; } }
a.cc: In function 'int main()': a.cc:23:5: error: 'else' without a previous 'if' 23 | else{ | ^~~~
s433290559
p03696
C++
#include <bits/stdc++.h> using namespace std; #define loop(i, a, b) for(int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define all(a) (a).begin(),(a).end() using namespace std; const int MOD = 1e9 + 7, INF = 1e9; using vi = vector <int>; using vvi = vector <vi>; int main(){ int n; string s; cin >> n >> s; int num_right = 0; rep(i, n){ if(s[i] == ')')num_right++; } int num_left = num_right; if(num_right > num_left) rep(i, num_right - num_left) cout << "("; cout << s << endl; else{ cout << s; rep(i, num_left - num_right) cout << ")"; } }
a.cc: In function 'int main()': a.cc:23:5: error: 'else' without a previous 'if' 23 | else{ | ^~~~
s232042246
p03696
C++
#include<stdio.h> #include<malloc.h> int main() { int N; char* S; char* stack[101]; int stack_number = 0; int i, j; int left_count = 0; int right_count = 0; scanf("%d", &N); S = (char *)malloc(sizeof(char) * (N+1)); scanf("%s", S); for(i = 0; i < N; i++) { stack[stack_number] = S[i]; stack_number++; if(stack_number > 1 && stack[stack_number-1] == ')') { for(j = stack_number-2; j >= 0; j--) { if(stack[j] == '(') { stack_number -= 2; break; } } } } for(i = 0; i < stack_number; i++) { if(stack[i] == '(') left_count++; else right_count++; } for(i = 0; i < right_count; i++) putchar('('); printf("%s", S); for(i = 0; i < left_count; i++) putchar(')'); return 0; }
a.cc: In function 'int main()': a.cc:20:34: error: invalid conversion from 'char' to 'char*' [-fpermissive] 20 | stack[stack_number] = S[i]; | ~~~^ | | | char a.cc:22:54: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 22 | if(stack_number > 1 && stack[stack_number-1] == ')') { | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~ a.cc:24:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 24 | if(stack[j] == '(') { | ~~~~~~~~~^~~~~~ a.cc:33:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 33 | if(stack[i] == '(') left_count++; | ~~~~~~~~~^~~~~~
s977738091
p03696
C++
import java.util.*; import java.math.*; import java.io.*; class Main{ public static InputReader sc; public static PrintWriter out; public static final long MOD = (long)1e9 + 7L; public static void main(String[] args){ sc=new InputReader(System.in); out=new PrintWriter(System.out); int n=sc.nextInt(); char[] A=sc.readString().toCharArray(); String ans=""; Stack<Character> s=new Stack<Character>(); for(int i=0;i<n;i++){ if(A[i]=='('){ s.push(A[i]); } else{ if(!s.isEmpty() && s.peek()=='('){ s.pop(); ans+="()"; } else{ ans='('+ans; ans+=')'; } } //out.println(ans); } while(!s.isEmpty()){ ans+="()"; s.pop(); } out.println(ans); out.close(); } // static class Pair{ // String x; // int y; // Pair(){ // this.x=""; // this.y=-1; // } // Pair(String profit,int val,int count){ // this.x=profit; // this.y=val; // } // public static Comparator<Pair> Val=new Comparator<Pair>(){ // public int compare(Pair p1,Pair p2){ // if(p1.x==p2.y){ // return p1.y-p2.y; // } // return (int)p1.x-(int)p2.x; // } // }; // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + x; // result = prime * result + x; // return result; // } // public boolean equals(Object obj){ // if (this == obj) // return true; // if (!(obj instanceof Pair)) { // return false; // } // // Pair p = (Pair) obj; // if(p.x!=this.x){ // return false; // } // else if(p.y!=p.y){ // return false; // } // return true; // } // } static class DisjointSet{ int n; int[] par; int[] rank; DisjointSet(int n){ this.n=n; this.par=new int[n]; this.rank=new int[n]; makeSet(); } void makeSet(){ for(int i=0;i<n;i++){ par[i]=i; rank[i]=1; } } void union(int x,int y){ int parX=parent(x); int parY=parent(y); if(parX!=parY){ if(rank[parX]>=rank[parY]){ rank[parX]+=rank[parY]; rank[parY]=0; par[parY]=parX; } else{ rank[parY]+=rank[parX]; rank[parX]=0; par[parX]=parY; } } } int parent(int c){ int i=c; while(i!=par[i]){ i=par[i]; } return i; } } static int gcd(int a,int b){ if(b==0){ return a; } return gcd(b,a%b); } static int lcm(int a,int b){ int g; if(a<b){ g=gcd(b,a); } else{ g=gcd(a,b); } return (a*b)/g; } static long bigmod ( long a, long p, long m ) { long res = 1 % m, x = a % m; while ( p>0 ) { if ( (p & 1)==1 ) res = ( res * x ) % m; x = ( x * x ) % m; p >>= 1; } return res; } static boolean isPrime(int n){ if (n == 2) return true; for (long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } static void shuffle(int[] A){ for(int i=A.length-1;i>0;i--){ int j=(int)(Math.random()*(i+1)); int temp=A[j]; A[j]=A[i]; A[i]=temp; } } // public static class Node implements Comparable<Node>{ // int u; // int v; // public Node(){ // ; // } // public Node (int u, int v) { // this.u = u; // this.v = v; // } // // public void print() { // out.println(v + " " + u + " "); // } // // public int compareTo(Node n1){ // return this.u-n1.u; // } // } public static long pow(long base,long exp,long mod){ if(exp==0){ return 1; } if(exp==1){ return base; } long temp=exp/2; long val=pow(base,temp,mod); long result=val*val; result=(result%mod); long AND=exp&1; if(AND==1){ result*=base; result=(result%mod); } return result; } public static BigInteger pow(BigInteger base, BigInteger exp) { if(exp.equals(new BigInteger(String.valueOf(0)))){ return new BigInteger(String.valueOf(1)); } if(exp.equals(new BigInteger(String.valueOf(1)))) return base; BigInteger temp=exp.divide(new BigInteger(String.valueOf(2))); BigInteger val = pow(base, temp); BigInteger result = val.multiply(val); result=result.remainder(new BigInteger(String.valueOf(MOD))); BigInteger AND=exp.and(new BigInteger(String.valueOf(1))); if(AND.equals(new BigInteger(String.valueOf(1)))){ result = result.multiply(base); result=result.remainder(new BigInteger(String.valueOf(MOD))); } return result; } static class InputReader { private InputStream stream; private byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) c = snext(); int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = snext(); while (isSpaceChar(c)) c = snext(); int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public String readString() { int c = snext(); while (isSpaceChar(c)) c = snext(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.math.*; | ^~~~~~ 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.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:15: error: expected ':' before 'static' 5 | public static InputReader sc; | ^~~~~~~ | : a.cc:5:23: error: 'InputReader' does not name a type 5 | public static InputReader sc; | ^~~~~~~~~~~ a.cc:6:11: error: expected ':' before 'static' 6 | public static PrintWriter out; | ^~~~~~~ | : a.cc:6:19: error: 'PrintWriter' does not name a type 6 | public static PrintWriter out; | ^~~~~~~~~~~ a.cc:7:11: error: expected ':' before 'static' 7 | public static final long MOD = (long)1e9 + 7L; | ^~~~~~~ | : a.cc:7:19: error: 'final' does not name a type 7 | public static final long MOD = (long)1e9 + 7L; | ^~~~~ a.cc:8:11: error: expected ':' before 'static' 8 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:8:29: error: 'String' has not been declared 8 | public static void main(String[] args){ | ^~~~~~ a.cc:8:38: error: expected ',' or '...' before 'args' 8 | public static void main(String[] args){ | ^~~~ a.cc:84:12: error: expected unqualified-id before '[' token 84 | int[] par; | ^ a.cc:85:12: error: expected unqualified-id before '[' token 85 | int[] rank; | ^ a.cc:98:19: error: expected identifier before '(' token 98 | void union(int x,int y){ | ^ a.cc:98:20: error: expected unqualified-id before 'int' 98 | void union(int x,int y){ | ^~~ a.cc:98:20: error: expected ')' before 'int' 98 | void union(int x,int y){ | ~^~~ | ) a.cc:121:6: error: expected ';' after class definition 121 | } | ^ | ; a.cc:82:5: error: a storage class can only be specified for objects and functions 82 | static class DisjointSet{ | ^~~~~~ a.cc:147:12: error: 'boolean' does not name a type; did you mean 'bool'? 147 | static boolean isPrime(int n){ | ^~~~~~~ | bool a.cc:157:31: error: expected ',' or '...' before 'A' 157 | static void shuffle(int[] A){ | ^ a.cc:185:15: error: expected ':' before 'static' 185 | public static long pow(long base,long exp,long mod){ | ^~~~~~~ | : a.cc:203:15: error: expected ':' before 'static' 203 | public static BigInteger pow(BigInteger base, BigInteger exp) { | ^~~~~~~ | : a.cc:203:23: error: 'BigInteger' does not name a type 203 | public static BigInteger pow(BigInteger base, BigInteger exp) { | ^~~~~~~~~~ a.cc:223:20: error: expected ':' before 'InputStream' 223 | private InputStream stream; | ^~~~~~~~~~~~ | : a.cc:223:21: error: 'InputStream' does not name a type 223 | private InputStream stream; | ^~~~~~~~~~~ a.cc:224:20: error: expected ':' before 'byte' 224 | private byte[] buf = new byte[8192]; | ^~~~~ | : a.cc:224:21: error: 'byte' does not name a type 224 | private byte[] buf = new byte[8192]; | ^~~~ a.cc:225:20: error: expected ':' before 'int' 225 | private int curChar, snumChars; | ^~~~ | : a.cc:226:20: error: expected ':' before 'SpaceCharFilter' 226 | private SpaceCharFilter filter; | ^~~~~~~~~~~~~~~~ | : a.cc:226:21: error: 'SpaceCharFilter' does not name a type 226 | private SpaceCharFilter filter; | ^~~~~~~~~~~~~~~ a.cc:228:19: error: expected ':' before 'InputReader' 228 | public InputReader(InputStream stream) { | ^~~~~~~~~~~~ | : a.cc:228:43: error: expected ')' before 'stream' 228 | public InputReader(InputStream stream) { | ~ ^~~~~~~ | ) a.cc:232:19: error: expected ':' before 'int' 232 | public int snext() { | ^~~~ | : a.cc:248:19: error: expected ':' before 'int' 248 | public int nextInt() { | ^~~~ | : a.cc:268:19: error: expected ':' before 'long' 268 | public long nextLong() { | ^~~~~ | : a.cc:288:19: error: expected ':' before 'int' 288 | public int[] nextIntArray(int n) { | ^~~~ | : a.cc:288:23: error: expected unqualified-id before '[' token 288 | public int[] nextIntArray(int n) { | ^ a.cc:295:19: error: expected ':' before 'String' 295 | public String readString() { | ^~~~~~~ | : a.cc:295:20: error: 'String' does not name a type 295 | public String readString() { | ^~~~~~ a.cc:307:19: error: expected ':' before 'boolean' 307 | public boolean isSpaceChar(int c) { | ^~~~~~~~ | : a.cc:307:20: error: 'boolean' does not name a type; did you mean 'bool'? 307 | public boolean isSpaceChar(int c) { | ^~~~~~~ | bool a.cc:313:19: error: expected ':' before 'interface' 313 | public interface SpaceCharFilter { | ^~~~~~~~~~ | : a.cc:313:20: error: 'interface' does not name a type 313 | public interface SpaceCharFilter { | ^~~~~~~~~ a.cc:316:10: error: expected ';' after class definition 316 | } | ^ | ; a.cc:221:9: error: a storage class can only be specified for objects and functions 221 | static class InputReader { | ^~~~~~ a.cc:318:2: error: expected ';' after class definition 318 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:9:9: error: 'sc' was not declared in this scope 9 | sc=new InputReader(System.in); | ^~ a.cc:9:28: error: 'System' was not declared in this scope 9 | sc=new InputReader(System.in); | ^~~~~~ a.cc:10:9: error: 'out' was not declared in this scope 10 | out=new PrintWriter(System.out); | ^~~ a.cc:10:17: error: expected type-specifier before 'PrintWriter' 10 | out=new PrintWriter(System.out); | ^~~~~~~~~~~ a.cc:12:13: error: structured binding declaration cannot have type 'char' 12 | char[] A=sc.readString().toCharArray(); | ^~ a.cc:12:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:12:13: error: empty structured binding declaration a.cc:12:16: error: expected initializer before 'A' 12 | char[] A=sc.readString().toCharArray(); | ^ a.cc:13:9: error: 'String' was not declared in this scope 13 | String ans=""; | ^~~~~~ a.cc:14:9: error: 'Stack' was not declared in this scope 14 | Stack<Character> s=new Stack<Character>(); | ^~~~~ a.cc:14:15: error: 'Character' was not declared in this scope 14 | Stack<Character> s=new Stack<Character>(); | ^~~~~~~~~ a.cc:14:26: error: 's' was not declared in this scope 14 | Stack<Character> s=new Stack<Character>(); | ^ a.cc:14:32: error: 'Stack' does not name a type 14 | Stack<Character> s=new Stack<Character>(); | ^~~~~ a.cc:14:49: error: expected primary-expression before ')' token 14 | Stack<Character> s=new Stack<Character>(); | ^ a.cc:16:20: error: 'A' was not declared in this scope 16 | if(A[i]=='('){ | ^ a.cc:22:33: error: 'ans' was not declared in this scope 22 | ans+="()"; | ^~~ a.cc:25:33: error: 'ans' was not declared in this scope 25 | ans='('+ans; | ^~~ a.cc:32:17: error: 'ans' was not declared in this scope 32 | ans+="()"; | ^~~ a.cc:35:21: error: 'ans' was not declared in this scope 35 | out.println(ans); | ^~~ a.cc: In constructor 'Main::DisjointSet::DisjointSet(int)': a.cc:87:22: error: request for member 'n' in '(Main::DisjointSet*)this', which is of pointer type 'Main::DisjointSet*' (maybe you meant to use '->' ?) 87 | this.n=n; | ^ a.cc:88:22: error: request for member 'par' in '(Main::DisjointSet*)this', which is of pointer type 'Main::DisjointSet*' (maybe you meant to use '->' ?) 88 | this.par=new int[n]; | ^~~ a.cc:89:22: error: request for member 'rank' in '(Main::DisjointSet*)this', which is of pointer type 'Main::Disjo
s828708211
p03696
C++
#include <vector> // vectorを使うためにインクルードする #include <iostream> #include the <algorithm> using namespace std; int main() { int N; cin >> N; vector<int> vec; string s; cin >> s; for(int i=0;i<N;i++){ if(i==0){ if(s[i]=='(')vec.push_back(1); else{vec.push_back(-1);} } else if(s[i]=='('){vec.push_back(vec[i-1]+1);} else{vec.push_back(vec[i-1]-1);} } int mini = -1*(*min_element(vec.begin(),vec.end())); if(mini<0)mini=0; int last = mini + vec[N-1]; for(int i=0;i<mini;i++){ cout << "("; } for(int i=0;i<N;i++){ cout << s[i]; } for(int i=0;i<last;i++){ cout << ")"; } cout << endl; }
a.cc:3:10: error: #include expects "FILENAME" or <FILENAME> 3 | #include the <algorithm> | ^~~ a.cc: In function 'int main()': a.cc:22:33: error: 'min_element' was not declared in this scope 22 | int mini = -1*(*min_element(vec.begin(),vec.end())); | ^~~~~~~~~~~
s880136400
p03696
C++
#include <vector> // vectorを使うためにインクルードする #include <iostream> using namespace std; int main() { int N; cin >> N; vector<int> vec; string s; cin >> s; for(int i=0;i<N;i++){ if(i==0){ if(s[i]=='(')vec.push_back(1); else{vec.push_back(-1);} } else if(s[i]=='('){vec.push_back(vec[i-1]+1);} else{vec.push_back(vec[i-1]-1);} } int mini = -1*(*min_element(vec.begin(),vec.end())); if(mini<0)mini=0; int last = mini + vec[N-1]; for(int i=0;i<mini;i++){ cout << "("; } for(int i=0;i<N;i++){ cout << s[i]; } for(int i=0;i<last;i++){ cout << ")"; } cout << endl; }
a.cc: In function 'int main()': a.cc:21:33: error: 'min_element' was not declared in this scope 21 | int mini = -1*(*min_element(vec.begin(),vec.end())); | ^~~~~~~~~~~
s654270030
p03696
C++
#include <vector> // vectorを使うためにインクルードする #include <iostream> using namespace std; int main() { int N; cin >> N; vector<int> vec; string s; cin >> s; for(int i=0;i<N;i++){ if(i==0){ if(s[i]=='(')vec.push_back(1); else{vec.push_back(-1);} } else if(s[i]=='('){vec.push_back(vec[i-1]+1);} else{vec.push_back(vec[i-1]-1);} } int mini = -1*(*std::min_element(vec.begin(),vec.end())); if(mini<0)mini=0; int last = mini + vec[N-1]; for(int i=0;i<mini;i++){ cout << "("; } for(int i=0;i<N;i++){ cout << s[i]; } for(int i=0;i<last;i++){ cout << ")"; } cout << endl; }
a.cc: In function 'int main()': a.cc:21:38: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'? 21 | int mini = -1*(*std::min_element(vec.begin(),vec.end())); | ^~~~~~~~~~~ | tuple_element
s905756374
p03696
C++
#include <vector> // vectorを使うためにインクルードする #include <iostream> using namespace std; int main() { int N; cin >> N; vector<int> vec; string s; cin >> s; for(int i=0;i<N;i++){ if(i==0){ if(s[i]=='(')vec.push_back(1); else{vec.push_back(-1);} } else if(s[i]=='('){vec.push_back(vec[i-1]+1);} else{vec.push_back(vec[i-1]-1);} } int min = -1*(*std::min_element(vec.begin(),vec.end())); if(min<0)min=0; int last = min + vec[N-1]; for(int i=0;i<min;i++){ cout << "("; } for(int i=0;i<N;i++){ cout << s[i]; } for(int i=0;i<last;i++){ cout << ")"; } cout << endl; }
a.cc: In function 'int main()': a.cc:21:37: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'? 21 | int min = -1*(*std::min_element(vec.begin(),vec.end())); | ^~~~~~~~~~~ | tuple_element
s606378299
p03696
C++
#include <vector> // vectorを使うためにインクルードする #include <iostream> using namespace std; int main() { int N; cin >> N; vector<int> vec; string s; cin >> s; for(int i=0;i<N;i++){ if(i==0){ if(s[i]=='(')vec.push_back(1); else{vec.push_back(-1);} } else if(s[i]=='('){vec.push_back(vec[i-1]+1);} else{vec.push_back(vec[i-1]-1);} } int min = -1*(*min_element(vec.begin(),vec.end())); if(min<0)min=0; int last = min + vec[N-1]; for(int i=0;i<min;i++){ cout << "("; } for(int i=0;i<N;i++){ cout << s[i]; } for(int i=0;i<last;i++){ cout << ")"; } cout << endl; }
a.cc: In function 'int main()': a.cc:24:32: error: 'min_element' was not declared in this scope 24 | int min = -1*(*min_element(vec.begin(),vec.end())); | ^~~~~~~~~~~
s248906945
p03696
C++
#include "stdafx.h" #include<string.h> int main(void) { char str[100]; char str1[10] = ""; char str2[10] = ""; int i, a; int num = 0; int num2 = 0; int sum = 0; scanf("%d", &a); scanf("%s", str); for (i = 0; i<100; i++) { if (str[i] == '(') { num++; } } for (i = 0; i<100; i++) { if (str[i] == ')') { num2++; } } if (num < num2) { sum = num2 - num; for (i = 0; i < sum; i++) { strcat(str1,"("); } printf("%s%s\n", str1, str); } if (sum > num2) { sum = num - num2; for (i = 0; i < sum; i++) { strcat(str1, ")"); } printf("%s%s\n", str, str1); } if (num == num2) { for (i = 0; i < num; i++) { strcat(str1, "("); strcat(str2, ")"); } printf("%s%s%s", str1, str, str2); } return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s029727403
p03696
Java
import java.util.*; import java.io.*; public class Main2{ static PrintWriter out; static Scanner in; public static void main(String args[]){ in = new Scanner(System.in); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } public static void solve(){ int N = in.nextInt(); String S = in.next(); char[] C = S.toCharArray(); int migi = 0; int migil = 0; int left = 0; int leftm = 0; for(int i=0;i<N;i++){ if(C[i]=='('){ migil++; }else if(C[i]==')'&&migil<=0){ migi++; }else if(C[i]==')'&&migil>0){ migil--; } if(C[N-i-1]==')'){ leftm++; }else if(C[N-i-1]=='('&&leftm<=0){ left++; }else if(C[N-i-1]=='('&&leftm>0){ leftm--; } } for(int i=0;i<migi;i++) out.print('('); for(int i=0;i<N;i++) out.print(C[i]); for(int i=0;i<left;i++) out.print(')'); out.println(); } }
Main.java:4: error: class Main2 is public, should be declared in a file named Main2.java public class Main2{ ^ 1 error
s896078525
p03696
Java
import java.io.*; public class Main2 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(br.readLine()); String s = br.readLine(); int left = 0; int right =0; for (int i = 0; i < num; i++) { if(s.charAt(i) == '(') left++; else right++; if (left < right) { s = "(" + s; num++; left++; } } for (int i = left - right; i > 0; i--) { s = s + ")"; } System.out.println(s); } }
Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s718368688
p03696
Java
import java.io.*; public class Main2 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(br.readLine()); String s = br.readLine(); int left = 0; int right =0; for (int i = 0; i < num; i++) { if(s.charAt(i) == '(') left++; else right++; if (left < right) { s = "(" + s; num++; left++; } } for (int i = left - right; i > 0; i--) { s = s + ")"; } System.out.println(s); } }
Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s889278599
p03696
C++
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define pb(x) push_back(x) #define eb(x,y) emplace_back(x,y) #define MOD 1000000007 #define MAX 1000000001 #define INF 1410065408 #define EPS 1e-9 using namespace std; typedef long long ll; typedef pair<ll, ll> P; struct edge{int from, to; ll cost;}; signed main(){ int n; cin >> n; string s, pre = ", post = "; cin >> s; int tmp = 0; rep(n){ if(s[i] == '('){ tmp++; }else{ if(tmp > 0){ tmp--; }else{ pre += '('; } } } while(tmp > 0){ post += ')'; tmp--; } cout << pre << s << post; }
a.cc: In function 'int main()': a.cc:48:9: error: 'post' was not declared in this scope 48 | post += ')'; | ^~~~ a.cc:51:25: error: 'post' was not declared in this scope 51 | cout << pre << s << post; | ^~~~
s641545001
p03696
C++
n = int(input()) s = input() head = "" depth = 0 for i in s: if i == "(": depth += 1 else: if depth == 0: head += "(" else: depth -= 1 tail = "".join([")" for _ in range(depth)]) print(head + s + tail)
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s159333360
p03696
C++
#include <iostream> #include <string> using namespace std; int main(){ int n,ln=0,rn=0; string ans, s,l,r; l="(", r=")"; cin>>n; cin>>s; for(int i=0;i<s.length();i++){ if(s[i]=="("){ ln++; }else{ rn++; } } ans=s; if(ln<rn){ for(int i=0;i<ln-rn;i++){ ans=l+ans; } }else if(rn>ln){ for(int i=0;i<rn-ln;i++){ ans=ans+r; } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:12:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 12 | if(s[i]=="("){
s755156880
p03696
C++
#include <iostream> #include <string> using namespace std; int main(){ int n,ln=0,rn=0; string ans, s,l,r; l="(", r=")"; cin>>n; cin>>s; for(int i=0;i<s.length();i++){ if(s[i]=="(")ln++; else rn++; } ans=s; if(ln<rn){ for(int i=0;i<ln-rn;i++){ ans=l+ans; } }else if(rn>ln){ for(int i=0;i<rn-ln;i++){ ans=ans+r; } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:12:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 12 | if(s[i]=="(")ln++;
s772778061
p03696
C++
#include <iostream> #include <string> using namespace std; int main(){ int n,ln=0,rn=0; string ans[201]; string s,l,r; l="(", r=")"; cin>>n; cin>>s; for(int i=0;i<s.length();i++){ if(s[i]=="(")ln++; else rn++; } ans=s; if(ln<rn){ for(int i=0;i<ln-rn;i++){ans=l+ans;} }else if(rn>ln){ for(int i=0;i<rn-ln;i++){ans=ans+r;} } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:13:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | if(s[i]=="(")ln++; a.cc:17:6: error: incompatible types in assignment of 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 17 | ans=s; | ~~~^~ a.cc:19:35: error: no match for 'operator+' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'}) 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ~^~~~ | | | | | std::string [201] {aka std::__cxx11::basic_string<char> [201]} | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:19:36: note: deduced conflicting types for parameter 'const _CharT' ('char' and 'std::string' {aka 'std::__cxx11::basic_string<char>'}) 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:19:36: note: deduced conflicting types for parameter '_CharT' ('char' and 'std::string*' {aka 'std::__cxx11::basic_string<char>*'}) 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:19:36: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++){ans=l+ans;} | ^~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument dedu
s932056198
p03696
C++
#include <iostream> #include <string> using namespace std; int main(){ int n,ln=0,rn=0; string ans[201]; string s,l,r; l[0]="(", r[0]=")"; cin>>n; cin>>s; for(int i=0;i<s.length();i++){ if(s[i]=="(")ln++; else rn++; } ans=s; if(ln<rn){ for(int i=0;i<ln-rn;i++)ans=l+ans; }else if(rn>ln){ for(int i=0;i<rn-ln;i++)ans=ans+r; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:8: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive] 8 | l[0]="(", r[0]=")"; | ^~~ | | | const char* a.cc:8:18: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive] 8 | l[0]="(", r[0]=")"; | ^~~ | | | const char* a.cc:13:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | if(s[i]=="(")ln++; a.cc:17:6: error: incompatible types in assignment of 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 17 | ans=s; | ~~~^~ a.cc:19:34: error: no match for 'operator+' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'}) 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ~^~~~ | | | | | std::string [201] {aka std::__cxx11::basic_string<char> [201]} | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:19:35: note: deduced conflicting types for parameter 'const _CharT' ('char' and 'std::string' {aka 'std::__cxx11::basic_string<char>'}) 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:19:35: note: deduced conflicting types for parameter '_CharT' ('char' and 'std::string*' {aka 'std::__cxx11::basic_string<char>*'}) 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 19 | for(int i=0;i<ln-rn;i++)ans=l+ans; | ^~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:19:35: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string [201]' {aka 'std::__cxx11::basic_string<char> [201]'} 19 | for(int i=0;i<ln-rn;i++)a
s608758226
p03696
C++
#include<iostream> #include<algorithm> #include <string> #include<cstdio> #include<vector> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) using namespace std; typedef long long ll; int main() { REP(i, 3) { cout << z[i] << endl; } string moji; int n; cin >> n; vector<int>a(10000); REP(i, 1000) { a[i] = 1; } REP(i, n) { char gomi; cin >> gomi; moji += gomi; if (gomi == '(') { a[i] = 1; } else { a[i] = 0; } } int sii = moji.size(); while (1) { int c = 0; REP(i, n - 1) { if (a[i] == 1 && a[i + 1] == 0) { a.erase(a.begin() + i, a.begin() + i + 2); sii -= 2; c++; break; } } if (c == 0) { REP(i, sii) { int aa = a[i]; if (aa) { moji = moji + ')'; } else { moji = '(' + moji; } } break; } } cout << moji << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:29: error: 'z' was not declared in this scope 13 | REP(i, 3) { cout << z[i] << endl; } | ^
s601442944
p03696
C++
#include<iostream> using namespace std; int main(void){ int N,a=0,b=0,c; string S; cin>>N>>S; for(int i=0;i<N;i++){ if(S[i]=='('){ a++; } else if(S[i]==')'){ if(a>0) a=a-1; else b++; } } if(a==0) cout<<S<<endl; else if(a<0){ for(int i=0;i<a;i++){ cout<<'('; } cout<<S<<endl; } else if(a>0){ cout<<S<<endl; for(int i=0;i<b){ cout<<')'; } cout<<endl; } }
a.cc: In function 'int main()': a.cc:31:32: error: expected ';' before ')' token 31 | for(int i=0;i<b){ | ^ | ;
s465317317
p03696
C++
//problem-C #include <algorithm> #include <cmath> #include <cstdlib> #include <cstdio> #include <iostream> #include <vector> #include<string> #include<queue> #include<map> using namespace std; int main() { int N; string S; cin >> N >> S; int putFirst = 0; int putLast = 0; int nowCount = 0; for (int i = 0; i < N; i++) { if (S[i] == '(') { nowCount++; } else { nowCount--; if (nowCount == -1) { nowCount = 0; putFirst++; } } } putLast = nowCount; for (int i = 0; i < putFirst; i++) { cout << '('; } cout << S; for (int i = 0; i < putLast; i++) { cout << ')' } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:44:28: error: expected ';' before '}' token 44 | cout << ')' | ^ | ; 45 | } | ~
s624913923
p03696
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int n; char cs[105]; vector<int> parens; int inserts[100];// 場所 int insert; int depth; int main() { scanf("%d",&n); scanf("%s",cs); for(int i=0;i<n;i++){ if(cs[i]=='(')depth++; else depth--; if(depth<0){ insert++; depth++; } } while(insert--)printf("("); for(int i=0;i<n;i++){ printf("%c",cs[i]); } while(depth--)printf(")"); printf("\n"); return 0;
a.cc: In function 'int main()': a.cc:30:18: error: expected '}' at end of input 30 | return 0; | ^ a.cc:13:12: note: to match this '{' 13 | int main() { | ^
s593410704
p03696
C++
#include <iostream> #include <string.h> using namespace std; int main() { char s[100], f[100], l[100]; memset(s, '\0', 100); memset(f, '\0', 100); memset(l, '\0', 100); int cnt = 0, i = 0; int fi = 0, li = 0; cin >> cnt; for(; i != cnt; i++){ cin >> s[i]; } i = 0; int flag = 0; while (s[i] != '\0') { if (s[i] == ')') { if (flag != 0) { li--; flag--; } else { fi++; } } else { li++; flag++; } i++; } for (int c = 0; c < fi; c++) { f[c] = '('; } for (int c = 0; c < li; c++) { l[c] = ')'; } strcat_s(f, s); strcat_s(f, l); cout << f << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:9: error: 'strcat_s' was not declared in this scope; did you mean 'strcat'? 41 | strcat_s(f, s); | ^~~~~~~~ | strcat
s959212742
p03696
C++
#include <iostream> #include <string.h> using namespace std; int main() { char s[100], f[100], l[100]; memset(s, '\0', 100); memset(f, '\0', 100); memset(l, '\0', 100); int cnt = 0, i = 0; int fi = 0, li = 0; cin >> cnt; for(; i != cnt; i++){ cin >> s[i]; } i = 0; int flag = 0; while (s[i] != '\0') { if (s[i] == ')') { if (flag != 0) { li--; flag--; } else { fi++; } } else { li++; flag++; } i++; } for (int c = 0; c < fi; c++) { f[c] = '('; } for (int c = 0; c < li; c++) { l[c] = ')'; } strcat_s(f, s); strcat_s(f, l); cout << f << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:9: error: 'strcat_s' was not declared in this scope; did you mean 'strcat'? 41 | strcat_s(f, s); | ^~~~~~~~ | strcat
s667080334
p03696
C++
include<iostream> #include<cstdio> #include<cmath> #include<vector> using namespace std; int n,a,b,c; char s[310]; bool z = true; int main() { cin >> n; for(int i = 0;i < n;i++) { cin >> s[i]; if(z && s[i] == ')') { a++; continue; } if(!z && s[i] == '(') { b++; continue; } if(s[i] == '(') { c++; continue; } if(s[i] == ')') { c--; continue; } if(c > 0)c = false; if(c < 1)c = true; } if(c > 0)b += c; else a -= c; for(int i = 0;i < a;i++) cout << '(' ; for(int i = 0;i < n;i++) cout << s[i]; for(int i = 0;i < b;i++) cout << ')'; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ In file included from /usr/include/c++/14/cmath:45, from a.cc:3: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdio.h:34, from /usr/include/c++/14/cstdio:42, from a.cc:2: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/ptr_traits.h:156:47: error: 'p
s457896649
p03696
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String s = sc.next(); int first = 0; int last = 0; if(s.charAt(0) == ')') first = 1; if(s.charAt(s.length() - 1) == '(') l = 1; int plus = 0; int minus = 0; int lastP = 0; int firstM = 0; for(int i = 0; i < s.length(); i++) { if(s.charAt(i) == '(') { plus++; } else { minus++; } } if(first == 1) { for(int i = 0; i < s.length(); i++) { if(s.charAt(i) == ')') { firstM++; } else { break; } } } if(l == 1) { for(int i = s.length() - 1; i >= 0; i--) { if(s.charAt(i) == '(') { lastP++; } else { break; } } } String firstP = ""; String lastM = ""; for(int i = 0; i < firstM; i++) { firstP += "("; } for(int i = 0; i < lastP; i++) { lastM += ")"; } String ans = firstP + s + lastM; int p = plus - lastP; int m = minus - firstM; if(p > m) { String a = ""; for(int i = 0; i < (p - m); i++) { a += ")"; } ans = ans + a; } if(p < m) { String a = ""; for(int i = 0; i < (m - p); i++) { a += "("; } ans = a + ans; } System.out.println(ans); } }
Main.java:11: error: cannot find symbol if(s.charAt(s.length() - 1) == '(') l = 1; ^ symbol: variable l location: class Main Main.java:32: error: cannot find symbol if(l == 1) { ^ symbol: variable l location: class Main 2 errors
s708305011
p03696
C++
#define _USE_MATH_DEFINES #include<iostream> #include <math.h> #include <algorithm> #include <vector> #include <string> using namespace std; int main() { int n; char *ch; cin >> n; ch = new char[n]; for (int i = 0; i < n; i++){ cin >> ch[i]; } //対は消していって、その左右端は覚えておいた上で余りと対になる()を埋めていく char pre = '('; int numl = 0; int numr = 0; int nummax; string str = ""; //for (int i = 0; i < n; i++){ // if (ch[i] == '('&& pre == ')'){ // nummax = max(numl, numr); // for (int ii = 0; ii < nummax; ii++){ // str = str + "("; // } // for (int ii = 0; ii < nummax; ii++){ // str = str + ")"; // } // numl = 1; // numr = 0; // if (i == n - 1){ // str = str + "()"; // break; // } // } // else if (ch[i] == '('){ // numl++; // } // else if (ch[i] == ')'){ // numr++; // } // if (i == n - 1){ // nummax = max(numl, numr); // for (int ii = 0; ii < nummax; ii++){ // str = str + "("; // } // for (int ii = 0; ii < nummax; ii++){ // str = str + ")"; // } // } // pre = ch[i]; //} int numl = 0; int addl = 0; int addr = 0; int countl = 0; for (int i = 0; i < n; i++){ if (ch[i] == '('){ numl++; countl++; } if (ch[i] == ')'){ if (!(numl > 0)){ addl++; } numl--; } } int addr = n - countl - addl; for (int i = 0; i < addl; i++){ str = str + '('; } for (int i = 0; i < n; i++){ str = str + ch[i]; } for (int i = 0; i < addr; i++){ str = str + ')'; } cout << str; return 0; }
a.cc: In function 'int main()': a.cc:64:13: error: redeclaration of 'int numl' 64 | int numl = 0; | ^~~~ a.cc:24:13: note: 'int numl' previously declared here 24 | int numl = 0; | ^~~~ a.cc:81:13: error: redeclaration of 'int addr' 81 | int addr = n - countl - addl; | ^~~~ a.cc:66:13: note: 'int addr' previously declared here 66 | int addr = 0; | ^~~~
s042208163
p03696
C++
#include <algorithm> #include <iostream> #include <string> using namespace std; #define int long long int main() { int n; string s; cin >> n >> s; n = s.length(); int a[n]; for (int i = 0; i < n; i++) { a[i] = 0; if (s[i] == '(') { a[i] = 1; } else if (s[i] == ')') { a[i] = -1; } } int tmp = 0; int lb = 0; int rb = 0; for (int i = 0; i < n - 1; i++) { tmp += a[i]; if (a[i] == -1 && a[i+1] == 1) { // )(が登場したらリセット if (tmp < 0) {//)が多い lb -= tmp; } else if (tmp >= 0) {//(が多い rb += tmp; } tmp = 0; } } tmp += a[n-1]; if (tmp < 0) { lb -= tmp; } else if (tmp >= 0) { rb += tmp; } for (int i = 0; i < lb; i++) { cout << "("; } cout << s; for (int i = 0; i < rb; i++) { cout << ")"; } cout << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s920508527
p03696
C
#include <stdio.h> int main() { int n, i, a, b, k; char s[100], a[200]; scanf("%d", &n); scanf("%s", s); a = b = 0; for (i = 0; i < n; i++){ if (s[i] == '(') a++; else b++; } if (a > b){ k = a - b; for (i = 0; i < n; i++){ a[i] = s[i] } for (i = 0; i < k; i++){ a[i + n] = ')'; } } if (b > a){ k = b - a; for (i = 0; i < k; i++){ a[i] = '('; } for (i = 0; i < n; i++){ a[i + k] = s[i]; } } return 0; }
main.c: In function 'main': main.c:6:22: error: conflicting types for 'a'; have 'char[200]' 6 | char s[100], a[200]; | ^ main.c:5:19: note: previous declaration of 'a' with type 'int' 5 | int n, i, a, b, k; | ^ main.c:20:36: error: expected ';' before '}' token 20 | a[i] = s[i] | ^ | ; 21 | } | ~
s135271756
p03696
C++
#include <bits/stdc++.h> using namespace std; static const int MAXN = 1e3 + 10; deque<char> ans; stack<char> s; char data[MAXN]; int n; int main() { scanf("%d" , &n); scanf(" %s" , data + 1); for(int i = 1 ; i <= n ; ++i) { char a = data[i]; if(a == '(') { if(data[i + 1] == ')') { ++i; ans.push_back('('); ans.push_back(')'); } else s.push('('); } else { if(s.empty()) ans.push_front('('); while(!s.empty()) { s.pop(); ans.push_front('('); } ans.push_back(')'); } } while(!s.empty()) { ans.push_front('('); ans.push_back(')'); ans.pop(); } for(auto i: ans) printf("%c" , i); }
a.cc: In function 'int main()': a.cc:13:19: error: reference to 'data' is ambiguous 13 | scanf(" %s" , data + 1); | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:7:6: note: 'char data [1010]' 7 | char data[MAXN]; | ^~~~ a.cc:16:18: error: reference to 'data' is ambiguous 16 | char a = data[i]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:7:6: note: 'char data [1010]' 7 | char data[MAXN]; | ^~~~ a.cc:19:16: error: reference to 'data' is ambiguous 19 | if(data[i + 1] == ')') | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:7:6: note: 'char data [1010]' 7 | char data[MAXN]; | ^~~~ a.cc:45:13: error: 'class std::deque<char>' has no member named 'pop' 45 | ans.pop(); | ^~~
s692017082
p03696
Java
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String str = sc.next(); char[] S = new char[N]; for(int i=0;i<N;i++){ S[i] = str.charAt(i); } int[] depth = new int[N]; int deptA = 0; int deptB = 0; for(int i=0; i<N;i++){ if(S[i]=='('){ deptA++; depth[i] = deptA; }else{ if(i>0 && S[i-1]=='('){ depth[i-1]--; depth[i] = depth[i-1]; deptA--; }else{ deptB--; depth[i] = deptB; } } } for(int i=0;i<-deptB;i++){ System.out.print("("); } System.out.print(str); for(int i=0;i<deptA;i++){ System.out.print(")"); } }
Main.java:37: error: reached end of file while parsing } ^ 1 error
s575808293
p03696
C++
#include<cstdio> #include<cstring> #include<iostream> using namespace std; const int inf=1<<29; const int maxn=110; char str[maxn]; int n,dp[maxn][maxn]; pair<int,int> pre[maxn][maxn]; bool check(int i,int j) { if((str[i]=='('&&str[j]==')')||(str[i]=='['&&str[j]==']')) return true; return false; } void DFS(int l,int r) { if(l>r) return; if(l==r) { if(str[l]=='['||str[l]==']') printf("[]"); if(str[l]=='('||str[l]==')') printf("()"); return ; } if(check(l,r)&&dp[l][r]==dp[l+1][r-1]) { printf("%c",str[l]); DFS(l+1,r-1); printf("%c",str[r]); return; } int sl=pre[l][r].first; int sr=pre[l][r].second; DFS(sl,sr); DFS(sr+1,r); } int main() { int a; cin >> a; getchar(); memset(pre,-1,sizeof(pre)); gets(str); n=strlen(str); for(int i=0;i<n;i++) dp[i][i]=1; for(int j=1;j<n;j++) for(int i=0;i+j<n;i++) { dp[i][i+j]=inf; if(check(i,i+j)) { dp[i][i+j]=dp[i+1][i+j-1]; pre[i][i+j]=make_pair(i+1,i+j-1); } for(int k=0;k<=j;k++) if(dp[i][i+j]>dp[i][i+k]+dp[i+k+1][i+j]) { dp[i][i+j]=dp[i][i+k]+dp[i+k+1][i+j]; pre[i][i+j]=make_pair(i,i+k); } } DFS(0,n-1); return 0; }
a.cc: In function 'int main()': a.cc:46:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 46 | gets(str); | ^~~~ | getw
s375098244
p03696
C++
#include<string> #include<conio.h> using namespace std; int n; string s,moto; int main(){ cin>>n; cin>>s; for(int i=0;i<n;i++){ //moto[i]=s[i]; if(i!=0&&s[i-1]=='('&&s[i]==')') { s[i-1]='1'; s[i]='2'; } } for(int i=0;i<n;i++){ if(s[i]==')'){ s.insert(s.begin(),'('); } else if(s[i]=='('){ s.push_back(')'); } } for(int i=0;i<s.length()-1;i++){ if(s[i]=='1') s[i]='('; else if(s[i]=='2') s[i]=')'; } cout<<s<<endl; getch(); return 0; }
a.cc:2:9: fatal error: conio.h: No such file or directory 2 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s320687763
p03696
C++
#include"bits/stdc++.h" #include<conio.h> using namespace std; int n; string st; int b,a; int main(){ cin>>n>>st; int right=0,left=0; for(int i=0;i<st.length();i++){ if(st[i]=='('){ left++; } else if(st[i]==')'){ right++; if(right>left)a++; } } right=0;left=0; for(int i=st.length()-1;i>=0;i--){ if(st[i]=='('){ left++; if(right<left)b++; } else if(st[i]==')'){ right++; } } for(int i=0;i<a;i++)cout<<"("; cout<<st; for(int i=0;i<b;i++)cout<<")"; cout<<endl; getch(); return 0; }
a.cc:2:9: fatal error: conio.h: No such file or directory 2 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s508820716
p03696
C++
#include <iostream> #include <vector> #include <string> #include <queue> #include <iomanip> #include <stack> #include <bitset> #include <map> using namespace std; typedef long long ll; const ll INF = 1LL << 50; int solve(); void replace(string& target, string& from, string&to) { int pos(target.find(from)); while (pos != string::npos) { target.replace(pos, from.length(), to); pos = target.find(from); } } int main(void) { while (solve()) {} return 0; } int solve() { int N; cin >> N; string s, orig, ans; cin >> s; orig = s; while (orig.find("()") != string::npos) { replace(orig, std::string("()"), string("")); } int r = 0, l = 0; for (int i = 0; i < orig.length(); i++) { if (orig[i] == ')') r++; else l++; } for (int i = 0; i < r; i++) ans += "("; ans += s; for (int i = 0; i < l; i++) ans += ")"; cout << ans << endl; return 0; }
a.cc: In function 'int solve()': a.cc:39:36: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'} 39 | replace(orig, std::string("()"), string("")); | ^~~~~~~~~~~~ a.cc:17:38: note: initializing argument 2 of 'void replace(std::string&, std::string&, std::string&)' 17 | void replace(string& target, string& from, string&to) { | ~~~~~~~~^~~~
s397691274
p03696
C++
#include <bits/stdc++.h> using namespace std; int main( int argc, char *argv[] ) { int i; int N; char S[ 200 ]; char C; int iL; int iR; ios::sync_with_stdio( false ); cin.tie( 0 ); cin >> N; cin >> S; a = 0; b = 0; iL = 0; iR = 0; for( i = 0; i < N; i++ ) { C = S[ i ]; if( C == ')' ) { if( iL > 0 ) iL--; else iR++; } else { iL++; } } for( i = 0; i < iR; i++ ) cout << "("; cout << S; for( i = 0; i < iL; i++ ) cout << ")"; cout << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:21:9: error: 'a' was not declared in this scope 21 | a = 0; | ^ a.cc:22:9: error: 'b' was not declared in this scope 22 | b = 0; | ^
s051606539
p03696
C++
#include <iostream> #include <cstdio> #include <map> #include <cstring> #define INF 210 #define NMAX 105 using namespace std; int dp[NMAX][NMAX]; int K[NMAX][NMAX]; map<char,char> M; int i,j,k,N; char C[NMAX]; void afisare(int i,int j) { if(i>j) return ; if(i==j) { if(C[i]=='('||C[i]==')') cout<<"()"; else cout<<"[]"; } else { if(K[i][j]==0&&M[C[i]]==C[j]) { cout<<C[i]; afisare(i+1,j-1); cout<<C[j]; } else { afisare(i,K[i][j]); afisare(1+K[i][j],j); } } } int main() { scanf("%d\n",&N); gets(C+1); M['(']=')'; for(i=N;i>=1;i--) { for(j=i;j<=N;j++) { if(i==j) dp[i][j]=1; else { dp[i][j]=INF; if(M[C[i]]==C[j]) dp[i][j]=dp[i+1][j-1]; for(k=i;k<j;k++) if(dp[i][j]>dp[i][k]+dp[k+1][j]) { K[i][j]=k; dp[i][j]=dp[i][k]+dp[k+1][j]; } } } } afisare(1,N); return 0; }
a.cc: In function 'int main()': a.cc:42:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 42 | gets(C+1); | ^~~~ | getw
s831910612
p03697
C++
#include<bits/stdc++.h> #define Vsort(a) sort(a.begin(), a.end()) #define Vreverse(a) reverse(a.begin(), a.end()) #define Srep(n) for(int i = 0; i < (n); i++) #define Lrep(i,a,n) for(int i = (a); i < (n); i++) #define Brep(n) for(int bit = 0; bit < (1<<n); bit++) #define rep2nd(n,m) Srep(n) Lrep(j,0,m) #define vi vector<int> #define vi64 vector<int64_t> #define vvi vector<vector<int>> #define vvi64 vector<vector<int64_t>> using namespace std; int main(){ int a,b; cin >> a >> b; cout << (a + b < 10 ? a + b : "error") << endl; }
a.cc: In function 'int main()': a.cc:19:23: error: operands to '?:' have different types 'int' and 'const char*' 19 | cout << (a + b < 10 ? a + b : "error") << endl; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
s940369163
p03697
C++
#include<bits/stdc++.h> #define Vsort(a) sort(a.begin(), a.end()) #define Vreverse(a) reverse(a.begin(), a.end()) #define Srep(n) for(int i = 0; i < (n); i++) #define Lrep(i,a,n) for(int i = (a); i < (n); i++) #define Brep(n) for(int bit = 0; bit < (1<<n); bit++) #define rep2nd(n,m) Srep(n) Lrep(j,0,m) #define vi vector<int> #define vi64 vector<int64_t> #define vvi vector<vector<int>> #define vvi64 vector<vector<int64_t>> using namespace std; int main(){ int a,b: cin >> a >> b; cout << (a + b < 10 ? a + b : "error") << endl; }
a.cc: In function 'int main()': a.cc:17:10: error: found ':' in nested-name-specifier, expected '::' 17 | int a,b: | ^ | :: a.cc:17:9: error: 'b' has not been declared 17 | int a,b: | ^ a.cc:18:7: error: qualified-id in declaration before '>>' token 18 | cin >> a >> b; | ^~ a.cc:19:16: error: 'b' was not declared in this scope 19 | cout << (a + b < 10 ? a + b : "error") << endl; | ^
s771695204
p03697
C++
#include<bits/stdc++.h> #include<atcoder/all> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using namespace atcoder; using ll = long long; using p = pair<int,int>; const long long INF = 1ll << 60; int main() { int A, B; cin >> A >> B; if (A+B >=10) cout << "error" << endl; else cout << A+B << endl; return 0; }
a.cc:2:9: fatal error: atcoder/all: No such file or directory 2 | #include<atcoder/all> | ^~~~~~~~~~~~~ compilation terminated.
s796513221
p03697
Java
import java.util.Scanner; public class A063 { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner stdIn = new Scanner(System.in); int A = stdIn.nextInt(); int B = stdIn.nextInt(); if(A+B >= 10) { System.out.println("error"); } else { System.out.println(A+B); } } }
Main.java:3: error: class A063 is public, should be declared in a file named A063.java public class A063 { ^ 1 error
s954915265
p03697
C++
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> #include<cstdint> #include<cstddef> using namespace std; using i32 = int_fast32_t; using i64 = int_fast64_t; using usize = uint_fast64_t; #define rep(i, n) for (usize i = 0; i < (usize)(n); i++) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() using P = pair<i64,i64>; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); i32 a,b; cin >> a >> b; if(a + b >= 10)cout << "error" << endl; elsecout << a + b << endl; }
a.cc: In function 'int main()': a.cc:22:1: error: 'elsecout' was not declared in this scope 22 | elsecout << a + b << endl; | ^~~~~~~~
s417987495
p03697
C++
#include<bits/stdc++.h> using namespace std; #define ll long long signed main() { int a,b; cin >> a >> b; cout << ((a+b>=10)?"error":a+b) << endl; }
a.cc: In function 'int main()': a.cc:9:21: error: operands to '?:' have different types 'const char*' and 'int' 9 | cout << ((a+b>=10)?"error":a+b) << endl; | ~~~~~~~~~^~~~~~~~~~~~
s475303901
p03697
C++
#include<bits/stdc++.h> using namespace std; #define ll long long signed main() { int a,b; cin >> a >> b; cout << ((a+b>=10)?"error":a+b << endl; }
a.cc: In function 'int main()': a.cc:9:34: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 9 | cout << ((a+b>=10)?"error":a+b << endl; | ~~~~^~~~~~~ a.cc:9:41: error: expected ')' before ';' token 9 | cout << ((a+b>=10)?"error":a+b << endl; | ~ ^ | )
s917380168
p03697
C++
#include <iostream> #include <algorithm> #include <cmath> #include <string> using namespace std; int main() { int a, b; cin >> a >> b; if (a + b >= 10) cout << "error" << "\n"; else cout << a + b << "\n" }
a.cc: In function 'int main()': a.cc:12:38: error: expected ';' before '}' token 12 | cout << a + b << "\n" | ^ | ; 13 | } | ~
s131516918
p03697
C++
#include<iostream> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<((a+b<10)? a+b:"error"); return 0; }
a.cc: In function 'int main()': a.cc:7:18: error: operands to '?:' have different types 'int' and 'const char*' 7 | cout<<((a+b<10)? a+b:"error"); | ~~~~~~~~^~~~~~~~~~~~~
s181522002
p03697
C++
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define vi vector<int> #define bn(n) (n).begin(), (n).end() #define FOR(n) for(int i = 0; i < (int)n; i++) void solve() { int a, b; cin >> a >> b; cout << (a + b > 10 ? "error" : a + b); } int main () { ios::sync_with_stdio(0); cin.tie(0); int t = 1, i = 1; //cin >> t; while(t--) { //cout << "Case #" << i << ": "; solve(); //i++; } return 0; }
a.cc: In function 'void solve()': a.cc:15:25: error: operands to '?:' have different types 'const char*' and 'int' 15 | cout << (a + b > 10 ? "error" : a + b); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
s181984358
p03697
C
#include<stdio.h> int main() { int A,B,C; scanf("%d %d",&a,&b); if(1<=A && A<=9 && 1<=B && B<=9) { C=A+B; if(C<=9) printf("%d",C); else printf("error"); } return 0; }
main.c: In function 'main': main.c:6:20: error: 'a' undeclared (first use in this function) 6 | scanf("%d %d",&a,&b); | ^ main.c:6:20: note: each undeclared identifier is reported only once for each function it appears in main.c:6:23: error: 'b' undeclared (first use in this function) 6 | scanf("%d %d",&a,&b); | ^
s189227182
p03697
C++
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >>a >>b; if (a + b < 10) cout << a + b; else cout "error"; }
a.cc: In function 'int main()': a.cc:11:9: error: expected ';' before string constant 11 | cout "error"; | ^~~~~~~~ | ;
s616750686
p03697
C++
#include <bits/stdc++.h> using namespace std; int main() { int a , b ; cin >> a >> b ; cout << (a+b < 10 ? a+b : "error") << endl; }
a.cc: In function 'int main()': a.cc:8:21: error: operands to '?:' have different types 'int' and 'const char*' 8 | cout << (a+b < 10 ? a+b : "error") << endl; | ~~~~~~~~~^~~~~~~~~~~~~~~
s622470876
p03697
C++
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define pb push_back using ll = long long; using vin=vector<int>; using vll=vector<ll>; using vst=vector<string>; using P = pair<int, int>; const int inf=1e9+7; const ll INF=1e18; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; int main(){cout<<fixed<<setprecision(10); int a,b; cin>>a>>b; cout<<(a+b<10 ? a+b:"error")<<endl; }
a.cc: In function 'int main()': a.cc:26:26: error: operands to '?:' have different types 'int' and 'const char*' 26 | cout<<(a+b<10 ? a+b:"error")<<endl; | ~~~~~~~^~~~~~~~~~~~~
s939014059
p03697
C++
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define pb push_back using ll = long long; using vin=vector<int>; using vll=vector<ll>; using vst=vector<string>; using P = pair<int, int>; const int inf=1e9+7; const ll INF=1e18; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; int main(){cout<<fixed<<setprecision(10); int a,b; cin>>a>>b; cout<<(a+b<10 ?a+b:"error")<<endl; }
a.cc: In function 'int main()': a.cc:26:26: error: operands to '?:' have different types 'int' and 'const char*' 26 | cout<<(a+b<10 ?a+b:"error")<<endl; | ~~~~~~~^~~~~~~~~~~~
s299736922
p03697
C++
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x,y) make_pair(x,y) #define all(x) (x).begin(),(x).end() #define pb push_back using ll = long long; using vin=vector<int>; using vll=vector<ll>; using vst=vector<string>; using P = pair<int, int>; const int inf=1e9+7; const ll INF=1e18; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; int main(){cout<<fixed<<setprecision(10); int a,b; cin>>a>>b; cout<<(a+b<10?a+b:"error")<<endl; }
a.cc: In function 'int main()': a.cc:26:25: error: operands to '?:' have different types 'int' and 'const char*' 26 | cout<<(a+b<10?a+b:"error")<<endl; | ~~~~~~^~~~~~~~~~~~
s348278079
p03697
C++
#include<bits/stdc++.h> using namespace std; #define debug(n) cerr << #n << ':' << n << endl; #define dline cerr << __LINE__ << endl; using ll = long long; using ull = unsigned long long; template<class T, class U> using P = pair<T,U>; template<class T> using Heap = priority_queue<T>; template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>; template<class T,class U> using umap = unordered_map<T,U>; template<class T> using uset = unordered_set<T>; template<class T> bool ChangeMax(T&a,const T&b){ if(a >= b) return false; a = b; return true; } template<class T> bool ChangeMin(T&a,const T&b){ if(a <= b) return false; a = b; return true; } template<class T, size_t N, class U> void Fill(T (&a)[N], const U&v){ fill((U*)a,(U*)(a+N),v); } template<class T> istream& operator >> (istream&is, vector<T>&v){ for(auto&e:v)is >> e; return is; } int main(){ int a,b; cin >> a >> b; cout << (a+b >= 10 ? "error" : a+b) << endl; }
a.cc: In function 'int main()': a.cc:41:22: error: operands to '?:' have different types 'const char*' and 'int' 41 | cout << (a+b >= 10 ? "error" : a+b) << endl; | ~~~~~~~~~~^~~~~~~~~~~~~~~