QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350915#7063. Space StationRong7Compile Error//C++143.2kb2024-03-11 09:49:552024-03-11 09:49:56

Judging History

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

  • [2024-03-11 09:49:56]
  • 评测
  • [2024-03-11 09:49:55]
  • 提交

answer

// Not afraid to dark.

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

namespace io {
    int read_pos, read_dt; char read_char;
    inline int read (int &p = read_pos){
        p = 0, read_dt = 1; read_char = getchar ();
        while (! isdigit (read_char)){
            if (read_char == '-')
                read_dt = - 1;
            read_char = getchar ();
        }
        while (isdigit (read_char)){
            p = (p << 1) + (p << 3) + read_char - 48;
            read_char = getchar ();
        }
        return p = p * read_dt;
    }
    int write_sta[65], write_top;
    inline void write (int x){
        if (x < 0)
            putchar ('-'), x = - x;
        write_top = 0;
        do
            write_sta[write_top ++] = x % 10, x /= 10;
        while (x);
        while (write_top)
            putchar (write_sta[-- write_top] + 48);
    }
    int llen;
    inline int get_string (char c[], int &len = llen){
        len = 0;
        read_char = getchar ();
        while (read_char == ' ' || read_char == '\n' || read_char == '\r')
            read_char = getchar ();
        while (read_char != ' ' && read_char != '\n' && read_char != '\r'){
            c[++ len] = read_char;
            read_char = getchar ();
        }
        return len;
    }
}

const int N = 1e5, V = 50, mod = 1e9 + 7, sed = 23;
int n, ia, ct[V + 5], ans, jc[N + 5], inv[N + 5], inj[N + 5], sum;

inline unsigned long long Upload (vector < int > a){
    unsigned long long res = 0;
    for (int i = 1;i <= V;++ i)
        res = res * sed + a[i];
    return res;
}

map < unsigned long long , int > mp[V + 5];
unordered_map < unsigned long long , vector < int > > ifm;

signed main (){
    io::read (n), io::read (ia);
    sum += ia;
    for (int i = 1, a;i <= n;++ i){
        ++ ct[io::read (a)];
        sum += a;
    }
    inv[1] = jc[0] = jc[1] = inj[0] = inj[1] = 1;
    for (int i = 2;i <= n;++ i){
        inv[i] = 1ll * inv[i - mod % i] * (mod / i + 1) % mod;
        inj[i] = 1ll * inj[i - 1] * inv[i] % mod;
        jc[i] = 1ll * jc[i - 1] * i % mod;
    }
    mp[ia][0ull] = 1;
    ifm[0ull] = vector < int > (51, 0);
    int sz = 1;
    for (int i = ia;i < V;++ i){
        sz += mp[i].size ();
        for (auto j : mp[i]){
            vector < int > a = ifm[j.first];
            for (int k = 1;k <= i;++ k)
                if (ct[k] > a[k]){
                    ++ a[k];
                    unsigned long long xx = Upload (a);
                    if (! ifm.count (xx))
                        ifm[xx] = a;
                    (mp[min (V, i + k)][xx] += 1ll * j.second * (ct[k] - a[k] + 1) % mod) %= mod;
                    -- a[k];
                }
        }
    }
    if (ia == 7)
        puts ("here");
    if (sum >= V)
        for (auto i : mp[V]){
            vector < int > a = ifm[i.first];
            int cnt = n - ct[0];
            for (int j = 1;j <= V;++ j)
                cnt -= a[i];
            (ans += 1ll * i.second * jc[cnt] % mod) %= mod;
        }
    else
        for (auto i : mp[sum])
            (ans += i.second) %= mod;
    io::write (1ll * ans * jc[n] % mod * inj[n - ct[0]] % mod), puts ("");
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:97:25: error: no match for ‘operator[]’ (operand types are ‘std::vector<int>’ and ‘std::pair<const long long unsigned int, int>’)
   97 |                 cnt -= a[i];
      |                         ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/queue:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from answer.code:3:
/usr/include/c++/13/bits/stl_vector.h:1123:7: note: candidate: ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]’
 1123 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1123:28: note:   no known conversion for argument 1 from ‘std::pair<const long long unsigned int, int>’ to ‘std::vector<int>::size_type’ {aka ‘long unsigned int’}
 1123 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1142:7: note: candidate: ‘std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]’
 1142 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1142:28: note:   no known conversion for argument 1 from ‘std::pair<const long long unsigned int, int>’ to ‘std::vector<int>::size_type’ {aka ‘long unsigned int’}
 1142 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~