?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
128476441 |
Practice: arsilvyfish11 |
1214C - 57 | C++14 (GCC 6-32) | Wrong answer on test 18 | 31 ms | 4168 KB | 2021-09-11 09:56:23 | 2021-09-11 09:56:23 |
#include "bits/stdc++.h" using namespace std; #define kill(x) return cout << x, 0 #define int long long #define vi vector<int> #define pii pair<int, int> #define mod 1000000007 //1e9+7 #define inf 1e18 #define all(x) (x).begin(),(x).end() #define ff first #define ss second #define rep(i, a, n) for (int i = a; i < n; ++i) #define pb push_back #define tc int test;cin>>test; while(test--) #define in(n) int n;cin>>n #define invec(a,n) rep(i,0,n){ int val; cin>>val; a.pb(val);} const int N = 2e5 + 1235; // int max(int a,int b){ // return (a>b)?a:b; // } // int min(int a,int b){ // return (a<b)?a:b; // } // Driver function to sort the vector elements // by second element of pairs bool sortbysecdesc(const pair<int,int> &a, const pair<int,int> &b) { return (a.second > b.second); } bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); } int solve() { in(n); string s; cin>>s; if(n%2!=0){ cout<<"No"; return 0; } int check=0,shift=0; rep(i,0,n){ if(s[i]=='(') check++; else{ check--; if(check<0){ shift++; check=0; } } } if(shift<2) cout<<"Yes"; else cout<<"No"; return 0; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif //tc{ solve(); cout<<endl; // } return 0; }
?
?
?
?