結果
| 問題 |
No.2826 Earthwork
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-07-25 16:32:25 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,010 bytes |
| コンパイル時間 | 3,310 ms |
| コンパイル使用メモリ | 253,772 KB |
| 実行使用メモリ | 19,200 KB |
| 最終ジャッジ日時 | 2024-07-25 16:32:49 |
| 合計ジャッジ時間 | 22,336 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | RE * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
vector<vector<ll>> h(n,vector<ll>(n));
rep(i,n){
rep(j,n){
cin >> h[i][j];
}
}
vector<string> s(n);
rep(i,n) cin >> s[i];
vector<vector<ll>> a(n-1,vector<ll>(n)),b(n,vector<ll>(n-1));
rep(i,n-1){
rep(j,n){
cin >> a[i][j];
a[i][j]*=abs(h[i][j]+h[i+1][j]);
}
}
rep(i,n){
rep(j,n-1){
cin >> b[i][j];
b[i][j]*=abs(h[i][j]+h[i][j+1]);
}
}
auto f=[&](ll r,ll c,ll x){
if(h[r][c]==x) return true;
if(h[r][c]<x&&(s[r][c]=='+'||s[r][c]=='?')) return true;
if(x<h[r][c]&&(s[r][c]=='-'||s[r][c]=='?')) return true;
return false;
};
ll q;
cin >> q;
while(q--){
ll r,c,e;
cin >> r >> c >> e;
r--;
c--;
bool ng=false;
ng|=!f(r,c,e);
ng|=(0<=r-1&&!(abs(h[r-1][c]+e)<=a[r-1][c]||(f(r-1,c,-a[r-1][c]-e)||f(r-1,c,a[r-1][c]-e))));
ng|=(0<=c-1&&!(abs(h[r][c-1]+e)<=a[r][c-1]||(f(r,c-1,-b[r][c-1]-e)||f(r,c-1,b[r][c-1]-e))));
ng|=(r+1<n&&!(abs(h[r+1][c]+e)<=a[r][c]||(f(r+1,c,-a[r][c]-e)||f(r+1,c,a[r][c]-e))));
ng|=(c+1<n&&!(abs(h[r][c+1]+e)<=b[r][c]||(f(r,c+1,-b[r][c]-e)||f(r,c+1,b[r][c]-e))));
if(!ng) cout << "Yes\n";
else cout << "No\n";
}
}
FplusFplusF