結果
| 問題 |
No.2432 Flip and Move
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 21:38:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,596 ms / 2,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 1,009 ms |
| コンパイル使用メモリ | 83,624 KB |
| 実行使用メモリ | 159,424 KB |
| 最終ジャッジ日時 | 2024-11-28 06:09:37 |
| 合計ジャッジ時間 | 18,943 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cassert>
//#include<atcoder/modint>
using namespace std;
//using mint=atcoder::modint998244353;
int H,W;
long K;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>H>>W>>K;
vector<vector<vector<long> > >vis(H,vector<vector<long> >(W,vector<long>(4,-1)));
vector<vector<int> >col(H,vector<int>(W,0));
int x=0,y=0,dir=0;
while(K>0)
{
if(vis[x][y][dir]!=-1)
{
long d=vis[x][y][dir]-K;
d*=2;
K%=d;
}
vis[x][y][dir]=K;
col[x][y]=1-col[x][y];
{
int tx=x;
if(dir%2==0)tx++;
else tx--;
if(tx>=0&&tx<H)x=tx;
else dir^=1;
}
{
int ty=y;
if(dir/2==0)ty++;
else ty--;
if(ty>=0&&ty<W)y=ty;
else dir^=2;
}
K--;
}
for(int i=0;i<H;i++)
{
for(int j=0;j<W;j++)cout<<(col[i][j]==0?'.':'#');
cout<<"\n";
}
}