QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#143251#7079. Arraynot_yetWA 95ms26888kbC++142.8kb2023-08-20 23:35:012023-08-20 23:35:03

Judging History

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

  • [2023-08-20 23:35:03]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:26888kb
  • [2023-08-20 23:35:01]
  • 提交

answer

// 356807GC
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <set>
#include <unordered_map>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <tuple>
#include <stack>
#include <queue>
#include <cstdint>
#include <numeric>
#include <list>
using namespace std;

/* ----- type alias ----- */
using ll = long long;
template <typename T, typename U>
using umap = std::unordered_map<T, U>;
using vi  = vector<int>;
using vl  = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vii = vector<pii>;
using vll = vector<pll>;
using vvi = vector<vi>;
using vb  = vector<bool>;

/* ----- macros ----- */
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define MOD 1000000007ll
#define INF (1 << 30)
#define INF_L (1ll << 60)
#define optimize() std::ios_base::sync_with_stdio(false);\
                   cin.tie(nullptr); cout.tie(nullptr)
#define LEN(s) (int)(s).length()
#define SIZE(V) (int)(V).size()
#define DEC_MOD(N, DEC, MOD) (((N) - (DEC) + (MOD)) % (MOD))
#define INC_MOD(N, INC, MOD) (((N) + (INC)) % MOD)
#define FLOOR(N, M) (((N) - (M) + 1) / (M))
#define CEIL(N, M) (((N) + (M) - 1) / (M))
#define ROUND_F(N) (int)((double)N + 0.5)
#define PRINT(A, END) cerr << #A << ": " << boolalpha << A << END

/* ----- utility variables, arrays, vectors ----- */
int dr[] = { -1,  0, 0, 1 };
int dc[] = {  0, -1, 1, 0 };

const size_t N = 1000007ll;

vvi adj(N+1);
vb visited(N+1, false);

vector<ll> parent(10005, 1);
vector<ll> child(10005, 1);

ll find_parent(int c) {
    if (parent[c] == c) return parent[c];
    return find_parent(parent[c]);
}

void union_set(int a, int b) {
    parent[b] = a;
}

ll kill_all(vi &v) {
    if (v.size() == 1) return 0;
    vi t;
    t.push_back(v[0]);
    for (int i = 0; i < SIZE(v)-1; ++i) {
        if (v[i] < v[i+1]) t.push_back(v[i+1]);
    }
    return (t.size() != v.size() ? 1 + kill_all(t) : 0);
}

void solve() {
    int n;
    cin >> n;

    vi v(n);
    for (auto &i: v) cin >> i;

    ll ans = 0;
    for (int i = 1; i < n; ++i) {
        if (v[i] != v[i-1]) {
            int t = abs(v[i] - v[i-1]);
            if (i < n-1) t = min(t, abs(v[i] - v[i+1]));
            v[i] = t;
            ans = t;
            break;
        }
    }

    map<int, bool> d;
    vi dups(n+1, 0);
    for (int i = 0; i < n; ++i) {
        if (!d[v[i]]) {
            d[v[i]] = true;
            dups[i+1] = dups[i] + 1;
        } else {
            dups[i+1] = dups[i];
        }
    }

    for (int i = 0; i < n; ++i) ans += dups[i+1] * (i+1);
    cout << ans;
}

int main(void) {
    optimize();
    int t = 1;
    cin >> t;
    //int tc = 1;
    while (t--) {
        //cout << "Case " << tc++ << ": ";
        solve();
        cout << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 26888kb

input:

1
4
1 2 3 4

output:

22

result:

ok "22"

Test #2:

score: -100
Wrong Answer
time: 95ms
memory: 26616kb

input:

100000
10
873324878 873324878 873324878 873324878 891656676 891656676 615245360 873324878 873324878 873324878
10
560723194 560723194 797429144 797429144 560723194 797429144 819647695 560723194 797429144 560723194
10
750627649 746781323 756277046 756277046 750627649 750627649 756277046 750627649 9142...

output:

174
190
3846506
30845853
15624037
375905032
233
188681157
193
444977787
254
592982368
521401248
481173334
10605757
2462931
205488437
425364261
226805857
161
101
210
201
236556277
206
99903817
752410340
271169489
476007555
87735627
650387297
192462735
252219918
250
134274101
161
42785405
201
42692881...

result:

wrong answer 1st words differ - expected: '134', found: '174'