Submission #2164590


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  string t="+-*/";
  stack<int> st;

  rep(i,n){

    if(s[i]==','){
      s[i]=t[st.top()];
      continue;
    }
    if(s[i]==')'){
      st.pop();
      continue;
    }
    rep(j,4)
      if(s[i]==t[j]){
	st.push(j);
	break;
      }
  }

  rep(i,n){
    bool c=true;
    rep(j,4)
      if(s[i]==t[j] && s[i+1]=='(')c=false;
    if(c)cout<<s[i];
  }
  cout<<endl;
}

Submission Info

Submission Time
Task B - 異世界数式
User rika0384
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1138 Byte
Status
Exec Time 10 ms
Memory 512 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
All 400 / 400 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
Case Name Status Exec Time Memory
01.txt 9 ms 512 KB
02.txt 10 ms 512 KB
03.txt 9 ms 512 KB
04.txt 9 ms 512 KB
05.txt 9 ms 512 KB
06.txt 9 ms 512 KB
07.txt 10 ms 512 KB
08.txt 10 ms 512 KB
09.txt 10 ms 512 KB
10.txt 10 ms 512 KB
11.txt 10 ms 512 KB
12.txt 10 ms 512 KB
13.txt 10 ms 512 KB
14.txt 10 ms 512 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB
sample_05.txt 1 ms 256 KB