結果

問題 No.455 冬の大三角
ユーザー aaaaaa
提出日時 2018-09-18 20:42:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,738 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 107,764 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 09:54:07
合計ジャッジ時間 6,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 WA -
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:343:31: 警告: ‘y3’ may be used uninitialized [-Wmaybe-uninitialized]
  343 |                         if (i == y3 && j == x3) {
      |                             ~~^~~~~
main.cpp:323:17: 備考: ‘y3’ はここで定義されています
  323 |         int x3, y3;
      |                 ^~
main.cpp:343:42: 警告: ‘x3’ may be used uninitialized [-Wmaybe-uninitialized]
  343 |                         if (i == y3 && j == x3) {
      |                                        ~~^~~~~
main.cpp:323:13: 備考: ‘x3’ はここで定義されています
  323 |         int x3, y3;
      |             ^~
main.cpp:31:25: 警告: ‘y2’ may be used uninitialized [-Wmaybe-uninitialized]
   31 |         int x1, y1, x2, y2;
      |                         ^~
main.cpp:111:20: 警告: ‘x2’ may be used uninitialized [-Wmaybe-uninitialized]
  111 |                 xx = x2;
      |                 ~~~^~~~
main.cpp:31:21: 備考: ‘x2’ はここで定義されています
   31 |         int x1, y1, x2, y2;
      |                     ^~
main.cpp:89:36: 警告: ‘y1’ may be used uninitialized [-Wmaybe-uninitialized]
   89 |                 for (i = y1 - 1; i >= 0; i--) {
      |                                  ~~^~~~
main.cpp:31:17: 備考: ‘y1’ はここで定義されています
   31 |         int x1, y1, x2, y2;
      |                 ^~
main.cpp:66:33: 警告: ‘x1’ may be used uninitialized [-Wmaybe-uninitialized]
   66 |                                 if (j == x1) {
      |                                 ^~
main.cpp:31:13: 備考: ‘x1’ はここで定義されています
   31 |         int x1, y1, x2, y2;
      |             ^~

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;

int main() {
	int i, j;
	int h, w;
	vector<string>s;
	double dx, dy;
	vector<vector<bool>>mat(105, vector<bool>(105, false));

	cin >> h >> w;

	int x1, y1, x2, y2;

	for (i = 0; i < h; i++) {
		string str;
		cin >> str;
		s.push_back(str);
	}


	bool flag = false;

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '*') {
				if (flag == false) {
					x1 = j;
					y1 = i;
					flag = true;
				}
				else {
					x2 = j;
					y2 = i;
					break;
				}
			}
		}
	}

	mat[y1][x1] = true;
	mat[y2][x2] = true;


	if (x1 == x2) {
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (j == x1) {
					mat[i][j] = true;
				}
			}
		}

	}
	else if (y1 == y2) {
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == y1) {
					mat[i][j] = true;
				}
			}
		}

	}
	else if (x2 > x1) { //右下がり
		dx = (double)(x2 - x1) / (double)abs(y2 - y1);

		//if (y2 > y1) {

		double xx = x1;
		for (i = y1 - 1; i >= 0; i--) {
			xx -= dx;
			int dox = floor(xx);
			int upx = ceil(xx);

			if (dox < 0) break;
			mat[i][dox] = true;
			mat[i][upx] = true;
		}

		xx = x1;

		for (i = y1 + 1; i < y2; i++) {
			xx += dx;
			int dox = floor(xx);
			int upx = ceil(xx);

			if (upx >= w) break;
			mat[i][dox] = true;
			mat[i][upx] = true;
		}

		xx = x2;

		for (i = y2 + 1; i < h; i++) {
			xx += dx;
			int dox = floor(xx);
			int upx = ceil(xx);

			if (upx >= w) break;
			mat[i][dox] = true;
			mat[i][upx] = true;
		}
		//}
	}
	else if (x2 < x1) { //右上がり
		dx = (double)(x1 - x2) / (double)abs(y1 - y2);

		//if (y2 > y1) {

		double xx = x1;
		for (i = y1 - 1; i >= 0; i--) {
			xx += dx;
			int dox = floor(xx);
			int upx = ceil(xx);

			if (upx >= w) break;
			mat[i][dox] = true;
			mat[i][upx] = true;
		}

		xx = x1;

		for (i = y1 + 1; i < y2; i++) {
			xx -= dx;
			int dox = floor(xx);
			int upx = ceil(xx);

			if (dox < 0) break;
			mat[i][dox] = true;
			mat[i][upx] = true;
		}

		xx = x2;

		for (i = y2 + 1; i < h; i++) {
			xx -= dx;
			int dox = floor(xx);
			int upx = ceil(xx);

			if (dox < 0) break;
			mat[i][dox] = true;
			mat[i][upx] = true;
		}
		//}
	}
	/*
	else if (x2 > x1) {
		dx = (double)(x2 - x1) / (double)abs(y2 - y1);

		if (y2 > y1) {  //右斜め下がり

			double xx = x1;
			for (i = y1 - 1; i >= 0; i--) {
				xx -= dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (dox < 0) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x1;

			for (i = y1 + 1; i < y2; i++) {
				xx += dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (upx >= w) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x2;

			for (i = y2 + 1; i < h; i++) {
				xx += dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (upx >= w) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}
		}
		else if (y2 < y1) { //右上がり直線
			double xx = x1;
			for (i = y1 - 1; i >= 0; i--) {
				xx += dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (upx >= w) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x1;

			for (i = y1 + 1; i < y2; i++) {
				xx -= dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (dox < 0) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x2;

			for (i = y2 + 1; i < h; i++) {
				xx -= dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (dox < 0) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}
		}
	}
	else if (x2 < x1) {
		dx = (double)(x1 - x2) / (double)abs(y1 - y2);

		if (y2 < y1) { //右下がり

			double xx = x2;
			for (i = y2 - 1; i >= 0; i--) {
				xx -= dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (dox < 0) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x2;

			for (i = y2 + 1; i < y1; i++) {
				xx += dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (upx >= w) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x1;

			for (i = y1 + 1; i < h; i++) {
				xx += dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (upx >= w) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}
		}
		else if (y2 > y1) { //右上がり直線
			double xx = x2;
			for (i = y1 - 1; i >= 0; i--) {
				xx += dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (upx >= w) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x1;

			for (i = y1 + 1; i < y2; i++) {
				xx -= dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (dox < 0) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}

			xx = x2;

			for (i = y2 + 1; i < h; i++) {
				xx -= dx;
				int dox = floor(xx);
				int upx = ceil(xx);

				if (dox < 0) break;
				mat[i][dox] = true;
				mat[i][upx] = true;
			}
		}
	}
	*/


	int x3, y3;

	bool flag2 = false;

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (mat[i][j] == false) {
				x3 = j;
				y3 = i;
				flag2 = true;
				break;
			}
		}
		if (flag2 == true) break;
	}

	cout << endl;

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (i == y3 && j == x3) {
				cout << "*";
				continue;
			}
			else {
				cout << s[i][j];
			}
		}
		cout << endl;
	}

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (mat[i][j] == true) {
				cout << 1;
			}
			else {
				cout << 0;
			}
		}
		cout << endl;
	}












	getchar();
	getchar();
	return 0;
}
0