Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
# CodeChef
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![GitHub contributors](https://img.shields.io/github/contributors/aviraw/CodeChef.svg)](https://github.com/aviraw/CodeChef/graphs/contributors)
[![contributions welcome](https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=0059b3&style=flat-square)](https://github.com/aviraw/CodeChef/blob/master/contributing.md) 
#

DO FOLLOW MY GITHUB ACCOUNT I WOULD REALLY APPRECIATE IT. [Aviraw](https://github.com/aviraw/)


#Answers and problems

| Number | Name of Problem | Contributed By |
|-|-|-|
|1.|[Broken Telephone](https://github.com/aviraw/CodeChef/blob/master/Broken%20Telephone)|[sachin-cpp](https://github.com/sachin-cpp)|
|2.|[CHFM](https://github.com/aviraw/CodeChef/blob/master/CHFM)|[aviraw](https://github.com/aviraw)|
|3.|[Chef And Friends](https://github.com/aviraw/CodeChef/blob/master/Chef%20And%20Friends)|[aviraw](https://github.com/aviraw)|
|4.|[IPL and RCB](https://github.com/VkRan/CodeChef-1/blob/master/IPL%20and%20RCB.cpp)|[VkRan](https://github.com/VkRan)
|5.|[Zig_Zag_Tree](https://github.com/aviraw/CodeChef/blob/master/Broken%20Telephone)|[RaghavJindal13](https://github.com/RaghavJindal13)|
|6.|[Iterative_inorder](https://github.com/aviraw/CodeChef/blob/master/Broken%20Telephone)|[Kr-Raman](https://github.com/Kr-Raman)|
|7.|[towerofhanoi](https://github.com/dhairya2019/CodeChef/blob/master/towerofhanoi.cpp/)|[dhairya2019](https://github.com/dhairya2019)|
|8.|[CombinationSum](https://github.com/ananya07105/CodeChef/blob/master/CombinationSum)|[Ananya Sharma](https://github.com/ananya07105)|
|9.|[SOLBLTY](https://github.com/SidGoyal15555/CodeChef/commit/dca992f0f3b7f0d9887f7fcf0f3a20f693730319)|[SidGoyal15555](https://github.com/SidGoyal15555)|
|10.|[WWALK](https://github.com/rupal2711/CodeChef/commit/c732c1b93a9a8b8059a9b044c9a1b1551c9151ff)|[rupal2711](https://github.com/rupal2711)|
|11.|[Maximum difference of zeros and ones in binary string](https://github.com/Med16-11/CodeChef/blob/master/Maximum%20difference%20of%200s%20and%201s%20in%20binary%20string.cpp)|[Med16-11](https://github.com/Med16-11)|
|12.|[Travel Pass](https://github.com/aviraw/CodeChef/blob/master/Travel_Pass.cpp)|[DEEP DAS](https://github.com/myselfdeepdas)|
|13.|[Maximum Dual Area](https://github.com/AnjiAgrawal/CodeChef/blob/master/Minimum%20Dual%20Area.cpp)|[Anjali Agrawal](https://github.com/AnjiAgrawal)|
|14.|[Count Occurences of Anagrams](https://github.com/Med16-11/CodeChef/blob/master/Count%20Occurences%20of%20Anagrams.cpp)|[Med16-11](https://github.com/Med16-11)|
|15.|[Travel Pass](https://github.com/aviraw/CodeChef/blob/master/Travel_Pass.cpp)|[DEEP DAS](https://github.com/myselfdeepdas)|
|16.|[Valid Pair Sum](https://github.com/Med16-11/CodeChef/blob/master/Valid%20Pair%20Sum.cpp)|[Med16-11](https://github.com/Med16-11)|
|17.|[Ceil and A-B Problem](https://github.com/SajalRuhela017/CodeChef/blob/master/Ceil_AB.cpp)|[Sajal Ruhela](https://github.com/SajalRuhela017)|
|18.|[HOLES](https://github.com/aviraw/CodeChef/blob/master/holes_in_a_text.py)|[Kodali Bhavana](https://github.com/Kodali-Bhavana)|
|19.|[Smart Phone](https://github.com/SajalRuhela017/CodeChef/blob/master/Smart%20Phone.cpp)|[Sajal Ruhela](https://github.com/SajalRuhela017)|
|20.|[MAXDISTKT.cpp](https://github.com/sysoutayush/CodeChef/blob/master/MAXDISTKT.cpp)|[Ayush yadav](https://github.com/sysoutayush)|

72 changes: 72 additions & 0 deletions Vacation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <bits/stdc++.h>

std::vector<std::vector<int>> g1;
std::vector<std::pair<int,int>> zeroVector;
int m, n, q;


void takevectorinput(int n, int m) {
int tmp=0;
for (int i=1; i<=n; i++) {
std::vector<int> store;
for (int j=1; j<=m; j++)
{
std::cin >> tmp;
store.push_back(tmp);
if (tmp == 0)
{
zeroVector.push_back(std::make_pair(i,j));
}
}
g1.push_back(store);
}
}

int cheapestpath(std::pair<int, int> startingpoint, std::pair<int, int> endingpoint) {

// Same point
if (startingpoint.first == endingpoint.first && startingpoint.second == endingpoint.second) {
return g1[startingpoint.first-1][startingpoint.second-1];
}

if (zeroVector.size() > 0 )
{
for (int i=0;i<zeroVector.size();i++)
{
if (n==1){
if((zeroVector[i].second >= startingpoint.second && zeroVector[i].second <= endingpoint.second))
{
return 0;
}
}
else{
if((zeroVector[i].first >= startingpoint.first && zeroVector[i].first <= endingpoint.first) && (zeroVector[i].second >= startingpoint.second && zeroVector[i].second <= endingpoint.second) ){
return 0;
}
}

}
}
return 1;
}

int main() {
std::cin >> n >> m;
takevectorinput(n, m);
std::cin >> q;
while (q--) {
int a, b, c ,d, totalcost;
std::cin >> a >> b >> c >> d;
if (g1[c-1][d-1] == 0) {
totalcost = 0;
}
else {



totalcost = cheapestpath(std::make_pair(a,b), std::make_pair(c,d));
}
std::cout << totalcost << "\n";
}
return 0;
}