結果

問題 No.2432 Flip and Move
ユーザー 沙耶花沙耶花
提出日時 2023-08-18 22:51:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,299 bytes
コンパイル時間 3,827 ms
コンパイル使用メモリ 264,104 KB
実行使用メモリ 112,768 KB
最終ジャッジ日時 2024-05-06 05:19:18
合計ジャッジ時間 22,057 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 149 ms
57,984 KB
testcase_06 WA -
testcase_07 AC 1,017 ms
59,184 KB
testcase_08 AC 1,103 ms
64,012 KB
testcase_09 AC 1,461 ms
86,308 KB
testcase_10 WA -
testcase_11 AC 233 ms
82,436 KB
testcase_12 WA -
testcase_13 AC 180 ms
62,720 KB
testcase_14 WA -
testcase_15 AC 1,206 ms
74,188 KB
testcase_16 AC 211 ms
25,088 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 540 ms
39,296 KB
testcase_22 WA -
testcase_23 AC 65 ms
14,020 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 538 ms
38,144 KB
testcase_30 AC 680 ms
52,736 KB
testcase_31 AC 286 ms
42,752 KB
testcase_32 WA -
testcase_33 AC 659 ms
51,328 KB
testcase_34 AC 227 ms
28,416 KB
testcase_35 AC 153 ms
37,760 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:50:16: warning: 'D' may be used uninitialized [-Wmaybe-uninitialized]
   50 |         K %= (D*2);
      |              ~~^~~
main.cpp:19:13: note: 'D' was declared here
   19 |         int D;
      |             ^

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	int h,w;
	cin>>h>>w;
	
	long long K;
	cin>>K;
	int D;
	{
		vector f(h,vector(w,vector<int>(4,0)));
		int cx = 0,cy = 0;
		int d = 0;
		vector<int> dx = {1,-1};
		rep(i,Inf32){
			
			f[cx][cy][d] ++;
			int nx = cx+dx[d&1];
			int ny = cy+dx[(d>>1)&1];
			if(nx<0||nx>=h){
				d ^= 1;
			}
			else{
				cx = nx;
			}
			if(ny<0||ny>=w){
				d ^= 2;
			}
			else{
				cy = ny;
			}
			if(cx==0&&cy==0&&d==0){
				D = i+1;
				break;
			}
		}
		
	}
	
	K %= (D*2);
	{
		vector f(h,vector(w,vector<int>(4,0)));
		int cx = 0,cy = 0;
		int d = 0;
		vector<int> dx = {1,-1};
		rep(i,K){
			
			f[cx][cy][d] ++;
			int nx = cx+dx[d&1];
			int ny = cy+dx[(d>>1)&1];
			if(nx<0||nx>=h){
				d ^= 1;
			}
			else{
				cx = nx;
			}
			if(ny<0||ny>=w){
				d ^= 2;
			}
			else{
				cy = ny;
			}
			if(cx==0&&cy==0&&d==0){
				D = i+1;
				break;
			}
		}
		rep(i,h){
			rep(j,w){
				int cur =0;
				rep(k,4){
					cur ^= f[i][j][k];
				}
				cur %= 2;
				if(cur%2==1)cout<<'#';
				else cout<<'.';
			}
			cout<<endl;
		}
	}
	
	return 0;
}
0