From 252f0d84c8a468ccc61f13225a39582467cfe3d7 Mon Sep 17 00:00:00 2001 From: Nitin Singh Kanyal <77480195+Legit-Doodle@users.noreply.github.com> Date: Sat, 8 Oct 2022 15:32:58 +0530 Subject: [PATCH] Create ColorThePicture.cpp Color The Picture --- ColorThePicture.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 ColorThePicture.cpp 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"<