Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ✿ ✿ ✿ بسم الله الرحمن الرحيـــم ✿ ✿ ✿
- اللهم _صل _وسلم _وبارك _علي _سيدنا _محمـــد
- ░██████╗██╗░░██╗██████╗░░█████╗░██╗░░░██╗██╗░░██╗
- ██╔════╝██║░░██║██╔══██╗██╔══██╗██║░░░██║██║░██╔╝
- ╚█████╗░███████║██████╔╝██║░░██║██║░░░██║█████═╝░
- ░╚═══██╗██╔══██║██╔══██╗██║░░██║██║░░░██║██╔═██╗░
- ██████╔╝██║░░██║██║░░██║╚█████╔╝╚██████╔╝██║░╚██╗
- ╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝░╚════╝░░╚═════╝░╚═╝░░╚═╝
- */
- //**************************************************************************
- #include <bits/stdc++.h>
- #define ll long long
- #define pi 3.141592653
- #define NumOfDigit(w) log10(w) + 1
- #define space cout<<" ";
- #define fixed(n) cout << fixed << setprecision(n)
- #define nl "\n"
- #define EPS 1e-9
- #define OO 2'000'000'000
- #define MOD 1'000'000'007
- #define all(s) s.begin(), s.end()
- #define rall(s) s.rbegin(), s.rend()
- #define cin(v) for (auto&i:v) cin >> i;
- #define cout(v) for (auto&i:v) cout << i << " ";
- #define cout_map(mp) for(auto& [f, s] : mp) cout << f << " " << s << "\n";
- #define sz(s) s.size()
- #define mini(v) *min_element(all(v))
- #define maxi(v) *max_element(all(v))
- #define szz(arr) sizeof(arr)/sizeof(arr[0])
- // #define pair auto pair=minmax_element(all(v))
- // #define f *pair.first
- // #define s *pair.second
- using namespace std;
- //****************************************************************************
- void ShrOOk() {
- ios_base::sync_with_stdio(false),cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r" , stdin),
- freopen("output.txt","w",stdout);
- #endif
- }
- //****************************************************************************
- //****************************************************************************
- void solve()
- {
- string s;cin>>s;
- stack<char>stck;
- for(int i=0;i<sz(s);i++)
- {
- if(!stck.empty())
- {
- if(stck.top()=='(' and s[i]==')')
- {
- stck.pop();
- continue;
- }
- else if(stck.top()=='{' and s[i]=='}')
- {
- stck.pop();
- continue;
- }
- else if(stck.top()=='[' and s[i]==']')
- {
- stck.pop();
- continue;
- }
- }
- stck.emplace(s[i]);
- }
- cout<<(stck.empty()?"true":"false");
- }
- //****************************************************************************
- int main()
- {
- ShrOOk();
- ll t=1;
- //cin>>t;
- while(t--)
- {
- solve();
- cout<<nl;
- }
- return 0;
- }
- /*
- *****************************************************************************
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement