Submission #7067205
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define pll pair<ll,ll> #define rep(i,n) for(int i=0;i<n;i++) const ll INF = 1LL<<60; const ll mod = (int)1e9 + 7; int main() { //ll N; cin >> N; //ll N,M; cin >> N >> M; //string S; cin >> S; ll H,W; cin >> H >> W; bool five=false; int ma=0; vector<int> loc5; int a[H*W]; rep(i,H*W){ cin >> a[i]; if(a==5){ five=true; loc5.push_back(i); } chmax(ma,a); } if(ma==0)cout << "Yes" << ' ' << 0; else if(five){ if(H!=1 && W!=1){ cout << "Yes" << ' '; if(ma<=5)cout << 1; if(ma==6)cout << 2; if(ma==7)cout << 2; if(ma==8)cout << 3; if(ma==9)cout << 4; } else{ int mini=100; for(auto x:loc5){ int ml=0; int mr=0; rep(i,x){ chmax(ml,a[i]); } for(int i=x+1;i<H*W;i++){ chmax(mr,a[i]); } if(ml<=5)ml=0; if(ml==6)ml=1; if(ml==7)ml=1; if(ml==8)ml=2; if(ml==9)ml=3; if(mr<=5)mr=0; if(mr==6)mr=1; if(mr==7)mr=1; if(mr==8)mr=2; if(mr==9)mr=3; chmin(mini,ml+mr+1); } cout << "Yes" << ' ' << mini; } } else cout << "No"; } /* */
Submission Info
Submission Time | |
---|---|
Task | B - 10 puzzle |
User | lucky_space |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1869 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:23:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(a==5){ ^ ./Main.cpp:27:19: error: no matching function for call to ‘chmax(int&, int [(H * W)])’ chmax(ma,a); ^ ./Main.cpp:4:31: note: candidate: template<class T> bool chmax(T&, T) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } ^ ./Main.cpp:4:31: note: template argument deduction/substitution failed: ./Main.cpp:27:19: note: deduced conflicting types for parameter ‘T’ (‘int’ and ‘int*’) chmax(ma,a); ^