“()“不用考虑,因为放在哪里都可以,接下来要考虑的是”)(”,这种可以按照")()()()(“方式排放,因此分别使用”((“和”))“放在”)(“两边就可以了,并且不用考虑”)("的个数,然后cnt1-1和cnt2-1比较,如果相等则符合,反之不符合。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #include<bits/stdc++.h> using namespace std; #define LOCALa #define ll long long int #define inf 0x3f3f3f3f #define mset(a,b) memset(a,b,sizeof(a)) const int maxn=1e5+5; int a,b,c,d; void solve(){ scanf("%d%d%d%d",&a,&b,&c,&d); if(c==0){ if(a==d){ printf("1\n"); return; } else { printf("0\n"); return; } } else { if(a&&d&&(a-1==d-1)){ printf("1\n"); return; } else { printf("0\n"); return ; } } } int main(){ #ifdef LOCAL freopen("in.in","r",stdin); #endif solve(); return 0; }
|