제출 #315240

#제출 시각아이디문제언어결과실행 시간메모리
315240SeanliuCostinland (info1cup19_costinland)C++14
20 / 100
1 ms460 KiB
#include <iostream>
#define int long long int
using namespace std;

int D;
char mp[256][256];

inline void solve(int D){
	int cnt = 1;			
	for(int i = 0; i < 512; i++) for(int j = 0; j < 512; j++) mp[i][j] = '.';
	mp[0][0] = 'd';
	D--;
	if(D & 1){
		mp[0][0] = 'X';
		D--;
	}
	for(int i = 1; i < 63; i++){
		if((D >> i) & 1){
			mp[cnt][0] = 'X'; 
			for(int j = 0; j < i; j++){
				for(int k = 0; k < i; k++){
					mp[cnt + j][cnt + k] = (j + k < i ? 'X' : '.');
				}
			}
			cnt += i;
		}
	}	
	cnt++;
	for(int i = 0; i < cnt - 1; i++){
		mp[cnt - 1][i] = 'r';
		mp[i][cnt - 1] = 'd';
	}
	cout << cnt << " " << cnt << endl;
	for(int i = 0; i < cnt; i++){
		for(int j = 0; j < cnt; j++){
			cout << mp[i][j];
		}
		cout << endl;
	}
}

signed main(){
	cin >> D;
	if(D == 3){
		cout << "3 3\nrXd\n.Xd\nrr.\n";
	} else if(D == 4){
		cout << "3 3\nXXd\nX.d\nrr.\n";
	} else if(D == 5){
		cout << "5 5\nXXXXd\n....d\n....d\n....d\nrrrr.\n";
	} else if(D == 6){
		cout << "5 5\nXXXXd\nX...d\n....d\n....d\nrrrr.\n";
	} else if(D == 7){
		cout << "5 5\nXXXXd\nX...d\nX...d\n....d\nrrrr.\n";
	} else if(D == 8){
		cout << "5 5\nXXXXd\nX...d\nX...d\nX...d\nrrrr.\n";
	} else if(D == 9){
		cout << "5 5\nXXX.d\n.XX..d\nX...d\nX...d\nrrrr.\n";
	} else if(D == 10){
		cout << "5 5\nXXX.d\nXXX.d\n....d\n....d\nrrrr.\n";	
	} else if(D == 11){
		cout << "5 5\nXXX.d\nXXX.d\nX...d\n....d\nrrrr.\n";	
	} else if(D == 12){
		cout << "5 5\nXXX.d\nXXX.d\nX...d\nX...d\nrrrr.\n";	
	} else if(D == 13){
		cout << "5 5\nXXXXd\n.XXXd\n..X.d\n....d\nrrrr.\n";	
	} else if(D == 14){
		cout << "5 5\nXXXXd\n.XXXd\n...Xd\n....d\nrrrr.\n";	
	} else if(D == 15){
		cout << "5 5\nXXXXd\n.XXXd\n...Xd\nX...d\nrrrr.\n";	
	} else if(D == 16){
		cout << "5 5\nXXXXd\n.XXXd\n.X.Xd\n....d\nrrrr.\n";	
	} else if(D == 17){
		cout << "5 5\nXXXXd\n.XXXd\n.X.Xd\nX...d\nrrrr.\n";	
	} else if(D == 18){
		cout << "5 5\nX.X.d\nXXX.d\nXXX.d\n..X.d\nrrrr.\n";
	} else if(D == 19){
		cout << "5 5\nX.XXd\nXXX.d\nXXX.d\n..X.d\nrrrr.\n";
	} else {
		solve(D);
	}
}

컴파일 시 표준 에러 (stderr) 메시지

costinland.cpp: In function 'void solve(long long int)':
costinland.cpp:10:69: warning: iteration 256 invokes undefined behavior [-Waggressive-loop-optimizations]
   10 |  for(int i = 0; i < 512; i++) for(int j = 0; j < 512; j++) mp[i][j] = '.';
      |                                                            ~~~~~~~~~^~~~~
costinland.cpp:10:48: note: within this loop
   10 |  for(int i = 0; i < 512; i++) for(int j = 0; j < 512; j++) mp[i][j] = '.';
      |                                              ~~^~~~~
costinland.cpp:10:69: warning: iteration 256 invokes undefined behavior [-Waggressive-loop-optimizations]
   10 |  for(int i = 0; i < 512; i++) for(int j = 0; j < 512; j++) mp[i][j] = '.';
      |                                                            ~~~~~~~~~^~~~~
costinland.cpp:10:19: note: within this loop
   10 |  for(int i = 0; i < 512; i++) for(int j = 0; j < 512; j++) mp[i][j] = '.';
      |                 ~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...