結果
| 問題 |
No.585 工夫のないパズル
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2017-10-30 00:10:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,456 bytes |
| コンパイル時間 | 1,424 ms |
| コンパイル使用メモリ | 164,600 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 05:46:58 |
| 合計ジャッジ時間 | 2,228 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
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
ソースコード
#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,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,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,-1);
rotD(x-1,-1);
rotR(3,2);
rotD(x-1,1);
rotR(3,-1);
rotD(x-1,-1);
rotR(3,-1);
}
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,-(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,-(3-py));
rotD(x,-(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,-(3-y));
}
}
}
}
rotR(3,4-PX[12]);
if(PX[13]==3) swapadj(2);
if(PX[13]==2) swapadj(1);
if(PX[14]==3) 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;
}
kmjp