diff --git a/ColorThePicture.cpp b/ColorThePicture.cpp new file mode 100644 index 0000000..e8b0bc4 --- /dev/null +++ b/ColorThePicture.cpp @@ -0,0 +1,61 @@ +//COLOR THE PICTURE + +#include +using namespace std; + +void solve(){ + + //the picture will be strip of rows with col more than 2 or strip of cols with row more than 2 + + int n,m,k; + cin >> n >> m >> k; + + vector a(k); + + for(int i=0;i> a[i]; + + long long cols = 0; + int flag = 0; + for(int i=0;i 2) flag = 1; + if(a[i]/n >=2) cols += a[i]/n; + } + + if(cols >= m && (flag || m%2==0)){ + cout << "YES" << endl; + return; + } + + long long rows = 0; + flag = 0; + for(int i=0;i 2) flag = 1; + if(a[i]/m >=2) rows += a[i]/m; + } + + if(rows >= n && (flag || n%2==0)){ + cout << "YES" << endl; + return; + } + + cout << "NO" << endl; +} + +int main() +{ + #ifndef ONLINE_JUDGE + freopen("input.txt", "r", stdin); + freopen("output.txt", "w", stdout); + #endif + + int t; + cin>>t; + + while(t--) + { + solve(); + } + + cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<