QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#590636 | #9347. Competition in Swiss-system | kevinshan | Compile Error | / | / | C++23 | 4.3kb | 2024-09-26 09:15:28 | 2024-09-26 09:15:29 |
Judging History
answer
#pragma GCC optimize("Ofast,O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll __uint128_t
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second
#define THIRD frac(1,3)
#define ZERO frac{0,0}
struct frac {
ll num;
ll den;
frac(ll n, ll d) {
if(d == 0) num = 0, den = 0;
else {
ll g = gcd(n,d);
assert(g != 0);
num = n/g;
den = d/g;
}
}
bool is_zero() { return den == 0; }
bool is_less() { return den == 0 || num * 3 <= den; }
frac get_div(ll tot) {
ll g = gcd(num, tot);
if(g == 0) return ZERO;
assert(g != 0);
return {num/g, (tot/g)*den};
}
void display() {
if(is_less()) cout<<"1/3 ";
else cout<<num<<"/"<<den<<" ";
}
};
frac adding(frac a, frac b) {
if(a.is_zero()) return b;
if(b.is_zero()) return a;
if(a.is_less()) a = THIRD;
if(b.is_less()) b = THIRD;
// cout<<a.num<<"|"<<a.den<<"\n";
// cout<<b.num<<"|"<<b.den<<"\n";
ll new_num = a.num * b.den + b.num * a.den;
ll new_den = a.den * b.den;
ll g = gcd(new_num, new_den);
assert(g != 0);
return {new_num/g, new_den/g};
}
struct match{
int p1, p2, w1, w2, d;
int tot() { return w1 + w2 + d; }
};
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen("input.in", "r")) {
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
}
int t; cin>>t;
while(t--){
int n, M;
cin>>n>>M;
vector<vector<int>> opponents_played(n, vector<int>());
vector<ll> match_points(n);
vector<ll> game_points(n);
// tot_match_points = rounds * 3;
vector<ll> tot_game_points(n);
vector<int> ar(M+1);
for(int i=1; i<=M; i++) cin>>ar[i];
for(int rounds=1; rounds<=M; rounds++) {
ll tot_match_points = rounds;
vector<bool> played(n);
vector<match> matches;
for(int j=0; j<ar[rounds]; j++) {
match m = {0,0,0,0,0};
cin>>m.p1>>m.p2>>m.w1>>m.w2>>m.d;
m.p1--;
m.p2--;
matches.pb(m);
int winner = 0;
if(m.w1 > m.w2) winner = 1;
if(m.w1 < m.w2) winner = 2;
match_points[m.p1] += (winner == 1 ? 3 : 0) + (winner == 0 ? 1 : 0);
match_points[m.p2] += (winner == 2 ? 3 : 0) + (winner == 0 ? 1 : 0);
game_points[m.p1] += 3*m.w1 + m.d;
game_points[m.p2] += 3*m.w2 + m.d;
played[m.p1] = 1;
played[m.p2] = 1;
opponents_played[m.p1].pb(m.p2);
opponents_played[m.p2].pb(m.p1);
tot_game_points[m.p1] += m.tot();
tot_game_points[m.p2] += m.tot();
}
for(int j=0; j<n; j++) {
if(!played[j]){
tot_game_points[j] += 2;
match_points[j] += 3;
game_points[j] += 6;
}
}
cout<<"Round "<<rounds<<"\n";
vector<frac> MWP(n, ZERO);
vector<frac> GWP(n, ZERO);
for(int j=0; j<n; j++) {
GWP[j] = frac(game_points[j], 3*tot_game_points[j]);
MWP[j] = frac(match_points[j], tot_match_points*3);
}
for(int j=0; j<n; j++) {
cout<<match_points[j]<<" ";
// auto f1 = match_win_total[j].get_div(tot_matches_played[j]);
frac f1 = ZERO;
for(int i:opponents_played[j]) f1 = adding(f1, MWP[i]);
f1 = f1.get_div(opponents_played[j].size());
auto f2 = GWP[j];
frac f3 = ZERO;
for(int i:opponents_played[j]) f3 = adding(f3, GWP[i]);
f3 = f3.get_div(opponents_played[j].size());
// auto f3 = game_win_total[j].get_div(tot_matches_played[j]);
f1.display();
f2.display();
f3.display();
cout<<"\n";
}
}
}
}
Details
answer.code: In member function ‘void frac::display()’: answer.code:37:18: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘__int128 unsigned’) 37 | else cout<<num<<"/"<<den<<" "; | ~~~~^~~~~ | | | | | __int128 unsigned | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/13/bits/unique_ptr.h:42, from /usr/include/c++/13/memory:78, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56, from answer.code:3: /usr/include/c++/13/ostream:168:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 168 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:172:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 172 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:176:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 176 | operator<<(bool __n) | ^~~~~~~~ In file included from /usr/include/c++/13/ostream:880: /usr/include/c++/13/bits/ostream.tcc:96:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]’ 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:183:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 183 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/13/bits/ostream.tcc:110:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]’ 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:194:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 194 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/13/ostream:203:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 203 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:207:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 207 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:222:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 222 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/13/ostream:226:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 226 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/13/ostream:234:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 234 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/13/ostream:241:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(_Float16) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 241 | operator<<(_Float16 __f) | ^~~~~~~~ /usr/include/c++/13/ostream:250:7: note: candidate: ‘std::basic...