結果

問題 No.585 工夫のないパズル
ユーザー 👑 kmjpkmjp
提出日時 2017-10-30 00:07:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,459 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 164,500 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 22:30:46
合計ジャッジ時間 3,723 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:129:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<std::vector<int> >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
  129 |         _P("%d\n",R.size());
      |            ^~~~~~ ~~~~~~~~
      |                         |
      |                         std::vector<std::vector<int> >::size_type {aka long unsigned int}
main.cpp:6:30: note: in definition of macro ‘_P’
    6 | #define _P(...) (void)printf(__VA_ARGS__)
      |                              ^~~~~~~~~~~
main.cpp:129:14: note: format string is defined here
  129 |         _P("%d\n",R.size());
      |             ~^
      |              |
      |              int
      |             %ld

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S[4];
int A[4][4];
int PY[16];
int PX[16];
vector<vector<int>> R;

void goswap(int y1,int x1,int y2,int x2) {
	y1=(y1+8)%4;
	x1=(x1+8)%4;
	y2=(y2+8)%4;
	x2=(x2+8)%4;
	swap(A[y1][x1],A[y2][x2]);
	PY[A[y1][x1]]=y1;
	PX[A[y1][x1]]=x1;
	PY[A[y2][x2]]=y2;
	PX[A[y2][x2]]=x2;
}


void rotR(int row,int num) {
	num=(num+8)%4;
	if(num==0) return;
	R.push_back({0,row+1,num});
	int i;
	FOR(i,num) {
		goswap(row,3,row,2);
		goswap(row,2,row,1);
		goswap(row,1,row,0);
	}
}

void rotD(int col,int num) {
	num=(num+8)%4;
	if(num==0) return;
	R.push_back({1,col+1,num});
	int i;
	FOR(i,num) {
		goswap(3,col,2,col);
		goswap(2,col,1,col);
		goswap(1,col,0,col);
	}
}

void swapadj(int x) {
	rotD(x-1,1);
	rotR(3,3);
	rotD(x-1,3);
	rotR(3,2);
	rotD(x-1,1);
	rotR(3,3);
	rotD(x-1,3);
	rotR(3,3);
}

void test() {
	int y,x;
	FOR(y,4) {
		FOR(x,4) _P("%c",'A'+A[y][x]);
		_P("\n");
	}
	_P("::\n");
}



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(y,4) {
		cin>>S[y];
		FOR(x,4) {
			A[y][x]=S[y][x]-'A';
			PY[A[y][x]]=y;
			PX[A[y][x]]=x;
		}
	}
	FOR(x,4) {
		FOR(y,3) {
			int target=y*4+x;
			int py=PY[target], px=PX[target];
			
			if(y==0) {
				if(PX[target]!=x) {
					rotD(px,3-py);
					rotR(3,x-px);
					rotD(px,4-(3-py));
				}
				rotD(x,4-PY[target]);
			}
			else {
				if(PX[target]!=x) {
					rotD(x,3-y);
					rotD(px,3-py);
					rotR(3,x-px);
					rotD(px,4-(3-py));
					rotD(x,4-(3-y));
				}
				else {
					if(PY[target]==y) continue;
					rotD(x,3-py);
					rotR(3,1);
					rotD(x,(3-y)-(3-py));
					rotR(3,3);
					rotD(x,4-(3-y));
				}
			}
		}
	}
	
	rotR(3,4-PX[12]);
	if(PX[13]==3) swapadj(2);
	if(PX[13]==2) swapadj(1);
	if(PX[14]==4) swapadj(2);
	
	_P("%d\n",R.size());
	FORR(r,R) {
		if(r[0]==0) _P("R");
		else _P("C");
		_P(" %d %d\n",r[1],r[2]);
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0