Submission #6012034


Source Code Expand

Copy
//C

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか?!!!

class Node {

};

class dp {
private:
	bool InnerValues[20000][8001];
public:
	bool Get(int pos, int index) {
		if (pos + 10000 > 20000) return 0;
		if (pos + 10000 < 0) return 0;
		return InnerValues[pos + 10000][index];
	}
	void Set(int pos, int index, bool value) {
		if (pos + 10000 > 20000) return;
		if (pos + 10000 < 0) return;
		InnerValues[pos + 10000][index] = value;
	}
};

dp dpx;
dp dpy;
//dp[pos][ind][dir]: ind までの命令(shrink済)を消化したとき、posにいられるか?
vector<pair<char, int>> inst;

signed main() {
	string s;
	cin >> s;
	//s = "TTFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
	const int len = s.length();
	int x, y;
	cin >> x >> y;

	char now = s[0];
	int cnt = 0, consumed = 0;
	for (auto c : s) {
		if (now != c) {
			inst.push_back(make_pair(now, cnt));
			now = c;
			cnt = 0;
		}
		cnt++;
		consumed++;
		if (consumed == len) {
			inst.push_back(make_pair(now, cnt));
		}
	}




	//最初はx向き原点
	//dp[pos][ind]: ind までの命令(shrink済)を消化したとき、posにいられるか?
	//1番目の命令だけ特別扱い
	bool isX = true;
	if (inst[0].first == 'F') {
		dpx.Set(inst[0].second, 0, true);
		dpy.Set(0, 0, true);
	}
	else {
		if (inst[0].second % 2 == 1) {
			isX = !isX;
		}
		dpx.Set(0, 0, true);
		dpy.Set(0, 0, true);
	}

	//i番目の命令(shrink 済)まで消化したときにそのx/y座標にその向きでいられるか?
	rep(i, inst.size()) {
		if (i == 0) continue;

		if (inst[i].first == 'T') {
			//回転
			if (inst[i].second % 2 == 1) {
				isX = !isX;
			}

			//j: 座標
			for (int j = -len; j <= len; j++) {
				rep(k, 4) {
					dpx.Set(j, i, dpx.Get(j, i - 1));
					dpy.Set(j, i, dpy.Get(j, i - 1));
				}
			}
			continue;
		}

		//j: 座標 全てのX座標とY座標について、今回の更新で居る可能性があるかを調べる
		for (int j = -len; j <= len; j++) {
			if (isX) {
				//i-1 まで消化した時点で今回の命令でこの座標にこれる位置にいるか?
				bool value = dpx.Get(j - inst[i].second, i - 1) || dpx.Get(j + inst[i].second, i - 1);
				dpx.Set(j, i, value);
				//yは動かないのでi-1の時点で居たらOK、いなければNG
				dpy.Set(j, i, dpy.Get(j, i - 1));
			}
			else {
				bool value = dpy.Get(j - inst[i].second, i - 1) || dpy.Get(j + inst[i].second, i - 1);
				dpy.Set(j, i, value);
				dpx.Set(j, i, dpx.Get(j, i - 1));
			}
		}
	}

	int instLen = inst.size();

	if (dpx.Get(x, instLen - 1) && dpy.Get(y, instLen - 1)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}

Submission Info

Submission Time
Task D - FT Robot
User ymduu
Language C++14 (GCC 5.4.1)
Score 500
Code Size 13145 Byte
Status
Exec Time 986 ms
Memory 254464 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt
All 500 / 500 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt
Case Name Status Exec Time Memory
0_00.txt 2 ms 4352 KB
0_01.txt 2 ms 4352 KB
0_02.txt 2 ms 4352 KB
0_03.txt 2 ms 4352 KB
0_04.txt 2 ms 4352 KB
0_05.txt 2 ms 4352 KB
1_00.txt 2 ms 4352 KB
1_01.txt 2 ms 4352 KB
1_02.txt 52 ms 254208 KB
1_03.txt 51 ms 254208 KB
1_04.txt 51 ms 254208 KB
1_05.txt 51 ms 254208 KB
1_06.txt 986 ms 254464 KB
1_07.txt 985 ms 254464 KB
1_08.txt 674 ms 254464 KB
1_09.txt 673 ms 254464 KB
1_10.txt 672 ms 254464 KB
1_11.txt 673 ms 254464 KB
1_12.txt 674 ms 254464 KB
1_13.txt 674 ms 254464 KB
1_14.txt 520 ms 254336 KB
1_15.txt 519 ms 254336 KB
1_16.txt 519 ms 254336 KB
1_17.txt 518 ms 254336 KB
1_18.txt 496 ms 252288 KB
1_19.txt 508 ms 252288 KB
1_20.txt 507 ms 250240 KB
1_21.txt 515 ms 254336 KB
1_22.txt 528 ms 252416 KB
1_23.txt 512 ms 252288 KB
1_24.txt 511 ms 252288 KB
1_25.txt 519 ms 252288 KB
1_26.txt 2 ms 4352 KB
1_27.txt 2 ms 4352 KB
1_28.txt 505 ms 252288 KB
1_29.txt 510 ms 252288 KB
1_30.txt 399 ms 250240 KB
1_31.txt 379 ms 248192 KB
1_32.txt 261 ms 252288 KB
1_33.txt 251 ms 254336 KB
1_34.txt 157 ms 248064 KB
1_35.txt 152 ms 252160 KB
1_36.txt 105 ms 243968 KB
1_37.txt 119 ms 250112 KB
1_38.txt 80 ms 254208 KB
1_39.txt 83 ms 254208 KB
1_40.txt 65 ms 252160 KB
1_41.txt 69 ms 254208 KB
1_42.txt 366 ms 254336 KB
1_43.txt 366 ms 254336 KB
1_44.txt 365 ms 254336 KB
1_45.txt 365 ms 254336 KB
1_46.txt 365 ms 254336 KB
1_47.txt 365 ms 254336 KB
1_48.txt 365 ms 254336 KB
1_49.txt 365 ms 254336 KB