Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string color1, color2, color3, color;
- int floors1, floors2, floors3, floors;
- cin >> color1 >> floors1;
- cin >> color2 >> floors2;
- cin >> color3 >> floors3;
- cin >> color >> floors;
- bool ignore_color = color == "?"s;
- bool ignore_floor = floors == -1;
- if ((ignore_color || color == color1) && (ignore_floor || floors == floors1)) {
- cout << 1 << endl;
- }
- if ((ignore_color || color == color2) && (ignore_floor || floors == floors2)) {
- cout << 2 << endl;
- }
- if ((ignore_color || color == color3) && (ignore_floor || floors == floors3)) {
- cout << 3 << endl;
- }
- }
Advertisement
Comments
-
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string c1, c2, c3, cx;
- int h1, h2, h3, hx;
- cin >> c1 >> h1 >> c2 >> h2 >> c3 >> h3 >> cx >> hx;
- if (((c1 == cx) && (h1 == hx)) || ((c1 == cx) && (hx == -1)) || ((cx == "?"s) && (h1 == hx)) || ((cx == "?"s) && (hx == -1))) {
- cout << "1" << endl;
- }
- if (((c2 == cx) && (h2 == hx)) || ((c2 == cx) && (hx == -1)) || ((cx == "?"s) && (h2 == hx)) || ((cx == "?"s) && (hx == -1))) {
- cout << "2" << endl;
- }
- if (((c3 == cx) && (h3 == hx)) || ((c3 == cx) && (hx == -1)) || ((cx == "?"s) && (h3 == hx)) || ((cx == "?"s) && (hx == -1))) {
- cout << "3" << endl;
- }
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- string color_house_1, color_house_2, color_house_3, color_house_4;
- int number_house_1, number_house_2, number_house_3, number_house_4;
- cin >> color_house_1 >> number_house_1 >> color_house_2 >> number_house_2 >> color_house_3 >> number_house_3 >> color_house_4 >> number_house_4;
- if (((color_house_1 == color_house_4) || (color_house_4 == "?"s)) && ((number_house_1 == number_house_4) || (number_house_4 == -1))) {
- cout << 1 << endl;
- }
- if (((color_house_2 == color_house_4) || (color_house_4 == "?"s)) && ((number_house_2 == number_house_4) || (number_house_4 == -1))) {
- cout << 2 << endl;
- }
- if (((color_house_3 == color_house_4) || (color_house_4 == "?"s)) && ((number_house_3 == number_house_4) || (number_house_4 == -1))) {
- cout << 3 << endl;
- }
- return 0;
- }
-
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string a, b, c, d;
- int a1{}, b1{}, c1{}, d1{};
- cin >> a >> a1 >> b >> b1 >> c >> c1 >> d >> d1;
- /*
- red 3 green 3 green 2 green -1
- 2 3
- red 2 green 1 red 3 red 3
- 3
- red 1 green 2 blue 3 yellow 3
- grey 5 grey 5 grey 5 grey 5
- 1 2 3
- red 3 green 3 green 2 ? -1
- 1 2 3
- */
- if (d == "?" && d1 == -1)
- {
- cout << 1 << endl
- << 2 << endl
- << 3 << endl;
- }
- else if (d != "?" && d1 != -1)
- {
- if (a == d && a1 == d1)
- {
- cout << 1 << endl;
- }
- if (b == d && b1 == d1)
- {
- cout << 2 << endl;
- }
- if (c == d && c1 == d1)
- {
- cout << 3 << endl;
- }
- }
- else if (d == "?" || d1 == -1)
- {
- if (a == d || a1 == d1)
- {
- cout << 1 << endl;
- }
- if (b == d || b1 == d1)
- {
- cout << 2 << endl;
- }
- if (c == d || c1 == d1)
- {
- cout << 3 << endl;
- }
- }
- }
-
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- vector<string> colors = {};
- vector<int> floors = {};
- string buf_color;
- int buf_floor;
- cin >> buf_color >> buf_floor;
- colors.push_back(buf_color);
- floors.push_back(buf_floor);
- cin >> buf_color >> buf_floor;
- colors.push_back(buf_color);
- floors.push_back(buf_floor);
- cin >> buf_color >> buf_floor;
- colors.push_back(buf_color);
- floors.push_back(buf_floor);
- cin >> buf_color >> buf_floor;
- if (buf_floor == -1 && buf_color == "?"s) //если нет информации вообще
- {
- cout << 1 << endl << 2 << endl << 3 << endl;
- }
- else if (buf_floor == -1) //если этажность не указана
- {
- for (int i = 0; i < 3; i++)
- {
- if (buf_color == colors[i]) //сравниваем цвета
- cout << i+1 << endl;
- }
- }
- else if (buf_color == "?"s) //если цвет не указан
- {
- for (int i = 0; i < 3; i++)
- {
- if (buf_floor == floors[i]) //сравниваем этажность
- cout << i+1 << endl;
- }
- }
- else //если указано всё
- {
- for (int i = 0; i < 3; i++)
- {
- if (buf_floor == floors[i] && buf_color == colors[i]) //сравниваем этажность и цветность
- cout << i+1 << endl;
- }
- }
- return 0;
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- string Color[4];
- int N[4];
- int i;
- cin >> Color[0] >> N[0];
- cin >> Color[1] >> N[1];
- cin >> Color[2] >> N[2];
- cin >> Color[3] >> N[3];
- for (i=0; i<=2; i++) {
- if (((N[i]==N[3])||(N[3]<0)) && ((Color[i]==Color[3])||(Color[3]=="?"s)))
- cout << i+1 << endl;
- }
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- string color1, color2, color3;
- string color_Witness{"?"s};
- int floors1, floors2, floors3;
- int floors_Witness{-1};
- // Считайте информацию о трёх домах, которые видит перед собой Марта,
- cin >> color1 >> floors1 >> color2 >> floors2 >> color3 >> floors3;
- // а также показания очевидца.
- cin >> color_Witness >> floors_Witness;
- // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
- // по одному номеру в каждой строке
- if( color_Witness != "?"s && floors_Witness != -1 ){ // ввел и цвет и этажность
- if(color1 == color_Witness && floors1 == floors_Witness) {
- cout << 1 << endl;
- } if(color2 == color_Witness && floors2 == floors_Witness){
- cout << 2 << endl;
- } if(color3 == color_Witness && floors3 == floors_Witness){
- cout << 3 << endl;
- }
- } else if ( color_Witness == "?"s && floors_Witness == -1 ){ // не ввел ни цвет ни этажность
- cout << 1 << endl;
- cout << 2 << endl;
- cout << 3 << endl;
- } if( color_Witness == "?"s || floors_Witness == -1 ){ // ввёл либо цвет либо этажность
- if (color1 == color_Witness || floors1 == floors_Witness){
- cout << 1 << endl;
- } if (color2 == color_Witness || floors2 == floors_Witness){
- cout << 2 << endl;
- } if (color3 == color_Witness || floors3 == floors_Witness){
- cout << 3 << endl;
- }
- }
- }
-
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string house1, house2, house3, house4;
- int num_flor1, num_flor2, num_flor3, num_flor4;
- cin >> house1 >> num_flor1 >> house2 >> num_flor2 >> house3 >> num_flor3 >> house4 >> num_flor4;
- if (((house1 == house4) && (num_flor1 == num_flor4)) || ((house1 == house4) && (num_flor4 == -1 )) || ((house4 == "?") && (num_flor1 == num_flor4)) || ((house4 == "?") && (num_flor4 == -1))) {
- cout << 1 <<endl;
- } if (((house2 == house4) && (num_flor2 == num_flor4)) || ((house2 == house4) && (num_flor4 == -1 )) || ((house4 == "?") && (num_flor2 == num_flor4)) || ((house4 == "?") && (num_flor4 == -1))) {
- cout << 2 <<endl;
- } if (((house3 == house4) && (num_flor3 == num_flor4)) || ((house3 == house4) && (num_flor4 == -1)) || ((house4 == "?") && (num_flor3 == num_flor4)) || ((house4 == "?") && (num_flor4 == -1))) {
- cout << 3 << endl;
- }
- return 0;
- // Считайте информацию о трёх домах, которые видит перед собой Марта,
- // а также показания очевидца.
- // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
- // по одному номеру в каждой строке
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- // Считайте информацию о трёх домах, которые видит перед собой Марта,
- // а также показания очевидца.
- // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
- // по одному номеру в каждой строке
- string first_color, second_color, third_color, say_color;
- int first_num, second_num, third_num, say_num;
- cin >> first_color >> first_num >> second_color >> second_num >> third_color >> third_num >> say_color >> say_num;
- if((first_color == say_color && first_num == say_num) || (say_color == "?"s && first_num == say_num) || (first_color == say_color && say_num == -1)){
- cout << 1 << endl;
- }
- if((second_color == say_color && second_num == say_num) || (say_color == "?"s && second_num == say_num) || (second_color == say_color && say_num == -1)){
- cout << 2 << endl;
- }
- if((third_color == say_color && third_num == say_num) || (say_color == "?"s && third_num == say_num) || (third_color == say_color && say_num == -1)){
- cout << 3 << endl;
- }
- if(say_color == "?"s && say_num == -1){
- cout << 1 << endl << 2 << endl << 3 << endl;
- }
- }
-
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <utility>
- using namespace std;
- int main()
- {
- string color;
- int number;
- vector<pair<string, int>> pairs;
- for (size_t i = 0; i < 4; ++i)
- {
- cin >> color >> number;
- pairs.emplace_back(color, number);
- }
- pair<string, int> last = pairs.back();
- pairs.pop_back();
- if (last.first == "?"s && last.second == -1)
- {
- for (int i = 1; i <= pairs.size(); ++i)
- {
- cout << i << endl;
- }
- return 0;
- }
- if (last.first != "?"s && last.second == -1)
- {
- for (int i = 0; i < pairs.size(); ++i)
- {
- if (pairs[i].first == last.first)
- {
- cout << i + 1 << endl;
- }
- }
- return 0;
- }
- if (last.first == "?"s && last.second != -1)
- {
- for (int i = 0; i < pairs.size(); ++i)
- {
- if (pairs[i].second == last.second)
- {
- cout << i + 1 << endl;
- }
- }
- return 0;
- }
- if (last.first != "?"s && last.second != -1)
- {
- for (int i = 0; i < pairs.size(); ++i)
- {
- if (pairs[i] == last)
- {
- cout << i + 1 << endl;
- }
- }
- }
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- string house_1_color, house_2_color, house_3_color, user_suggestion_house_color;
- int house_1_floor, house_2_floor, house_3_floor, user_suggestion_house_floor;
- // read input
- cin >> house_1_color >> house_1_floor >> house_2_color >> house_2_floor >> house_3_color >> house_3_floor >> user_suggestion_house_color >> user_suggestion_house_floor;
- // check each house against the information provided by the passerby
- if ((house_1_color == user_suggestion_house_color || user_suggestion_house_color == "?") && (house_1_floor == user_suggestion_house_floor || user_suggestion_house_floor == -1)) {
- cout << 1 << endl;
- }
- if ((house_2_color == user_suggestion_house_color || user_suggestion_house_color == "?") && (house_2_floor == user_suggestion_house_floor || user_suggestion_house_floor == -1)) {
- cout << 2 << endl;
- }
- if ((house_3_color == user_suggestion_house_color || user_suggestion_house_color == "?") && (house_3_floor == user_suggestion_house_floor || user_suggestion_house_floor == -1)) {
- cout << 3 << endl;
- }
- return 0;
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- // Считайте информацию о трёх домах, которые видит перед собой Марта,
- // а также показания очевидца.
- // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
- // по одному номеру в каждой строке
- string color1, color2, color3, colorx;
- int floors1, floors2, floors3, floorsx;
- cin >> color1 >> floors1 >> color2 >> floors2 >> color3 >> floors3 >> colorx >> floorsx;
- if ((colorx == color1 || colorx == "?"s) && (floorsx == floors1 || floorsx == -1)) {
- cout << 1 << endl;
- }
- if ((colorx == color2 || colorx == "?"s) && (floorsx == floors2 || floorsx == -1)) {
- cout << 2 << endl;
- }
- if ((colorx == color3 || colorx == "?"s) && (floorsx == floors3 || floorsx == -1)) {
- cout << 3 << endl;
- }
- }
-
- #include <iostream>
- using namespace std;
- int main() {
- // Считайте информацию о трёх домах, которые видит перед собой Марта,
- // а также показания очевидца.
- // Выведите номера тех домов (1, 2, 3) которые нужно посетить,
- // по одному номеру в каждой строке
- string c1, c2, c3, seen;
- int h1, h2, h3, seen_cat;
- cin >> c1 >> h1 >> c2 >> h2 >> c3 >> h3 >> seen >> seen_cat;
- if ((c1 == seen && h1 == seen_cat) || (seen == "?"s && seen_cat == h1) || (seen == c1 && seen_cat == -1)) {
- cout << 1 << endl;
- }
- if ((c2 == seen && h2 == seen_cat) || (seen == "?"s && seen_cat == h2) || (seen == c2 && seen_cat == -1)) {
- cout << 2 << endl;
- }
- if ((c3 == seen && h3 == seen_cat) || (seen == "?"s && seen_cat == h3) || (seen == c3 && seen_cat == -1)) {
- cout << 3 << endl;
- }
- else if (seen == "?"s && seen_cat == -1) {
- cout << 1 << endl
- << 2 << endl
- << 3 << endl;
- }
- }
Add Comment
Please, Sign In to add comment