QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#64464#4428. FenceSa3tElSefr#WA 742ms46032kbC++232.4kb2022-11-24 20:50:312022-11-24 20:50:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-24 20:50:32]
  • 评测
  • 测评结果:WA
  • 用时:742ms
  • 内存:46032kb
  • [2022-11-24 20:50:31]
  • 提交

answer

/// Brrrr Brrrr
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

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

#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x,y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;

const int N = 1e6+5, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-7;

const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};

int sum[N];
int n, a[N];

void doWork() {

    cin >> n;

    int mx = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    set<int> st;
    f(i,0,n+2) st.insert(i);
    vector<vector<int>> pos(mx + 1);
    sum[n + 1] = sum[n + 2] = 0;
    for(int i = n; i >= 1; --i) {
        sum[i] = sum[i + 2] + a[i];
        pos[a[i]].pb(i);
    }

    for(int b = 1; b <= mx; b++) {
        bool parity = 0;
        int ans = 0;
        for(auto it = st.begin(); *it <= n; it++) {
            int nxt = *next(it);
            if(parity == 0) {
                if(nxt%2!=*it%2) {
                    ans += sum[*it+1]-sum[nxt];
                }   else {
                    ans += sum[*it+1]-sum[nxt+1];
                    parity ^= 1;
                }
            }   else {
                if(nxt%2!=*it%2) {
                    ans += sum[*it+2]-sum[nxt+1];
                }   else {
                    ans += sum[*it+2]-sum[nxt];
                    parity ^= 1;
                }
            }
            int cnt = a[nxt] / b, mod = a[nxt] % b;
            ans += b * ((cnt + !parity) / 2);
            parity ^= (cnt&1);
            if(mod) {
                ans += !parity * mod;
                parity ^= 1;
            }
         }
        for(auto x : pos[b])st.erase(x);
        cout << ans << '\n';
    }


}
int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE

    int t = 1;
    cin >> t;
    while (t--) {
        doWork();
    }
    return 0;
}

///Look at my code ya codeomk



詳細信息

Test #1:

score: 0
Wrong Answer
time: 742ms
memory: 46032kb

input:

5
333834
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

500000
500000
499995
499987
500000
500032
499996
499987
500032
500000
499994
499998
499981
499996
500080
500090
500077
500032
499980
499915
500035
499941
500055
499923
500000
499980
499935
500042
500174
499905
500002
499998
500218
499899
499965
500010
500144
500242
499839
499915
499987
500010
500122...

result:

wrong answer 500001st lines differ - expected: '500000', found: '500001'