Codeforces Round #684 DIV1 A2問題/DIV2 C2問題 - Binary Table (Hard Version)

Source

Codeforces Round #684 DIV1 A2問題 (500pt)
Codeforces Round #684 DIV2 C2問題 (750pt)
Problem description

問題概要

省略

解法

省略

cLayversion 20201121-1)のコード

C++に変換後のコードはこちら

//no-unlocked
int X, Y;
char S[100][102];
int ress, res[10000][6];

int zs, z1[4], z2[4];
int os, o1[4], o2[4];
{
  REP(rd_int()){
    rd(X,Y,S(X));
    rep(i,X) rep(j,Y) S[i][j] -= '0';
    ress = 0;

    rep(i,X-2) rep(j,Y) if(S[i][j]==1){
      (res[ress][0], res[ress][1]) = (i, j);
      (res[ress][2], res[ress][3]) = (i+1, j);
      (res[ress][4], res[ress][5]) = (i+1, if[j==Y-1, j-1, j+1]);
      rep(k,3) S[res[ress][2k]][res[ress][2k+1]] ^= 1;
      ress++;
    }
    rep(j,Y-2) rep(i,X-2,X) if(S[i][j]==1){
      (res[ress][0], res[ress][1]) = (i, j);
      (res[ress][2], res[ress][3]) = (i, j+1);
      (res[ress][4], res[ress][5]) = (if[i==X-1, i-1, i+1], j+1);
      rep(k,3) S[res[ress][2k]][res[ress][2k+1]] ^= 1;
      ress++;
    }

    zs = os = 0;
    rep(i,X-2,X) rep(j,Y-2,Y){
      if(S[i][j]==0) arrInsert(zs, zs, z1, i, z2, j);
      if(S[i][j]==1) arrInsert(os, os, o1, i, o2, j);
    }

    if(os == 1){
      rep(i,3){
        rep(k,2) (res[ress][2k], res[ress][2k+1]) = (z1[(i+k)%3], z2[(i+k)%3]);
        (res[ress][4], res[ress][5]) = (o1[0], o2[0]);
        rep(k,3) S[res[ress][2k]][res[ress][2k+1]] ^= 1;
        ress++;
      }
    }
    if(os == 2){
      rep(i,2){
        rep(k,2) (res[ress][2k], res[ress][2k+1]) = (z1[k], z2[k]);
        (res[ress][4], res[ress][5]) = (o1[i], o2[i]);
        rep(k,3) S[res[ress][2k]][res[ress][2k+1]] ^= 1;
        ress++;
      }
    }
    if(os == 3){
      rep(k,3) (res[ress][2k], res[ress][2k+1]) = (o1[k], o2[k]);
      rep(k,3) S[res[ress][2k]][res[ress][2k+1]] ^= 1;
      ress++;
    }
    if(os == 4){
      rep(i,4){
        rep(k,3) (res[ress][2k], res[ress][2k+1]) = (o1[(i+k)%4], o2[(i+k)%4]);
        rep(k,3) S[res[ress][2k]][res[ress][2k+1]] ^= 1;
        ress++;
      }
    }

    wt(ress);
    rep(i,ress) wt(res[i](6)+1);
  }
}

Current time: 2021年09月17日16時28分42秒
Last modified: 2020年11月21日18時56分20秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces CF684 CF_DIV1_A CF_DIV2_C
トップページに戻る

Logged in as: unknown user (not login)

ログイン: