結果

問題 No.2432 Flip and Move
ユーザー umezoumezo
提出日時 2023-08-25 04:32:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,663 ms / 2,000 ms
コード長 1,075 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 209,316 KB
実行使用メモリ 182,684 KB
最終ジャッジ日時 2023-08-25 04:32:41
合計ジャッジ時間 31,086 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1,110 ms
128,964 KB
testcase_03 AC 1,111 ms
182,684 KB
testcase_04 AC 13 ms
4,652 KB
testcase_05 AC 12 ms
4,592 KB
testcase_06 AC 270 ms
36,092 KB
testcase_07 AC 697 ms
119,516 KB
testcase_08 AC 749 ms
129,560 KB
testcase_09 AC 1,057 ms
176,392 KB
testcase_10 AC 687 ms
82,936 KB
testcase_11 AC 790 ms
94,104 KB
testcase_12 AC 559 ms
70,948 KB
testcase_13 AC 376 ms
48,952 KB
testcase_14 AC 243 ms
43,412 KB
testcase_15 AC 878 ms
150,844 KB
testcase_16 AC 674 ms
53,144 KB
testcase_17 AC 1,498 ms
112,056 KB
testcase_18 AC 307 ms
34,080 KB
testcase_19 AC 1,169 ms
87,364 KB
testcase_20 AC 1,663 ms
123,756 KB
testcase_21 AC 1,140 ms
85,336 KB
testcase_22 AC 1,304 ms
98,716 KB
testcase_23 AC 203 ms
27,184 KB
testcase_24 AC 1,531 ms
107,832 KB
testcase_25 AC 1,038 ms
79,616 KB
testcase_26 AC 492 ms
51,312 KB
testcase_27 AC 26 ms
6,712 KB
testcase_28 AC 18 ms
6,104 KB
testcase_29 AC 1,251 ms
83,352 KB
testcase_30 AC 1,562 ms
116,560 KB
testcase_31 AC 511 ms
48,728 KB
testcase_32 AC 66 ms
11,596 KB
testcase_33 AC 1,554 ms
113,956 KB
testcase_34 AC 799 ms
60,536 KB
testcase_35 AC 283 ms
29,640 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int h,w;
  ll k;
  cin>>h>>w>>k;
  vector<vector<char>> G(h,vector<char>(w,'.'));
  
  set<array<int,4>> s;
  int ni=0,nj=0,dh=1,dw=1;
  while(1){
  	s.insert({ni,nj,dh,dw});
  	if(dh==1){
  		if(ni==h-1) dh=0;
  		else ni++;
  	}
  	else{
  		if(ni==0) dh=1;
  		else ni--;
  	}
  	
  	if(dw==1){
  		if(nj==w-1) dw=0;
  		else nj++;
  	}
  	else{
  		if(nj==0) dw=1;
  		else nj--;
  	}
  
    if(s.count({ni,nj,dh,dw})) break;
  }
  int a=s.size();
  k%=a;
  
  ni=0,nj=0,dh=1,dw=1;
  while(k--){
  	if(G[ni][nj]=='.') G[ni][nj]='#';
  	else G[ni][nj]='.';
  	
  	if(dh==1){
  		if(ni==h-1) dh=0;
  		else ni++;
  	}
  	else{
  		if(ni==0) dh=1;
  		else ni--;
  	}
  	
  	if(dw==1){
  		if(nj==w-1) dw=0;
  		else nj++;
  	}
  	else{
  		if(nj==0) dw=1;
  		else nj--;
  	}
  }
  rep(i,h){
  	rep(j,w) cout<<G[i][j];
  	cout<<'\n';
  }

  return 0;
}
0