結果
問題 | No.2622 Dam |
ユーザー | tipstar0125 |
提出日時 | 2024-02-09 22:07:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,373 bytes |
コンパイル時間 | 1,807 ms |
コンパイル使用メモリ | 202,996 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-28 15:21:06 |
合計ジャッジ時間 | 2,227 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 4 ms
6,816 KB |
testcase_04 | AC | 4 ms
6,820 KB |
testcase_05 | AC | 4 ms
6,816 KB |
ソースコード
using namespace std; #include <bits/stdc++.h> typedef long long ll; typedef long double ld; typedef string str; template <typename T> using v = vector<T>; template <typename T> using vv = vector<vector<T>>; template <typename T> using vvv = vector<vector<vector<T>>>; template <typename T> inline void errv(T &v) { for(auto x : v) cerr << x << " "; cerr << endl; } inline void errv(vector<bool> &v) { for(auto x : v) cerr << (x ? 1 : 0) << " "; cerr << endl; } template <typename T> inline void dbgn(T x) { cerr << x << endl; } template <typename T> inline void dbgn(vector<T> &v) { errv(v); } template <typename T> inline void dbgn(vector<vector<T>> &m) { for(auto &v : m) errv(v); } template <typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template <typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } template <typename T> inline T sum(vector<T> &a) { T ret{}; for(auto &i : a) ret += i; return ret; } template <typename T> inline T min(vector<T> &a) { T ret = a[0]; for(auto &i : a) chmin(ret, i); return ret; } template <typename T> inline T max(vector<T> &a) { T ret = a[0]; for(auto &i : a) chmax(ret, i); return ret; } template <long long mod> struct modint { modint(ll v = 0) : value(normalize(v)) { } ll val() const { return value; } void normalize() { value = normalize(value); } ll normalize(ll v) { if(v <= mod && v >= -mod) { if(v < 0) v += mod; return v; } if(v > 0 && v < 2 * mod) { v -= mod; return v; } if(v < 0 && v > -2 * mod) { v += 2 * mod; return v; } v %= mod; if(v < 0) v += mod; return v; } modint<mod> &operator=(ll v) { value = normalize(v); return *this; } bool operator==(const modint &o) const { return value == o.val(); } bool operator!=(const modint &o) const { return value != o.val(); } const modint &operator+() const { return *this; } const modint &operator-() const { return value ? mod - value : 0; } const modint operator+(const modint &o) const { return value + o.val(); } modint &operator+=(const modint &o) { value += o.val(); if(value >= mod) value -= mod; return *this; } const modint operator-(const modint &o) const { return value - o.val(); } modint &operator-=(const modint &o) { value -= o.val(); if(value < 0) value += mod; return *this; } const modint operator*(const modint &o) const { return (value * o.val()) % mod; } modint &operator*=(const modint &o) { value *= o.val(); value %= mod; return *this; } const modint operator/(const modint &o) const { return operator*(o.inv()); } modint &operator/=(const modint &o) { return operator*=(o.inv()); } const modint pow(ll n) const { modint ans = 1, x(value); while(n > 0) { if(n & 1) ans *= x; x *= x; n >>= 1; } return ans; } const modint inv() const { ll a = value, b = mod, u = 1, v = 0; while(b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } return u; } friend ostream &operator<<(ostream &os, const modint &x) { return os << x.val(); } template <typename T> friend modint operator+(T t, const modint &o) { return o + t; } template <typename T> friend modint operator-(T t, const modint &o) { return -o + t; } template <typename T> friend modint operator*(T t, const modint &o) { return o * t; } template <typename T> friend modint operator/(T t, const modint &o) { return o.inv() * t; } private: ll value; }; #define d(x) dbgn(x); #define rep(i, c, n) for(int i = c; i < n; ++i) #define repa(i, a) for(auto i : a) #define so(v) sort(v.begin(), v.end()) #define rso(v) sort(v.rbegin(), v.rend()) using P = pair<ll, int>; using Dijkstra = priority_queue<P, vector<P>, greater<P>>; // using mint = modint<1000000007>; using mint = modint<998244353>; const ll INF = 1LL << 60; const ll MOD = 998244353; // const ll MOD = 1000000007; int dx[8] = {0, 1, 0, -1, -1, -1, 1, 1}; int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1}; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while(t--) { ll v, x, fo, fi, q, r; cin >> v >> x >> fo >> fi >> q >> r; if(x + (fi - fo) * r >= v) { cout << "Overflow" << endl; continue; } if(fo >= fi) { cout << "Zero" << endl; continue; } ll a = (fi - fo) * r; ll b = fo * (q - r); if(a > b) { cout << "Overflow" << endl; } else if(a < b) { cout << "Zero" << endl; } else { cout << "Safe" << endl; } } }