QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342228#7965. 机器人C1942huangjiaxuWA 100ms192828kbC++142.5kb2024-03-01 09:54:292024-03-01 09:54:29

Judging History

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

  • [2024-03-01 09:54:29]
  • 评测
  • 测评结果:WA
  • 用时:100ms
  • 内存:192828kb
  • [2024-03-01 09:54:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,k,tot;
inline void Add(int &x,int y){
	if((x+=y)>=n)x-=n;
}
struct Comand;
Comand* newcmd();
struct Comand{
	string name,tname;
	int h,x,y;
	Comand *nxt;
	void read(){
		cin>>name;
		if(name=="MOVE")scanf("%d%d",&h,&x);
		else if(name=="SWAP")scanf("%d%d%d",&h,&x,&y);
		else if(name=="MIRROR")scanf("%d%d",&h,&x);
		else if(name=="REPLACE"){
			scanf("%d%d",&h,&x);
			nxt=newcmd();
		}else if(name=="ACTIVATE")scanf("%d",&h);
		else if(name=="TRIGGER"){
			cin>>tname;
			tname.pop_back();
			nxt=newcmd();
		}
	}
}buc[1000005];
struct Robot{
	int t[2];
	Comand *c[11];
}bot[105];
Comand* newcmd(){
	Comand &C=buc[++tot];
	C.read();
	return &C;
}
void init(int x){
	Robot &B=bot[x];
	scanf("%d%d",&B.t[0],&B.t[1]);
	for(int i=1;i<=m;++i)B.c[i]=newcmd();
}
void exe(Comand c,int id,bool tri);
void Act(int nw){
	for(int j=1;j<=m;++j)exe(*bot[nw].c[j],nw,false);
}
void end(int id,string name,bool tri){
	for(int j=1;j<=m;++j){
		Comand *C=bot[id].c[j];
		if(C->name!="TRIGGER")continue;
		if(C->tname=="TRIGGER"){
			if(tri){
				exe(*C->nxt,id,true);
				return;
			}
		}else if(C->tname==name){
			exe(*C->nxt,id,true);
			return;
		}
	}
}
void exe(Comand c,int id,bool tri){
	if(c.name=="SLACKOFF"){
		printf("Robot %d slacks off.\n",id);
		if(!(--k))exit(0);
	}else if(c.name=="MOVE"){
		Add(bot[id].t[c.h],c.x);
		printf("Robot %d moves its ",id);
		if(c.h)printf("right");
		else printf("left");
		printf(" hand towards Robot %d.\n",bot[id].t[c.h]);
		if(!(--k))exit(0);
	}else if(c.name=="SWAP"){
		int z=bot[id].t[c.h];
		printf("Robot %d swaps a line of command with Robot %d.\n",id,z);
		if(!(--k))exit(0);
		swap(bot[id].c[c.y],bot[z].c[c.x]);
	}else if(c.name=="MIRROR"){
		int z=bot[id].t[c.h];
		printf("Robot %d modifies a line of command of Robot %d.\n",id,z);
		if(!(--k))exit(0);
		Comand *C=bot[z].c[c.x];
		if(C->name=="TRIGGER")C->nxt->h^=1;
		else C->h^=1;
	}else if(c.name=="REPLACE"){
		int z=bot[id].t[c.h];
		printf("Robot %d replaces a line of command of Robot %d.\n",id,z);
		if(!(--k))exit(0);
		bot[z].c[c.x]=c.nxt;
	}else if(c.name=="ACTIVATE"){
		int z=bot[id].t[c.h];
		printf("Robot %d activates Robot %d.\n",id,z);
		if(!(--k))exit(0);
		Act(z);
	}else return;
	if(bot[id].t[1]!=id)end(bot[id].t[1],c.name,tri);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;++i)init(i);
	for(int nw=0;;Add(nw,1))Act(nw);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 100ms
memory: 99120kb

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: 0
Accepted
time: 45ms
memory: 188112kb

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 swaps a line of command with Robot 7.
Robot 0 modifies a line of command of Robot 15.
Robot 0 activates Robot 15.
Robot 15 modifies a line of command of Robot 0.
Robot 15 modifies a line of command of Robot 0.
Robot 15 replaces a line of command...

result:

ok 300000 lines

Test #3:

score: 0
Accepted
time: 62ms
memory: 192828kb

input:

100 10 300000
59 13
REPLACE 0 5 REPLACE 0 7 MOVE 1 10
MOVE 0 40
ACTIVATE 1
TRIGGER TRIGGER: SWAP 1 9 7
ACTIVATE 1
SWAP 0 9 3
TRIGGER MOVE: MIRROR 1 1
MIRROR 0 7
MIRROR 0 5
REPLACE 1 1 SLACKOFF
27 65
REPLACE 1 8 REPLACE 1 6 MIRROR 0 6
TRIGGER MIRROR: SWAP 1 8 6
MOVE 1 2
TRIGGER REPLACE: MIRROR 0 1
MI...

output:

Robot 0 replaces a line of command of Robot 59.
Robot 0 moves its left hand towards Robot 99.
Robot 0 activates Robot 13.
Robot 13 slacks off.
Robot 13 slacks off.
Robot 13 slacks off.
Robot 13 swaps a line of command with Robot 20.
Robot 13 swaps a line of command with Robot 20.
Robot 13 moves its ...

result:

ok 300000 lines

Test #4:

score: -100
Wrong Answer
time: 56ms
memory: 115392kb

input:

100 10 300000
38 0
TRIGGER TRIGGER: REPLACE 0 5 MIRROR 1 1
TRIGGER REPLACE: MOVE 0 98
MOVE 1 27
MIRROR 0 2
MOVE 1 38
MIRROR 1 8
SLACKOFF
SLACKOFF
TRIGGER REPLACE: MOVE 1 25
TRIGGER MOVE: REPLACE 1 5 ACTIVATE 1
63 95
ACTIVATE 0
SWAP 0 7 10
REPLACE 0 6 SWAP 1 9 9
SWAP 1 4 1
SWAP 1 7 4
MIRROR 1 2
MOVE ...

output:

Robot 0 moves its right hand towards Robot 27.
Robot 0 modifies a line of command of Robot 38.
Robot 0 moves its right hand towards Robot 65.
Robot 0 modifies a line of command of Robot 65.
Robot 0 slacks off.
Robot 65 slacks off.
Robot 0 slacks off.
Robot 65 slacks off.
Robot 1 activates Robot 63.
...

result:

wrong answer 558th lines differ - expected: 'Robot 21 modifies a line of command of Robot 12.', found: 'Robot 21 modifies a line of command of Robot 39.'