結果
| 問題 | No.323 yuki国 |
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-12-16 14:34:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 5,000 ms |
| コード長 | 1,652 bytes |
| 記録 | |
| コンパイル時間 | 910 ms |
| コンパイル使用メモリ | 94,500 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 12:22:49 |
| 合計ジャッジ時間 | 2,238 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d%d", &h, &w);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:21:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | for(int i=0; i<2; i++) scanf("%d%d%d", &a[i], &r[i], &c[i]);//cin >> a[i] >> r[i] >> c[i];
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:24:52: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | for(int i=0; i<h; i++) m[i] = string((scanf("%s", buff),buff));//cin >> m[i];
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;
typedef bitset<2550> bits;
int main(){
int h,w;
//cin >> h >> w;
scanf("%d%d", &h, &w);
vector<int> a(2),r(2),c(2);
for(int i=0; i<2; i++) scanf("%d%d%d", &a[i], &r[i], &c[i]);//cin >> a[i] >> r[i] >> c[i];
vector<string> m(h);
char buff[100];
for(int i=0; i<h; i++) m[i] = string((scanf("%s", buff),buff));//cin >> m[i];
if( abs(a[0]-a[1])%2 != abs(r[0]-r[1] + c[0]-c[1])%2){
//cout << "No" << endl;
puts("No");
return 0;
}
bits inc,dec;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
(m[i][j]=='.'?dec:inc).set( (w+1)*i + j );
}
}
int mx_size = 1200;
int times = 1200;
vector<bits> s(mx_size);
s[a[0]].set( (w+1)*r[0] + c[0] );
queue<int> update;
vector<int> used(mx_size, 0);
update.push(a[0]);
used[a[0]] = 1;
while(update.size() && s[a[1]][(w+1)*r[1] + c[1]]==false){
int k = update.front();
update.pop();
used[k] = 0;
bits tmp = (s[k]<<1) | (s[k]>>1) | (s[k]<<(w+1)) | (s[k]>>(w+1));
if(k+1<mx_size){
bits next = s[k+1]|(tmp&inc);
if(next != s[k+1]){
s[k+1] = next;
if(used[k+1]==0){
used[k+1] = 1;
update.push(k+1);
}
}
}
if(k-1>0){
bits next = s[k-1]|(tmp&dec);
if(next != s[k-1]){
s[k-1] = next;
if(used[k-1]==0){
used[k-1] = 1;
update.push(k-1);
}
}
}
}
if(s[a[1]][(w+1)*r[1] + c[1]]){
//cout << "Yes" << endl;
puts("Yes");
}else{
//cout << "No" << endl;
puts("No");
}
return 0;
}
koyumeishi