Submission #371322


Source Code Expand

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>

#define INF 2147483647
#define EPS 1e-9
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long

using namespace std;

#define MAX_S 5001

string S;
int num = 0;
string str[MAX_S];

void div(){

	num = 0;
	
	for (int i = 0; i < S.length(); ){
		
		for (int j = i + 1; j <= S.length(); j++){
			
			if (j == S.length()){
				
				str[num] = S.substr(i, j-i);

				i = j + 1;
				num++;

				break;

			}

			else if(S[j] == ' '){
				
				str[num] = S.substr(i, j - i);

				i = j + 1;
				num++;

				break;

			}

		}

	}

}

stack<string> S1;

void solve(){
	
	for (int i = 0; i < num; i++){
		
		if (str[i] == "not"){
			S1.push("not");
		}

		else{
			
			while (S1.size() >= 2){
				
				string p1 = S1.top();
				S1.pop();
				string p2 = S1.top();
				S1.pop();

				if (p1 == p2 && p2 == "not")
					continue;

				else{
					S1.push(p2);
					S1.push(p1);
				}

			}

			S1.push(str[i]);

		}

	}

}

int main(){

	getline(cin, S);

	div();

	solve();

	vector<string> ans;

	while (S1.size()){
		ans.push_back(S1.top());
		S1.pop();
	}

	reverse(ans.begin(), ans.end());

	for (int i = 0; i < ans.size(); i++){
		cout << ans[i];
		if (i < num - 1)
			cout << " ";
	}
	cout << endl;

	return 0;


}

Submission Info

Submission Time
Task A - 二重否定除去法則
User takoshi
Language C++ (GCC 4.9.2)
Score 0
Code Size 1800 Byte
Status WA
Exec Time 2034 ms
Memory 1052 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 3
WA × 6
TLE × 10
Set Name Test Cases
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt
Case Name Status Exec Time Memory
scrambled_00.txt WA 24 ms 928 KB
scrambled_01.txt AC 23 ms 928 KB
scrambled_02.txt AC 23 ms 924 KB
scrambled_03.txt WA 22 ms 808 KB
scrambled_04.txt WA 22 ms 804 KB
scrambled_05.txt WA 23 ms 940 KB
scrambled_06.txt AC 23 ms 1052 KB
scrambled_07.txt WA 25 ms 1052 KB
scrambled_08.txt WA 26 ms 932 KB
scrambled_09.txt TLE 2032 ms 936 KB
scrambled_10.txt TLE 2032 ms 924 KB
scrambled_11.txt TLE 2034 ms 920 KB
scrambled_12.txt TLE 2032 ms 936 KB
scrambled_13.txt TLE 2033 ms 880 KB
scrambled_14.txt TLE 2030 ms 928 KB
scrambled_15.txt TLE 2032 ms 912 KB
scrambled_16.txt TLE 2032 ms 924 KB
scrambled_17.txt TLE 2032 ms 932 KB
scrambled_18.txt TLE 2032 ms 932 KB