QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#286600#7965. 机器人ucup-team1004WA 70ms16796kbC++142.7kb2023-12-18 07:39:152023-12-18 07:39:17

Judging History

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

  • [2023-12-18 07:39:17]
  • 评测
  • 测评结果:WA
  • 用时:70ms
  • 内存:16796kb
  • [2023-12-18 07:39:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#ifdef DEBUG
template<class T>
ostream& operator << (ostream &out,vector<T> a){
	out<<'[';
	for(T x:a)out<<x<<',';
	return out<<']';
}
template<class T>
vector<T> ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<class T>
void debug(T x){
	cerr<<x<<endl;
}
template<class T,class...S>
void debug(T x,S...y){
	cerr<<x<<' ',debug(y...);
}
#else
#define debug(...) void()
#endif
char LR[2][10]={"left","right"};
const int N=101,M=11;
int n,m,k,cur[2][N];
char op[20];
int trs(char *str){
	if(str[0]=='S')return 0;
	else if(str[1]=='O')return 1;
	else if(str[0]=='S')return 2;
	else if(str[0]=='M')return 3;
	else if(str[0]=='R')return 4;
	else if(str[0]=='A')return 5;
	else return 6;
}
struct command{
	int op,h,x,y;
	command *nex;
	void read(){
		static char str[20];
		scanf("%s",str);
		op=trs(str);
		if(op==0);
		else if(op==1)scanf("%d%d",&h,&x);
		else if(op==2)scanf("%d%d%d",&h,&x,&y);
		else if(op==3)scanf("%d%d",&h,&x);
		else if(op==4){
			scanf("%d%d",&h,&x);
			nex=new command;
			nex->read();
		}else if(op==5)scanf("%d",&h);
		else if(op==6){
			scanf("%s",str);
			x=trs(str);
			nex=new command;
			nex->read();
		}
	}
}a[N][M];
void run(int);
void Run(int i,command o,bool flag=0,bool rev=0){
	o.h^=rev;
	if(o.op==0){
		printf("Robot %d slacks off.\n",i);
		if(!--k)exit(0);
	}else if(o.op==1){
		(cur[o.h][i]+=o.x)%=n;
		printf("Robot %d moves its %s hand towards Robot %d.\n",i,LR[o.h],cur[o.h][i]);
		if(!--k)exit(0);
	}else if(o.op==2){
		printf("Robot %d swaps a line of command with Robot %d.\n",i,cur[o.h][i]);
		if(!--k)exit(0);
		swap(a[i][o.y],a[cur[o.h][i]][o.x]);
	}else if(o.op==3){
		printf("Robot %d modifies a line of command of Robot %d.\n",i,cur[o.h][i]);
		if(!--k)exit(0);
		a[cur[o.h][i]][o.x].h^=1;
	}else if(o.op==4){
		printf("Robot %d replaces a line of command of Robot %d.\n",i,cur[o.h][i]);
		if(!--k)exit(0);
		a[cur[o.h][i]][o.x]=*o.nex;
	}else if(o.op==5){
		printf("Robot %d activates Robot %d.\n",i,cur[o.h][i]);
		if(!--k)exit(0);
		run(cur[o.h][i]);
	}else if(o.op==6){
		return;
	}
	if(cur[1][i]!=i){
		int x=cur[1][i];
		for(int j=1;j<=m;j++)if(a[x][j].op==6){
			if(a[x][j].x!=6){
				if(a[x][j].x==o.op)return Run(x,*a[x][j].nex,1,a[x][j].h);
			}else{
				if(flag)return Run(x,*a[x][j].nex,1,a[x][j].h);
			}
		}
	}
}
void run(int i){
	for(int j=1;j<=m;j++){
		Run(i,a[i][j]);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d",&cur[0][i],&cur[1][i]);
		for(int j=1;j<=m;j++)a[i][j].read();
	}
	for(int i=0;;++i%=n)run(i);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 70ms
memory: 13084kb

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:

ok 300000 lines

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 16796kb

input:

100 10 300000
15 7
REPLACE 1 10 REPLACE 1 9 ACTIVATE 0
SWAP 1 7 4
MIRROR 0 10
TRIGGER ACTIVATE: REPLACE 1 6 SLACKOFF
MOVE 0 63
SWAP 0 2 1
SWAP 1 3 7
SWAP 1 1 5
REPLACE 1 10 MIRROR 1 10
REPLACE 1 4 MIRROR 0 2
80 77
SWAP 0 8 8
ACTIVATE 1
MOVE 0 42
MIRROR 1 6
TRIGGER SWAP: SWAP 1 4 7
MIRROR 1 1
TRIGGER...

output:

Robot 0 replaces a line of command of Robot 7.
Robot 0 slacks off.
Robot 0 moves its left hand towards Robot 78.
Robot 0 slacks off.
Robot 0 replaces a line of command of Robot 7.
Robot 1 slacks off.
Robot 1 moves its right hand towards Robot 70.
Robot 70 slacks off.
Robot 1 slacks off.
Robot 1 acti...

result:

wrong answer 2nd lines differ - expected: 'Robot 0 swaps a line of command with Robot 7.', found: 'Robot 0 slacks off.'