結果
問題 |
No.322 Geometry Dash
|
ユーザー |
|
提出日時 | 2016-06-29 19:09:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
J_TLE
(最初)
|
実行時間 | - |
コード長 | 2,466 bytes |
コンパイル時間 | 1,576 ms |
コンパイル使用メモリ | 173,492 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 05:34:37 |
合計ジャッジ時間 | 10,258 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 1 WA * 26 |
コンパイルメッセージ
main.cpp: In member function 'Fraction& Fraction::operator+=(const Fraction&)': main.cpp:32:5: warning: no return statement in function returning non-void [-Wreturn-type] 31 | adjust(); +++ |+ return *this; 32 | } | ^ main.cpp: In member function 'Fraction& Fraction::operator*=(const Fraction&)': main.cpp:50:5: warning: no return statement in function returning non-void [-Wreturn-type] 49 | adjust(); +++ |+ return *this; 50 | } | ^
ソースコード
#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<<endl #define smax(x,y) (x)=max((x),(y)) #define smin(x,y) (x)=min((x),(y)) #define MEM(x,y) memset((x),(y),sizeof (x)) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; struct Fraction{ long long n, d; Fraction():n(0),d(1){ } Fraction(long long n_, long long d_ = 1):n(n_), d(d_){ adjust(); } bool operator<(const Fraction &x) const{ return n*x.d < x.n*d; } bool operator<=(const Fraction &x) const { return n*x.d<=x.n*d; } bool operator>(const Fraction &x) const{ return !(*this<=x); } bool operator>=(const Fraction &x) const{ return !(*this<x); } bool operator==(const Fraction &x) const{ return n*x.d==x.n*d; } bool operator!=(const Fraction &x) const{ return n*x.d!=x.n*d; } Fraction & operator+=(const Fraction &x){ n = x.d*n + d * x.n; d *= x.d; adjust(); } Fraction operator+(const Fraction &x) const{ Fraction res = *this; res += x; return res; } Fraction & operator-=(const Fraction &x){ return *this += Fraction(-x.n, x.d); } Fraction operator-(const Fraction &x) const{ Fraction res = *this; res -= x; return res; } Fraction & operator*=(const Fraction &x){ n *= x.n; d *= x.d; adjust(); } Fraction operator*(const Fraction &x) const{ Fraction res = *this; res *= x; return res; } Fraction operator/=(const Fraction &x){ return *this *= Fraction(x.d, x.n); } Fraction operator/(const Fraction &x) const{ Fraction res; res /= x; return res; } private: void adjust(){ if(n == 0)d = 1; if(d < 0)n = -n, d = -d; auto g = gcd(n, d); n /= g; d /= g; } long long gcd(long long a, long long b){ return b ? gcd(b, a%b) : a; } }; int main(){ int N; cin>>N; vector<pair<Fraction, int>> vf(N); rep(i, N)scanf("%lld%lld", &vf[i].first.n, &vf[i].first.d), vf[i].second = i + 1; sort(all(vf), greater<pair<Fraction, int>>()); rep(i, N)printf("%d%c", vf[i].second, i == N - 1 ? '\n' : ' '); }