QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#286432#7965. 机器人RemakeeTL 0ms0kbC++143.8kb2023-12-17 21:14:592023-12-17 21:15:00

Judging History

你现在查看的是最新测评结果

  • [2023-12-17 21:15:00]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-12-17 21:14:59]
  • 提交

answer

// Skyqwq
#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }

template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}

const int N = 105, M = 12;

int n, m, k, H[N][2];

string s[N][N];

void chk(int u, string name, string n2);

int cnt = 0;

void out() {

	if (++cnt == k) {
		exit(0);
	}
	//cerr << cnt<<endl;
}

bool is(char c) {
	return c >= 'A' && c <= 'Z';
}



void rev(int v, int x) {
//	string z = rev(s[v][x]);
	for (int i = 2; i < s[v][x].size(); i++) {
		if (s[v][x][i - 1] == ' ' && is(s[v][x][i - 2]) && (s[v][x][i] == '0' || s[v][x][i] == '1') && (i + 1 == s[v][x].size() || s[v][x][i + 1] == ' ')) {
			s[v][x][i] = s[v][x][i] == '1' ? '0' : '1';
			return;
		}
	}
//	if (z != s[v][x]) {
//		cerr << z <<endl;
//		cerr<<s[v][x]<<endl;
//		exit(0);
//	} 
//	s[v][x] = rev(s[v][x]);
}

void act(int u);

void wk(int u, string t, int o) {
	stringstream sin(t);
	string A; sin >> A;
	if (A == "SLACKOFF") {
		printf("Robot %d slacks off.\n", u);
		out();
	} else if (A == "MOVE") {
		int h, z; sin >> h >> z;
		(H[u][h] += z) %= n;
		printf("Robot %d moves its %s hand towards Robot %d.\n", u, h ? "right" : "left", H[u][h]);
		out();
	} else if (A == "SWAP") {
		int h, x, y;
		sin >> h >> x >> y;
		int v = H[u][h];
		swap(s[v][x], s[u][y]);
		printf("Robot %d swaps a line of command with Robot %d.\n", u, v);
		out();
	} else if (A == "MIRROR") {
		int h, x;
		sin >> h >> x;
		int v = H[u][h];
		rev(v, x);
		printf("Robot %d modifies a line of command of Robot %d.\n", u, v);
		out();
	} else if (A == "REPLACE") {
		int h, x;
		sin >> h >> x;
		
		
//		string w, ret = "";
//		while (sin >> w) {
//			ret += w + " ";
//		}
//		ret.pop_back();
		int v = H[u][h];
//		s[v][x] = ret;
		getline(sin, s[v][x]);
		printf("Robot %d replaces a line of command of Robot %d.\n", u, v);
		out();
	} else if (A == "ACTIVATE") {
		int h;
		sin >> h;
		int v = H[u][h];
		printf("Robot %d activates Robot %d.\n", u, v);
		out();
		act(v);
	} else if (A == "TRIGGER") {
		return;
	} else {
		assert(false);
	}
	if (o) chk(u, A, "");
}

void act(int u) {
	for (int i = 1; i <= m; i++) wk(u, s[u][i], 1);
}

void chk(int v, string name, string n2) {
	int u = H[v][1];
	if (u == v) return; 
	name += ":";
	n2 += ":";
	//cout <<u<<" "<<v<<" "<<name<<endl;
	for (int i = 1; i <= m; i++) {
		if (s[u][i].substr(0, 7) != "TRIGGER") continue;
		string t = s[u][i];
		stringstream sin(t);
		string A; sin >> A;
		if (A == "TRIGGER") {
			string B; sin >> B;

			//puts("here");
			//cout<<B<<"??"<<name<<endl;
			if (B == name || B == n2) {
				//puts("here??\n");
				string ret = "", w;
				int f = -1; string awa;
				while (sin >> w) {
					ret += w + " ";
					if (f == -1) awa = w, f = 1;
				}
				ret.pop_back(); 
				//puts("tr");
				//cout<<ret<<" " << awa<<"??\n";
				//cout <<v <<"??" <<ret<<endl;
				wk(u, ret, 0);
				chk(u, A, awa);
				return;
			}
		}
	}
}

int main() {
//	freopen("5.in", "r", stdin);
//	freopen("2.out", "w", stdout);
   	cin >> n >> m >> k;
   	for (int i = 0; i < n; i++) {
   		cin >> H[i][0] >> H[i][1]; getchar();
   		for (int j = 1; j <= m; j++) {
   			getline(cin, s[i][j]);
   		}
   	}
   	while (1) {
   		for (int i = 0; i < n; i++)
   			act(i);
   	}
   	
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

100 1 300000
1 1
REPLACE 0 1 REPLACE 0 1 REPLACE 1 1 REPLACE 0 1 REPLACE 0 1 REPLACE 0 1 REPLACE 1 1 REPLACE 1 1 REPLACE 0 1 REPLACE 1 1 REPLACE 1 1 REPLACE 1 1 REPLACE 1 1 REPLACE 0 1 REPLACE 1 1 REPLACE 0 1 REPLACE 0 1 REPLACE 0 1 REPLACE 1 1 REPLACE 0 1 REPLACE 0 1 REPLACE 1 1 REPLACE 0 1 REPLACE...

output:

Robot 0 replaces a line of command of Robot 1.
Robot 1 replaces a line of command of Robot 2.
Robot 2 replaces a line of command of Robot 3.
Robot 3 replaces a line of command of Robot 4.
Robot 4 replaces a line of command of Robot 5.
Robot 5 replaces a line of command of Robot 6.
Robot 6 replaces a...

result: