답안 #1028865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028865 2024-07-20T09:37:00 Z underwaterkillerwhale 송금 (JOI19_remittance) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#define se              second
#define fs              first
#define mp              make_pair
#define pb              push_back
#define ll              long long
#define ii              pair<ll,ll>
#define ld              long double
#define SZ(v)           (int)v.size()
#define ALL(v)          v.begin(), v.end()
#define bit(msk, i)     ((msk >> i) & 1)
#define iter(id, v)     for(auto id : v)
#define rep(i,m,n)      for(int i=(m); i<=(n); i++)
#define reb(i,m,n)      for(int i=(m); i>=(n); i--)
using namespace std;

mt19937_64 rd(chrono :: steady_clock :: now().time_since_epoch().count());
ll Rand(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rd); }

const int N = 2e5 + 7;
const int Mod = 1e9 + 7;
const int szBL = 320;
const int INF = 1e9;
const int BASE = 1337;

int n;
pair<int,int> a[N];

void solution () {
    cin >> n;
//    n = 1e5;
//    rep (i, 1, n) a[i].fs = Rand(1, 1e5), a[i].se = Rand(1, 1e5);
    rep (i, 1, n) cin >> a[i].fs >> a[i].se;
    while (1) {
        rep (i, 1, n) {
            if (a[i].fs > a[i].se + 1) {
                int pos = i;
                while (a[pos].fs > a[pos].se + 1) {
                    int nxt = 1 + pos % n;
//                    cout << pos <<": "<<a[pos].fs<<"->"<<a[pos].fs -(a[pos].fs - a[pos].se) / 2 * 2 <<"\n";
                    a[nxt].fs += (a[pos].fs - a[pos].se) / 2;
                    a[pos].fs -= (a[pos].fs - a[pos].se) / 2 * 2;
                    pos = nxt;
                }
            }
//            rep (j, 1, n) cout << a[j].fs<< " "; cout<<"\n";
        }
        int ok = 1;
        rep (i, 1, n) if (a[i].fs > a[i].se + 1) {
            ok = 0;
        }
        if (ok) break;
    }
    int edcase = 1;
    rep (i, 1, n) {
        if (a[i].fs != a[i].se + 1) edcase = 0;
    }
    if (edcase  ) {
        rep (i, 1, n) if (a[i].se > 0) {
            cout <<"Yes\n";
            return;
        }
        cout <<"No\n";
        return;
    }
    rep (i, 1, n) if (a[i].fs != a[i].se) {
    cout <<"No\n"; return; }
    cout <<"Yes\n";
}

#define file(name) freopen(name".inp", "r", stdin); \
freopen(name".out", "w", stdout);

int main () {
    file("c");
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll num_Test = 1;
//    cin >> num_Test;
    while(num_Test--)
        solution();
}
/*
nếu mình nghĩ sẽ thay đổi định nghĩa, kiểu dữ liệu của hàm hay mảng j thì mình phải nghĩ xem nó sẽ ảnh hưởng đến các phần nào
0 0
1 0
0 0
*/

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:71:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 | #define file(name) freopen(name".inp", "r", stdin); \
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:75:5: note: in expansion of macro 'file'
   75 |     file("c");
      |     ^~~~
remittance.cpp:72:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 | freopen(name".out", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:75:5: note: in expansion of macro 'file'
   75 |     file("c");
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -