QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#426082#7615. Sequence Foldingreal_sigma_team#WA 1763ms222608kbC++201.5kb2024-05-30 20:54:322024-05-30 20:54:33

Judging History

你现在查看的是最新测评结果

  • [2024-05-30 20:54:33]
  • 评测
  • 测评结果:WA
  • 用时:1763ms
  • 内存:222608kb
  • [2024-05-30 20:54:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll = long long;


#define int long long

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    ll n;
    int m;
    cin >> n >> m;
    map<ll, int> cost, val;
    vector<ll> pts;
    for (int i = 0; i < m; ++i) {
        ll x;
        cin >> x;
        cost[x] = 1;
        val[x] = 1;
        pts.push_back(x);
    }
    ll ans = 0;
    while (n != 1) {
        for (auto& x : pts) {
            x = min(x, n + 1 - x);
        }
        sort(pts.begin(), pts.end());
        pts.resize(unique(pts.begin(), pts.end()) - pts.begin());
//        cout << n << ' ' << ans << endl;
//        for (auto x : pts) cout << x << ' ';
//        cout << endl;
        for (auto x : pts) {
            ll y = n + 1 - x;
            if (!val.count(x) || !cost.count(x)) {
                val[x] = 0;
                cost[x] = 1;
            }
            if (!val.count(y) || !cost.count(y)) {
                val[y] = 0;
                cost[y] = 1;
            }
//            cerr << n << ' ' << x << ' ' << y << ' ' << val[x] << ' ' << cost[x] << ' ' << val[y] << ' ' << cost[y] << endl;
            if (val[x] == val[y]) {
                cost[x] += cost[y];
            } else {
                if (cost[y] < cost[x]) swap(cost[x], cost[y]), swap(val[x], val[y]);
                ans += cost[x];
                val[x] = val[y];
                cost[x] = cost[y] - cost[x];
            }
        }
        n /= 2;
    }
    cout << ans;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3500kb

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 1763ms
memory: 222608kb

input:

17179869184 100000
138476 774165 993977 1152277 1236393 1244970 1534017 1693701 1763926 1778781 1842066 1874644 1885666 2120429 2485344 2977941 3158255 3340476 3504862 4000117 4066652 4197639 4338723 4389163 4576965 4761601 5097091 5175412 5295902 5810551 5855982 6001770 6111262 6163309 6351547 6582...

output:

100000

result:

wrong answer 1st lines differ - expected: '99999', found: '100000'