Click on table to read problem, udebug, discuss, ...
Last Submissions | ||||||
---|---|---|---|---|---|---|
Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
| discuss11507 - | Accepted | C++11 | 0.050 | 0.000 | 2919 | 1 mins ago |
Suggest:
- The state 2 will depend on the state 1 and the bending step 1
-> The state i will depend on the state i-1 and the bending step i-1.
=> The state n will depend on the state n-1 and the bending step n-1.
#include<bits/stdc++.h>
#define int long long
#define N 1000111
#define oo 9223372036854775807LL
#define X first
#define Y second
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define DOW(i, a, b) for(int i=b; i>=a; i--)
#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
#define forvec(i,a) for(int i=0; i<a.size(); i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define for0(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
int t, n, x, y, z, l, r, k;
int a[N], b[N];
char c[N];
string s;
int32_t main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
while(cin >> n && n){
string state="+x";
for1(i,n-1){
string next_step;
cin >> next_step;
if (next_step == "No") continue;
if (state == "+x")
state = next_step;
else
if (state == "-x"){
string x= (next_step[0]=='+'?"-":"+");
string y="";
y += next_step[1];
state = x + y;
}
else
if (state==next_step)
state= "-x";
else
if (state[1]==next_step[1])
state= "+x";
}
cout<<state<<"\n";
}
}
No comments:
Post a Comment