結果

問題 No.240 ナイト散歩
コンテスト
ユーザー fal_rnd
提出日時 2017-01-21 01:23:14
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 942 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 992 ms
コンパイル使用メモリ 181,292 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-24 08:22:26
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:10:16: warning: ignoring return value of 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   10 |         cin.tie();
      |         ~~~~~~~^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:48,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/istream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/sstream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/complex:50,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ccomplex:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:133,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_ios.h:310:7: note: declared here
  310 |       tie() const
      |       ^~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

using  ll = long long int;
using ull = unsigned long long int;
const char en ='\n';
const int  mod=1000000007;

int main(){
	cin.tie();
	ios::sync_with_stdio(false);

	bool field[20][20]; for(int i=0;i<20;i++) fill_n(field[i],20,false);

	int dx[]{-2,-2,-1,-1,1,1,2,2};
	int dy[]{-1,1,-2,2,-2,2,-1,1};


	deque<pair<int,int>> d;
	d.push_back(make_pair(10,10));
	field[10][10]=true;
	for(int i=0;i<3;i++){
		int size=d.size();
		for(int j=0;j<size;j++){
			pair<int,int> p=d.front(),q;
			d.pop_front();
			for(int k=0;k<8;k++){
				q=make_pair(p.first+dx[k],p.second+dy[k]);
				d.push_back(q);
				field[q.first][q.second]=true;
			}
		}
	}

	int x,y;
	cin>>x>>y;

	x+=10;
	y+=10;

	if(x>20||x<0||y>20||y<0){
		cout<<"NO"<<en;
	}else{
		cout<<(field[x][y]?"YES":"NO")<<en;
	}

	/*
	for(int i=0;i<20;i++){
		for(int j=0;j<20;j++){
			cout<<field[i][j]<<" ";
		}
		cout<<en;
	}
	*/

	return 0;
}
0