QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671069#7965. 机器人hewanyingWA 61ms46580kbC++142.3kb2024-10-24 10:35:482024-10-24 10:35:48

Judging History

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

  • [2024-10-24 10:35:48]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:46580kb
  • [2024-10-24 10:35:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back

const int N=105;
const char st[7]={'L','O','W','I','E','C','R'};
int n,m,K,cnt=0,t[N][2],idx=0;
struct Nod{
  int op,h,x,y;
}a[N*N*N];
vector<int> G[N];
string T;

int Op(string T){
  for(int i=0;i<7;i++) if(T[1]==st[i]) return i;
  return -1;
}

int readin(){
  Nod &v=a[++idx];
  int nw=idx;
  cin>>T;v.op=Op(T);
  if(v.op==1) cin>>v.h>>v.x;
  else if(v.op==2) cin>>v.h>>v.x>>v.y,--v.x,--v.y;
  else if(v.op==3) cin>>v.h>>v.x,--v.x;
  else if(v.op==4){
    cin>>v.h>>v.x;--v.x;
    v.y=readin();
  }else if(v.op==5) cin>>v.h;
  else if(v.op==6){
    cin>>T;
    v.h=Op(T),v.x=readin();
  }
  return nw;
}

void init(){
  for(int i=0;i<n;i++){
    cin>>t[i][0]>>t[i][1];
    for(int j=0;j<m;j++) G[i].pb(readin());
  }
}

void rev(int id){
  if(a[id].op!=6) a[id].h^=1;
  else a[a[id].x].h^=1;
}

bool DO(int id);

bool wrk(int id,Nod v,int tp=0){
  if(cnt>=K) return false;
  if(v.op==6) return true;
  bool fl=true;
  
  int op=v.op,h=v.h,x=v.x,y=v.y;
  ++cnt;
  
  if(op==0) cout<<"Robot "<<id<<" slacks off.\n";
  else if(op==1){
    t[id][h]=(t[id][h]+x)%n;
    cout<<"Robot "<<id<<" moves its "<<(h==0?"left":"right")<<" hand towards Robot "<<t[id][h]<<".\n";
  }else if(op==2){
    swap(G[id][y],G[t[id][h]][x]);
    cout<<"Robot "<<id<<" swaps a line of command with Robot "<<t[id][h]<<".\n";
  }else if(op==3){
    rev(G[t[id][h]][x]);
    cout<<"Robot "<<id<<" modifies a line of command of Robot "<<t[id][h]<<".\n";
  }else if(op==4){
    G[t[id][h]][x]=y;
    cout<<"Robot "<<id<<" replaces a line of command of Robot "<<t[id][h]<<".\n";
  }else if(op==5){
    cout<<"Robot "<<id<<" activates Robot "<<t[id][h]<<".\n";
    fl&=DO(t[id][h]);
  }
  
  int to=t[id][1];
  if(to==id) return fl;
  
  for(int i=0;i<m;i++) if(a[G[to][i]].op==6){
    if(a[G[to][i]].h==op||(a[G[to][i]].h==6&&tp)){
      fl&=wrk(to,a[a[G[to][i]].x],1);
      break;
    }
  } 
  return fl;
}

bool DO(int id){
  for(int i=0;i<m;i++)
    if(!wrk(id,a[G[id][i]])) return false;
  return true;
}

int main(){
  /*2024.10.24 H_W_Y P9966 [THUPC 2024 初赛] 机器人 大模拟*/ 
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m>>K;init();
  
  int id=0;
  while(DO(id)) id=(id+1)%n;

  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 61ms
memory: 46580kb

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: 54ms
memory: 31960kb

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: 38ms
memory: 31756kb

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: 30ms
memory: 10640kb

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.'