QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#143304#7079. Arraynot_yetWA 127ms26840kbC++203.0kb2023-08-21 01:33:502023-08-21 01:33:54

Judging History

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

  • [2023-08-21 01:33:54]
  • 评测
  • 测评结果:WA
  • 用时:127ms
  • 内存:26840kb
  • [2023-08-21 01:33:50]
  • 提交

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 = INF_L;
    set<int> s(v.begin(), v.end());
    ll prev = *s.begin();
    auto it = s.begin();
    ++it;
    for ( ; it != s.end(); ++it) {
        /*PRINT(prev, ' ');*/
        /*PRINT(*it, '\n');*/
        ans = min(ans, abs(prev - *it));
        prev = *it;
    }

    for (int i = 1; i < n; ++i) {
        if (abs(v[i] - v[i-1]) == ans) {
            v[i] = v[i-1];
            break;
        }
    }

    map<int, bool> d;
    vi dups(n+1, 0);
    for (int i = 0; i < n; ++i) {
        /*PRINT(v[i], '\n');*/
        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';
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 26840kb

input:

1
4
1 2 3 4

output:

22

result:

ok "22"

Test #2:

score: -100
Wrong Answer
time: 127ms
memory: 26752kb

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:

18331927
22218658
3846452
30845799
15623983
375904992
4267066
5419907
718084
168663016
103315089
330102198
41806364
481173282
8415478
2462884
22524584
425364212
226805803
361599543
453462931
92021433
12124707
82681689
22276802
99903763
98735862
75844120
216327275
87735615
173436284
192462683
1240113...

result:

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