CSES - Putka Open 2015 – 6/6 - Results
Submission details
Task:Shakki
Sender:
Submission time:2015-12-06 17:39:13 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
Test results
testverdicttimegroup
#10.14 s1details
#20.15 s1details
#30.20 s1details
#40.15 s1details
#50.06 s1details
#60.08 s1details
#70.19 s1details
#80.14 s1details
#90.14 s1details
#100.14 s1details
#110.15 s2details
#120.07 s2details
#130.16 s2details
#140.15 s2details
#150.21 s2details
#160.06 s2details
#170.14 s2details
#18ACCEPTED0.06 s2details
#190.14 s2details
#200.19 s2details
#210.05 s3details
#220.14 s3details
#230.07 s3details
#240.08 s3details
#250.10 s3details
#260.15 s3details
#270.19 s3details
#280.08 s3details
#290.14 s3details
#300.19 s3details
#310.09 s4details
#320.14 s4details
#330.14 s4details
#340.08 s4details
#350.20 s4details
#36ACCEPTED0.06 s4details
#370.06 s4details
#380.19 s4details
#390.20 s4details
#400.20 s4details

Compiler report

input/code.cpp: In function 'void print_board(std::vector<std::vector<char> >&)':
input/code.cpp:92:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int64_t i=0;i<board.size();i++) {
                    ^
input/code.cpp:93:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int64_t j=0;j<board.size();j++) {
                      ^
input/code.cpp: In function 'int main()':
input/code.cpp:745:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int64_t i=0;i<moves.size();i++) {
                    ^

Code

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
#include<cmath>
#include<utility>

using namespace std;

void rotate(vector<vector<char>> &b, int64_t x, int64_t y, int d) {
  if(d == 1) {
    char c=b[x][y];
    b[x][y] = b[x][y+1];
    b[x][y+1] = b[x+1][y+1];
    b[x+1][y+1] = b[x+1][y];
    b[x+1][y]=c;
  } else {
    char c=b[x][y];
    b[x][y] = b[x+1][y];
    b[x+1][y] = b[x+1][y+1];
    b[x+1][y+1] = b[x][y+1];
    b[x][y+1] = c;
  }
}


int64_t hsh(const vector<vector<char>> &b) {
  int64_t h=1;
  for(int64_t i=0;i<4;i++) {
    for(int64_t j=0;j<4;j++) {
      if(b[i][j] == 'M') {
        h=2*h+1;
      } else {
        h=2*h;
      }
    }
  }
  return h;
}

bool fine(const vector<vector<char>> &b) {
  for(int64_t i=0;i<3;i++) {
    for(int64_t j=0;j<3;j++) {
      if(b[i][j] == b[i+1][j] || b[i][j] == b[i][j+1]) {
        return false;
      }
    }
    if(b[i][3] == b[i+1][3]) return false;
  }
  for(int64_t j=0;j<3;j++) {
    if(b[3][j] == b[3][j+1]) return false;
  }
  return true;
}

vector<pair<int64_t,int64_t>> bfs(vector<vector<char>> &b, map<int64_t,pair<pair<int64_t,int64_t>,int64_t>> &found, int64_t hshstart) {

  queue<vector<vector<char>>> q;
  q.push(b);

  while(!q.empty()) {
    vector<vector<char>> bb=q.front();
    q.pop();
    if(fine(bb)) {
      int64_t tmp=hsh(bb);
      vector<pair<int64_t,int64_t>> moves;
      while(tmp != hshstart) {
        moves.push_back(found[tmp].first);
        tmp=found[tmp].second;
      }
      return moves;
    }
    int64_t oldhsh=hsh(bb);
    for(int64_t i=0;i<3;i++) {
      for(int64_t j=0;j<3;j++) {
        rotate(bb, i, j, 1);
        if(found.find(hsh(bb)) == found.end()) {
          q.push(bb);
          found[hsh(bb)]=make_pair(make_pair(i, j), oldhsh);
        }
        rotate(bb, i, j, -1);
      }
    }
  }
  return vector<pair<int64_t,int64_t>>();
}

void print_board(vector<vector<char>> &board) {
  for(int64_t i=0;i<board.size();i++) {
    for(int64_t j=0;j<board.size();j++) {
      cout << board[j][i];
    }
    cout << '\n';
  }
}

int main(void) {
  vector<vector<char>> board(8,vector<char>(8));
  for(int64_t i=0;i<8;i++) {
    for(int64_t j=0;j<8;j++) {
      char c;
      cin >> c;
      board[j][i]=c;
    }
  }

  vector<pair<int64_t,int64_t>> moves;

  int64_t A=0,B=0,C=0,D=0;
  for(int64_t x=0;x<4;x++) for(int64_t y=0;y<4;y++) if(board[x][y] == 'M') A++;
  for(int64_t x=4;x<8;x++) for(int64_t y=0;y<4;y++) if(board[x][y] == 'M') B++;
  for(int64_t x=0;x<4;x++) for(int64_t y=4;y<8;y++) if(board[x][y] == 'M') C++;
  for(int64_t x=4;x<8;x++) for(int64_t y=4;y<8;y++) if(board[x][y] == 'M') D++;
  while(A > 8) {
    if(B < 16) {
      int64_t x=4,y=0;
      for(;x<8;x++) {
        bool out=false;
        y=0;
        for(;y<4;y++) {
          if(board[x][y] == 'V') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(y == 0) {
        if(x == 4) {
          for(int64_t i=0;i<3;i++) {
            rotate(board,x,y,1);
            moves.push_back(make_pair(x,y));
          }
          y++;
        } else {
          rotate(board,x-1,y,1);
          moves.push_back(make_pair(x-1,y));
          y++;
        }
      }
      while(x > 4) {
        rotate(board,x-1,y-1,1);
        moves.push_back(make_pair(x-1,y-1));
        x--;
      }
      int64_t xx=0,yy=0;
      for(;xx<4;xx++) {
        yy=0;
        bool out=false;
        for(;yy<4;yy++) {
          if(board[xx][yy] == 'M') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(yy == 3) {
        if(xx == 3) {
          for(int64_t i=0;i<3;i++) {
            rotate(board,xx-1,yy-1,1);
            moves.push_back(make_pair(xx,yy));
          }
          yy--;
        } else {
          rotate(board,xx,yy-1,1);
          moves.push_back(make_pair(xx,yy-1));
          yy--;
        }
      }
      while(yy > y-1) {
        rotate(board,xx,yy-1,1);
        moves.push_back(make_pair(xx,yy-1));
        yy--;
      }
      while(xx < 3) {
        rotate(board,xx, yy, 1);
        moves.push_back(make_pair(xx,yy));
        xx++;
      }
      rotate(board,xx, yy, 1);
      moves.push_back(make_pair(xx,yy));
      A--;
      B++;
    } else if(C < 16) {
      int64_t x=0,y=4;
      for(;x<4;x++) {
        y=0;
        bool out=false;
        for(;y<8;y++) {
          if(board[x][y] == 'V') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(x == 3) {
        if(y == 4) {
          for(int64_t i=0;i<3;i++) {
            rotate(board,x-1,y,1);
            moves.push_back(make_pair(x-1,y));
          }
          x--;
        } else {
          rotate(board,x-1,y-1,1);
          moves.push_back(make_pair(x-1,y-1));
          x--;
        }
      }
      while(y > 4) {
        rotate(board,x,y-1,1);
        moves.push_back(make_pair(x,y-1));
        y--;
      }
      int64_t xx=0,yy=0;
      for(;xx<4;xx++) {
        yy=0;
        bool out=false;
        for(;yy<4;yy++) {
          if(board[xx][yy] == 'M') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(yy == 3) {
        rotate(board,xx,yy-1,1);
        moves.push_back(make_pair(xx,yy-1));
        yy--;
      }
      while(xx < x+1) {
        rotate(board,xx,yy,1);
        moves.push_back(make_pair(xx,yy));
        xx++;
      }
      while(yy < 3) {
        rotate(board,xx-1,yy,1);
        moves.push_back(make_pair(xx-1,yy));
        yy++;
      }
      rotate(board,xx-1,yy,1);
      moves.push_back(make_pair(xx-1,yy));
      A--;
      C++;
    }
  }

  while(A < 8) {
    if(B > 0) {
      int64_t x=4,y=0;
      for(;x<8;x++) {
        bool out=false;
        y=0;
        for(;y<4;y++) {
          if(board[x][y] == 'M') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(y == 0) {
        if(x == 4) {
          for(int64_t i=0;i<3;i++) {
            rotate(board,x,y,1);
            moves.push_back(make_pair(x,y));
          }
          y++;
        } else {
          rotate(board,x-1,y,1);
          moves.push_back(make_pair(x-1,y));
          y++;
        }
      }
      while(x > 4) {
        rotate(board,x-1,y-1,1);
        moves.push_back(make_pair(x-1,y-1));
        x--;
      }
      int64_t xx=0,yy=0;
      for(;xx<4;xx++) {
        yy=0;
        bool out=false;
        for(;yy<4;yy++) {
          if(board[xx][yy] == 'V') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(yy == 3) {
        if(xx == 3) {
          for(int64_t i=0;i<3;i++) {
            rotate(board,xx-1,yy-1,1);
            moves.push_back(make_pair(xx,yy));
          }
          yy--;
        } else {
          rotate(board,xx,yy-1,1);
          moves.push_back(make_pair(xx,yy-1));
          yy--;
        }
      }
      while(yy > y-1) {
        rotate(board,xx,yy-1,1);
        moves.push_back(make_pair(xx,yy-1));
        yy--;
      }
      while(xx < 3) {
        rotate(board,xx, yy, 1);
        moves.push_back(make_pair(xx,yy));
        xx++;
      }
      rotate(board,xx, yy, 1);
      moves.push_back(make_pair(xx,yy));
      A--;
      B++;
    } else if(C > 0) {
      int64_t x=0,y=4;
      for(;x<4;x++) {
        y=0;
        bool out=false;
        for(;y<8;y++) {
          if(board[x][y] == 'M') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(x == 3) {
        if(y == 4) {
          for(int64_t i=0;i<3;i++) {
            rotate(board,x-1,y,1);
            moves.push_back(make_pair(x-1,y));
          }
          x--;
        } else {
          rotate(board,x-1,y-1,1);
          moves.push_back(make_pair(x-1,y-1));
          x--;
        }
      }
      while(y > 4) {
        rotate(board,x,y-1,1);
        moves.push_back(make_pair(x,y-1));
        y--;
      }
      int64_t xx=0,yy=0;
      for(;xx<4;xx++) {
        yy=0;
        bool out=false;
        for(;yy<4;yy++) {
          if(board[xx][yy] == 'V') {
            out=true;
            break;
          }
        }
        if(out) break;
      }
      if(yy == 3) {
        rotate(board,xx,yy-1,1);
        moves.push_back(make_pair(xx,yy-1));
        yy--;
      }
      while(xx < x+1) {
        rotate(board,xx,yy,1);
        moves.push_back(make_pair(xx,yy));
        xx++;
      }
      while(yy < 3) {
        rotate(board,xx-1,yy,1);
        moves.push_back(make_pair(xx-1,yy));
        yy++;
      }
      rotate(board,xx-1,yy,1);
      moves.push_back(make_pair(xx-1,yy));
      A--;
      C++;
    }
  }

  if(D > 8) {
    if(B < 8) {
      /* B from D*/
      while(B < 8) {
        int64_t x=4,y=4;
        for(;x<8;x++) {
          y=0;
          bool out=false;
          for(;y<8;y++) {
            if(board[x][y] == 'M') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(x == 7) {
          if(y == 4) {
            for(int64_t i=0;i<3;i++) {
              rotate(board,x-1,y,1);
              moves.push_back(make_pair(x-1,y));
            }
            x--;
          } else {
            rotate(board,x-1,y-1,1);
            moves.push_back(make_pair(x-1,y-1));
            x--;
          }
        }
        while(y > 4) {
          rotate(board,x,y-1,1);
          moves.push_back(make_pair(x,y-1));
          y--;
        }
        int64_t xx=4,yy=0;
        for(;xx<8;xx++) {
          yy=0;
          bool out=false;
          for(;yy<4;yy++) {
            if(board[xx][yy] == 'V') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(yy == 3) {
          rotate(board,xx,yy-1,1);
          moves.push_back(make_pair(xx,yy-1));
          yy--;
        }
        while(xx < x+1) {
          rotate(board,xx,yy,1);
          moves.push_back(make_pair(xx,yy));
          xx++;
        }
        while(yy < 3) {
          rotate(board,xx-1,yy,1);
          moves.push_back(make_pair(xx-1,yy));
          yy++;
        }
        rotate(board,xx-1,yy,1);
        moves.push_back(make_pair(xx-1,yy));
        B++;
        D--;
      }
    } else {
      /* C from D*/
      while(C < 8) {
        int64_t x=4,y=4;
        for(;x<8;x++) {
          y=0;
          bool out=false;
          for(;y<8;y++) {
            if(board[x][y] == 'M') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(y == 4) {
          if(x == 4) {
            for(int64_t i=0;i<3;i++) {
              rotate(board,x,y,1);
              moves.push_back(make_pair(x,y));
            }
            y++;
          } else {
            rotate(board,x-1,y,1);
            moves.push_back(make_pair(x-1,y));
            y++;
          }
        }
        while(x > 4) {
          rotate(board,x-1,y-1,1);
          moves.push_back(make_pair(x-1,y-1));
          x--;
        }
        int64_t xx=0,yy=4;
        for(;xx<4;xx++) {
          yy=0;
          bool out=false;
          for(;yy<8;yy++) {
            if(board[xx][yy] == 'V') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(yy == 7) {
          if(xx == 3) {
            for(int64_t i=0;i<3;i++) {
              rotate(board,xx-1,yy-1,1);
              moves.push_back(make_pair(xx,yy));
            }
            yy--;
          } else {
            rotate(board,xx,yy-1,1);
            moves.push_back(make_pair(xx,yy-1));
            yy--;
          }
        }
        while(yy > y-1) {
          rotate(board,xx,yy-1,1);
          moves.push_back(make_pair(xx,yy-1));
          yy--;
        }
        while(xx < 3) {
          rotate(board,xx, yy, 1);
          moves.push_back(make_pair(xx,yy));
          xx++;
        }
        rotate(board,xx, yy, 1);
        moves.push_back(make_pair(xx,yy));
        D--;
        C++;
      }
    }
  }
  if(D < 8) {
    if(B > 8) {
      /* B from D*/
      while(B < 8) {
        int64_t x=4,y=4;
        for(;x<8;x++) {
          bool out=false;
          for(;y<8;y++) {
            if(board[x][y] == 'V') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(x == 7) {
          if(y == 4) {
            for(int64_t i=0;i<3;i++) {
              rotate(board,x-1,y,1);
              moves.push_back(make_pair(x-1,y));
            }
            x--;
          } else {
            rotate(board,x-1,y-1,1);
            moves.push_back(make_pair(x-1,y-1));
            x--;
          }
        }
        while(y > 4) {
          rotate(board,x,y-1,1);
          moves.push_back(make_pair(x,y-1));
          y--;
        }
        int64_t xx=4,yy=0;
        for(;xx<8;xx++) {
          yy=0;
          bool out=false;
          for(;yy<4;yy++) {
            if(board[xx][yy] == 'M') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(yy == 3) {
          rotate(board,xx,yy-1,1);
          moves.push_back(make_pair(xx,yy-1));
          yy--;
        }
        while(xx < x+1) {
          rotate(board,xx,yy,1);
          moves.push_back(make_pair(xx,yy));
          xx++;
        }
        while(yy < 3) {
          rotate(board,xx-1,yy,1);
          moves.push_back(make_pair(xx-1,yy));
          yy++;
        }
        rotate(board,xx-1,yy,1);
        moves.push_back(make_pair(xx-1,yy));
        B--;
        D++;
      }
    } else {
      while(C < 8) {
        int64_t x=4,y=4;
        for(;x<8;x++) {
          y=0;
          bool out=false;
          for(;y<8;y++) {
            if(board[x][y] == 'V') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(y == 4) {
          if(x == 4) {
            for(int64_t i=0;i<3;i++) {
              rotate(board,x,y,1);
              moves.push_back(make_pair(x,y));
            }
            y++;
          } else {
            rotate(board,x-1,y,1);
            moves.push_back(make_pair(x-1,y));
            y++;
          }
        }
        while(x > 4) {
          rotate(board,x-1,y-1,1);
          moves.push_back(make_pair(x-1,y-1));
          x--;
        }
        int64_t xx=0,yy=4;
        for(;xx<4;xx++) {
          yy=0;
          bool out=false;
          for(;yy<8;yy++) {
            if(board[xx][yy] == 'M') {
              out=true;
              break;
            }
          }
          if(out) break;
        }
        if(yy == 7) {
          if(xx == 3) {
            for(int64_t i=0;i<3;i++) {
              rotate(board,xx-1,yy-1,1);
              moves.push_back(make_pair(xx,yy));
            }
            yy--;
          } else {
            rotate(board,xx,yy-1,1);
            moves.push_back(make_pair(xx,yy-1));
            yy--;
          }
        }
        while(yy > y-1) {
          rotate(board,xx,yy-1,1);
          moves.push_back(make_pair(xx,yy-1));
          yy--;
        }
        while(xx < 3) {
          rotate(board,xx, yy, 1);
          moves.push_back(make_pair(xx,yy));
          xx++;
        }
        rotate(board,xx, yy, 1);
        moves.push_back(make_pair(xx,yy));
        D++;
        C--;
      }
    }
  }

  vector<vector<char>> bA(4,vector<char>(4));
  vector<vector<char>> bB(4,vector<char>(4));
  vector<vector<char>> bC(4,vector<char>(4));
  vector<vector<char>> bD(4,vector<char>(4));
  for(int64_t i=0;i<4;i++) {
    for(int64_t j=0;j<4;j++) {
      bA[i][j]=board[i][j];
    }
  }
  for(int64_t i=4;i<8;i++) {
    for(int64_t j=0;j<4;j++) {
      bB[i-4][j]=board[i][j];
    }
  }
  for(int64_t i=0;i<4;i++) {
    for(int64_t j=4;j<8;j++) {
      bC[i][j-4]=board[i][j];
    }
  }
  for(int64_t i=4;i<8;i++) {
    for(int64_t j=4;j<8;j++) {
      bD[i-4][j-4]=board[i][j];
    }
  }

  /*vector<vector<char>> bar(4,vector<char>(4));
  for(int64_t i=0;i<4;i++) {
    for(int64_t j=0;j<4;j++) {
      if((i+j)%2) {
        bar[i][j]='M';
      } else {
        bar[i][j]='V';
      }
    }
  }
  print_board(bar);
  hsh1=hsh(bar);
  for(int64_t i=0;i<4;i++) {
    for(int64_t j=0;j<4;j++) {
      if((i+j)%2) {
        bar[i][j]='V';
      } else {
        bar[i][j]='M';
      }
    }
  }
  print_board(bar);
  hsh2=hsh(bar);*/

  map<int64_t,pair<pair<int64_t,int64_t>,int64_t>> found;

  vector<pair<int64_t,int64_t>> foo=bfs(bA, found, hsh(bA));
  for(int64_t i=foo.size()-1;i>=0;i--) {
    moves.push_back(foo[i]);
  }

  found.clear();
  foo=bfs(bB, found, hsh(bB));
  for(int64_t i=foo.size()-1;i>=0;i--) {
    moves.push_back(make_pair(foo[i].first+4, foo[i].second));
  }

  found.clear();
  foo=bfs(bC, found, hsh(bC));
  for(int64_t i=foo.size()-1;i>=0;i--) {
    moves.push_back(make_pair(foo[i].first, foo[i].second+4));
  }

  found.clear();
  foo=bfs(bD, found, hsh(bD));
  for(int64_t i=foo.size()-1;i>=0;i--) {
    moves.push_back(make_pair(foo[i].first+4, foo[i].second+4));
  }

  cout << moves.size() << '\n';
  for(int64_t i=0;i<moves.size();i++) {
    cout << moves[i].first+1 << " " << moves[i].second+1 << "\n";
  }

  return 0;
}

Test details

Test 1

Group: 1

Verdict:

input
VMMVVMVV
MMVVMVVV
MMVVMMMM
MVVVMVVM
MVVVVMVM
...

correct output
100000

user output
(empty)

Test 2

Group: 1

Verdict:

input
MVMVVMMV
VVMMVVVV
VMMVMMVM
MVVVVMVM
MVMVMMVM
...

correct output
100000

user output
(empty)

Test 3

Group: 1

Verdict:

input
VMMMVMVV
MMMVMVMV
VMMVMVVM
VVVMVMMV
MVMVMVMV
...

correct output
100000

user output
26
5 1
5 1
5 1
1 1
...

Error:
*** Error in `input/code': double free or corruption (out): 0x0000000001c84100 ***

Test 4

Group: 1

Verdict:

input
VVVMVMVV
VMMVMVMM
MVVMMVMV
VMVMMVMM
MMVVMMVM
...

correct output
100000

user output
(empty)

Test 5

Group: 1

Verdict:

input
MVMVVMMM
VVMMVVMV
MVVMVVMM
VMVMVMMV
MMVMVVVM
...

correct output
100000

user output
8
2 1
3 1
3 2
5 3
...

Test 6

Group: 1

Verdict:

input
VMMVMVVM
VVMMVVMM
MMMVMVVM
VMMVMMVM
MVMVMMMV
...

correct output
100000

user output
16
1 2
1 1
1 1
2 1
...

Test 7

Group: 1

Verdict:

input
MVVVVMMM
MMMMMMMM
VVVVVMMV
MMVVMVVM
VMVVVVMV
...

correct output
100000

user output
(empty)

Test 8

Group: 1

Verdict:

input
VMMVMVMM
MMMVVMMM
MVVVVVVV
VVVVMMMV
MVVVMVVM
...

correct output
100000

user output
(empty)

Test 9

Group: 1

Verdict:

input
VVVVVMMM
MMVVVVVV
MVVVMMMM
VVMVVVVM
VMMVMVMM
...

correct output
100000

user output
(empty)

Test 10

Group: 1

Verdict:

input
VMMVMMMM
VVMVVVVV
VMMVMVMV
VMMVMVMM
VVVMMMMM
...

correct output
100000

user output
(empty)

Test 11

Group: 2

Verdict:

input
VMVMVVMM
MMVMVVMM
VMVVVMMV
VVVMVMVM
VVMMVVMM
...

correct output
25000

user output
(empty)

Test 12

Group: 2

Verdict:

input
MVMVVMVV
VMMVVMVM
VMVVVMMM
VMMMMVVM
MMVVVMMM
...

correct output
25000

user output
19
1 2
2 2
3 2
4 2
...

Test 13

Group: 2

Verdict:

input
MVVMMVVV
MMVVMVMM
VVVMVMVV
VMVMMMMM
MVVMMVMV
...

correct output
25000

user output
(empty)

Test 14

Group: 2

Verdict:

input
VVMMMVMV
VMVVVMVV
VVMVVVMM
MVVMVMVM
MMVVMMMM
...

correct output
25000

user output
(empty)

Test 15

Group: 2

Verdict:

input
MVVVMVVV
MMMMVMMM
MVMMMVVM
MMVVVMVM
VMVVVMMV
...

correct output
25000

user output
23
1 1
2 1
3 1
4 1
...

Error:
*** Error in `input/code': double free or corruption (out): 0x0000000001976100 ***

Test 16

Group: 2

Verdict:

input
VMMVMVVM
VMMVVVVV
MVMVMMVM
VMMVVVMV
VVMVMMVM
...

correct output
25000

user output
25
5 2
5 2
5 3
5 4
...

Test 17

Group: 2

Verdict:

input
MVVMMVVM
MVVVMMMV
MVVMMVVM
VMMVMVMV
VMMVMMMM
...

correct output
25000

user output
(empty)

Test 18

Group: 2

Verdict: ACCEPTED

input
MVMMVVMM
VVMMMMVV
VMVVVVVM
MVMMMVMV
VMVVVMVM
...

correct output
25000

user output
26
5 1
5 1
5 1
1 1
...

Test 19

Group: 2

Verdict:

input
MVVVVVVV
VMMVMVVM
VMVMMMMV
MVMVMMMM
MMVVVMMM
...

correct output
25000

user output
(empty)

Test 20

Group: 2

Verdict:

input
MVVVMMMM
MMVMMVMV
MVVVVVMM
VVMMMVVM
VVVMVMVV
...

correct output
25000

user output
(empty)

Test 21

Group: 3

Verdict:

input
VMVVMVMM
MMMMVMMV
VVVMVVVV
MVMVMVVM
VMMVMMMM
...

correct output
5000

user output
20
5 2
5 2
5 3
5 4
...

Test 22

Group: 3

Verdict:

input
VVVVVVMM
MMMVMMVV
VVVVVVMV
MMMVMVVV
MVVMMMMV
...

correct output
5000

user output
(empty)

Test 23

Group: 3

Verdict:

input
MMVMVMVV
MMVVMVVM
VMMVVMVM
MMMMMMVV
MVVVVMVM
...

correct output
5000

user output
27
5 1
5 1
5 1
1 1
...

Test 24

Group: 3

Verdict:

input
MVMVVMVM
VVMVVMVM
MMMMVMVV
MVVMMVVV
MMMMMVVV
...

correct output
5000

user output
13
5 1
5 1
5 1
1 1
...

Test 25

Group: 3

Verdict:

input
MVVVMVVM
MMMMVVMV
VMMVMMVV
VVMVMVMV
MVMMMVMM
...

correct output
5000

user output
12
1 2
2 3
3 1
3 2
...

Test 26

Group: 3

Verdict:

input
VMVMVVVM
MMMVVVMM
MMVVVVVM
VVVVMMVV
VMMVVMMV
...

correct output
5000

user output
(empty)

Test 27

Group: 3

Verdict:

input
MMVMMVVM
MVVVMVMV
MVVVMVVM
VMVMMMVV
VMMVVVVV
...

correct output
5000

user output
(empty)

Test 28

Group: 3

Verdict:

input
MVMMVMMV
VMVMMMVV
MMMMVVMV
VVVVMMMM
MMMVMMVV
...

correct output
5000

user output
19
5 1
5 1
5 1
1 1
...

Test 29

Group: 3

Verdict:

input
VVVVMVMV
MMMVVMVM
MVVVMVMV
VVVMVVMM
VMMMMMVV
...

correct output
5000

user output
(empty)

Test 30

Group: 3

Verdict:

input
MVVVMVVV
MMVVMMMM
MVVVVVVV
MVMVMMMV
VMMMVMMM
...

correct output
5000

user output
(empty)

Test 31

Group: 4

Verdict:

input
MVMMVMMV
VVVMMVVV
VMMVVMMV
VVMMMVVM
VVVMMMVV
...

correct output
250

user output
15
5 1
5 1
5 2
5 3
...

Test 32

Group: 4

Verdict:

input
VVMMVVVM
VMVVMMVV
VMMMMMMV
VVMVMVVV
VMMVMVMM
...

correct output
250

user output
(empty)

Test 33

Group: 4

Verdict:

input
MMVVMVMV
VVVMVMMM
VVVVMVMM
MVVMVVMV
VMMVMVVM
...

correct output
250

user output
(empty)

Test 34

Group: 4

Verdict:

input
VMVMVVMV
MVVMMMMM
MMVVMMMM
VMVMVVVM
VMMMVVVM
...

correct output
250

user output
4
3 1
2 2
2 1
1 1

Test 35

Group: 4

Verdict:

input
VMVMVMMM
VMMVVVMM
MMVMVMMM
MVMMVVVV
VMMVMMMV
...

correct output
250

user output
38
5 1
5 1
5 1
1 2
...

Error:
*** Error in `input/code': double free or corruption (out): 0x0000000001629100 ***

Test 36

Group: 4

Verdict: ACCEPTED

input
MVMVMVMM
MVMVMMMV
MMVVVVMM
MVMVVVVV
VMMMVVMM
...

correct output
250

user output
23
1 1
1 1
2 2
1 2
...

Test 37

Group: 4

Verdict:

input
VMMMMVMM
VVMMMVMV
VMVVVVVV
MVMMMVVM
VMVMMVVM
...

correct output
250

user output
30
1 3
1 2
1 2
2 2
...

Test 38

Group: 4

Verdict:

input
VMMVMVMV
VVMVMVMM
MMMVMVMM
MVVVVMMM
MMVVVMVV
...

correct output
250

user output
(empty)

Test 39

Group: 4

Verdict:

input
MMMMMVMV
MVVMMMMV
VMVVVVMM
VMVVVMMV
MVMMMVMM
...

correct output
250

user output
19
1 2
1 1
1 0
1 0
...

Error:
*** Error in `input/code': double free or corruption (out): 0x00000000022c0100 ***

Test 40

Group: 4

Verdict:

input
VMMMMMMV
VMMVVVVV
MVMMVMMV
MVVVVMMV
MVVVVMMM
...

correct output
250

user output
16
1 2
1 1
1 1
2 1
...

Error:
*** Error in `input/code': double free or corruption (out): 0x0000000000983100 ***