#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> #include <cmath> using namespace std; char itlist[3] = {'W','L','T'}; int num_of_games_left = 0; int result; int fave_team; void checking(vector<int> team_to_score){ int f_score = team_to_score[fave_team]; bool flag = false; for(int i = 1; i < 5; i++){ if(i != fave_team && f_score <= team_to_score[i]){ flag = true; break; } } if(flag == false){ result++; } } void play(int gameindex, vector<pair<int,int>> games_left, vector<int> team_to_score){ if (gameindex == num_of_games_left){ //check, update result; checking(team_to_score); return; } //copy the map for(int i = 0; i < 3; i++){ int t1 = games_left[gameindex].first; int t2 = games_left[gameindex].second; if(itlist[i] == 'W'){ team_to_score[t1] += 3; play(gameindex+1, games_left, team_to_score); team_to_score[t1] -= 3; } else if(itlist[i] == 'L'){ team_to_score[t2] += 3; play(gameindex+1, games_left, team_to_score); team_to_score[t2] -= 3; } else{ team_to_score[t1] += 1; team_to_score[t2] += 1; play(gameindex+1, games_left, team_to_score); team_to_score[t1] -= 1; team_to_score[t2] -= 1; } //copy back team_to_score } } int main(){ vector<int> team_to_score(5, 0); cin >> fave_team; int num_of_games_played; cin >> num_of_games_played; vector<pair<int,int>> games_left; games_left.push_back(make_pair(1,2)); games_left.push_back(make_pair(1,3)); games_left.push_back(make_pair(1,4)); games_left.push_back(make_pair(2,3)); games_left.push_back(make_pair(2,4)); games_left.push_back(make_pair(3,4)); for (int x=0; x<num_of_games_played; x++){ int team1; cin >> team1; int team2; cin >> team2; int score1; cin >> score1; int score2; cin >> score2; if (score1 > score2){ team_to_score[team1] += 3; } else if (score1 < score2){ team_to_score[team2] += 3; } else{ team_to_score[team1] += 1; team_to_score[team2] += 1; } for(int i = 0; i < games_left.size(); i++){ if (make_pair(team1,team2) == games_left[i]){ games_left.erase(games_left.begin()+i); } } } num_of_games_left = 6-num_of_games_played; play(0, games_left, team_to_score); cout<<result<<endl;; return 0; }
top of page
Recent Posts
See All#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c,...
0
s1 = input() s2 = input() silly = '' silly_o = '' quiete = '-' i = 0 j = 0 while i < len(s1) and j < len(s2): if s1[i] != s2[j]: if...
0
#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int,...
0
bottom of page
Comentários