結果

問題 No.396 クラス替え
ユーザー CodeCreater123
提出日時 2025-05-18 16:01:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 1,303 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 195,132 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2025-05-18 16:01:09
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 200010;
const int mod = 1e9 + 7;
vector<int> f[N];
int power(int a, int b, int c) {
    int ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % c;
        a = a * a % c, b >>= 1;
    } return ans;
}
int solve(string s, int mod) {
    int f[2] = {1, 0}, n = s.size();
    for (int i = 0; i < (n + 1) / 2; ++i) {
        int g[2] = {0, 0};
        for (int j = 0; j < 2; ++j) {
            int l = i ? 0 : 1, r = j ? 9 : (s[i] & 15);
            for (int k = l; k <= r; ++k) g[j || (k < r)] = (g[j || (k < r)] + f[j]) % mod;
        }
        f[0] = g[0], f[1] = g[1];
    }
    int ss = f[1];
    for (int i = 1; i < n; ++i) ss = (ss + power(10, (i - 1) / 2, mod) * 9 % mod) % mod;
    string nw; for (int i = 0; i < (n + 1) / 2; ++i) nw += s[i];
    for (int i = (n + 1) / 2; i < n; ++i) nw += s[n - i - 1]; ss += (nw <= s); return ss;
}
signed main() {
    cin.tie(0)->sync_with_stdio(false);
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int i1 = (x - 1) % (2 * m), i2 = (y - 1) % (2 * m);
    int x1 = 0, x2 = 0;
    if (i1 < m) x1 = i1 + 1;
    else x1 = m + m - 1 - i1 + 1;
    if (i2 < m) x2 = i2 + 1;
    else x2 = m + m - 1 - i2 + 1;
    cout << ((x1 == x2) ? "YES" : "NO") << '\n';
    return 0;
}
0