結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー くまくま
提出日時 2022-06-07 17:19:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,683 bytes
コンパイル時間 1,544 ms
コンパイル使用メモリ 164,512 KB
最終ジャッジ日時 2024-11-15 02:18:39
合計ジャッジ時間 2,333 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'void in(T& ...)':
main.cpp:30:55: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   30 | template<class... T>void in(T&... a) { (cin >> ... >> a); }
      |                                                       ^
main.cpp: In function 'void out(const T&, const Ts& ...)':
main.cpp:32:111: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   32 | template<class T, class... Ts>void out(const T& a, const Ts&... b) { cout << a;(cout << ... << (cout << ' ', b));cout << '\n'; }
      |                                                                                                               ^
main.cpp: In instantiation of 'void in(T& ...) [with T = {std::vector<std::vector<long long int, std::allocator<long long int> >, std::allocator<std::vector<long long int, std::allocator<long long int> > > >}]':
main.cpp:47:5:   required from here
main.cpp:30:55: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<std::vector<long long int>, std::allocator<std::vector<long long int> > >')
   30 | template<class... T>void in(T&... a) { (cin >> ... >> a); }
      |                                        ~~~~~~~~~~~~~~~^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _C

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
const int INF = 1e9;
const ll LINF = 1e18;
const double eps = 1e-10;
#define fi first
#define se second
#define eb emplace_back
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define srep(i, s, n) for (ll i = s; i < (ll)(n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fore(i,x) for(auto &i:x)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define sz(x) (ll)x.size()
#define dame { puts("-1"); return;}
#define yes { puts("Yes"); return;}
#define no { puts("No"); return;}
#define ret(x) { cout<<(x)<<'\n'; return;}
bool is_pop(ll hash, ll d){return (hash>>d)&1;}
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using PQ = priority_queue<T,vc<T>,greater<T>>;
template<class... T>void in(T&... a) { (cin >> ... >> a); }
void out() { cout << '\n'; }
template<class T, class... Ts>void out(const T& a, const Ts&... b) { cout << a;(cout << ... << (cout << ' ', b));cout << '\n'; }
template< typename T >istream &operator>>(istream &is, vector< T > &v){for(T &in : v) is >> in;return is;}
template< typename T >ostream &operator<<(ostream &os, const vector< T > &v){for(int i = 0; i < (int) v.size(); i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;}
template<class... T>constexpr auto min(T... a) { return min(initializer_list<common_type_t<T...>>{a...}); }
template<class... T>constexpr auto max(T... a) { return max(initializer_list<common_type_t<T...>>{a...}); }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void MAIN(); int main() { cin.tie(0); ios::sync_with_stdio(false); MAIN(); }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void MAIN()
{
  ll h,w;
  in(h,w);
  vv<ll> a(h,vl(w));
  in(a);
  vv<vl> dp(h,vv<ll>(w,vl(2)));
  dp[0][0][0] = a[0][0];
  rep(i,h) rep(j,w) rep(k,2) {
    ll now = dp[i][j][k];
    if(i + 1 < h) {
      if(now > a[i+1][j]) chmax(dp[i+1][j][k],now+a[i+1][j]);
      else if(k == 0) chmax(dp[i+1][j][1],now);
    }
    if(j + 1 < w) {
      if(now > a[i][j+1]) chmax(dp[i][j+1][k],now+a[i][j+1]);
      else if(k == 0) chmax(dp[i][j+1][1],now);
    }
  }
  bool flg = false;
  rep(k,2) if(dp[h-1][w-1][k] > a[h-1][w-1]) flg = true;
  if(flg) yes
  else no
}
0