QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#461597#6876. Out of ControlmdubaWA 233ms147804kbC++209.5kb2024-07-02 20:40:582024-07-02 20:40:58

Judging History

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

  • [2024-07-02 20:40:58]
  • 评测
  • 测评结果:WA
  • 用时:233ms
  • 内存:147804kb
  • [2024-07-02 20:40:58]
  • 提交

answer

//#pragma comment(linker, "/stack:20000000")
//#pragma GCC optimize("Ofast,O3,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx2,bmi,bmi2,popcnt,lzcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define se second
#define fi first
#define ld long double
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define ull unsigned long long
#define y1 y12313312312
#define vd vasvsadasdasfdasf
#define endl '\n'
#define gcd __gcd
#define b_p __builtin_popcountll
#define next nqweqweeqeqe
#define prev ppawfawfpfaw
#define pii pair < int, int >
#define pdd pair < double, double >
#define vi vector < int >
#define vpii vector < pii >
#define vpdd vector < pdd >
#define si set < int >
#define spii set < pii >
#define mii map < int, int >
#define umii unordered_map < int, int >
#define msi multiset < int >
#define qi queue < int >
#define qpii queue < pii >
#define mci map < char, int >
#define mdi map < double, int >
#define all(x) x.begin(), x.end()
#define mems(x, y) memset(x, y, sizeof x)
#define srt(x, y) sort(x + 1, x + y + 1)
#define rvs(x, y) reverse(x + 1, x + y + 1)
#define FOR(i, x, y) for (int i = x; i <= y; i++)
#define FOR1(i, x, y, z) for(int i = x; i <= y; i += z)
#define ROF(i, x, y) for (int i = x; i >= y; i--)
#define ROF1(i, x, y, z) for (int i = x; i >= y; i -= z)
#define uniq(x); sort(all(x)); x.resize(unique(all(x)) - x.begin());
#define mid ((tl + tr) >> 1)
#define LS v + v, tl, mid
#define RS v + v + 1, mid + 1, tr
#define int ll

using namespace std;
using namespace __gnu_pbds;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> bool emin(T& a, const U& b) { return b < a ? a = b, 1 : 0; } // set a = min(a,b)
template <class T, class U> bool emax(T& a, const U& b) { return a < b ? a = b, 1 : 0; } // set a = max(a,b)
template <class T, class U> void erase(T& t, const U& u) { // don't erase
    auto it = t.find(u); //assert(it != end(t));
    if (it != t.end()) t.erase(it);
}

inline namespace FileIO {
	void setIn(string s)  { freopen(s.c_str(),"r",stdin); }
	void setOut(string s) { freopen(s.c_str(),"w",stdout); }
	void setIO(string s = "") {
		//cin.tie(0)->sync_with_stdio(0); // unsync C / C++ I/O streams
		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		// cin.exceptions(cin.failbit);
		// throws exception when do smth illegal
		// ex. try to read letter into int
		if (s.ss) setIn(s+".in"), setOut(s+".out"); // for old USACO
	}
}

int MOD = 1e9 + 7;
#ifndef int
struct Mint
{
    private:
        int normal(int x) { if (x >= MOD) x -= MOD; if (x < 0) x += MOD; return x;}
        int power(int x, int y) { int res = 1; for (;y;y >>= 1, x = (x * x) % MOD) if (y & 1) res = (res * x) % MOD; return res;}
    public:

        int x;
        Mint():x(0){}
        Mint(int y):x(normal(y)){}
        Mint operator -()const {return Mint(MOD - x);}
        Mint operator +(const Mint y) {return Mint(x + y.x);}
        Mint operator -(const Mint y) {return Mint(x - y.x);}
        Mint operator *(const Mint y) {return Mint(int((ll)x * y.x % MOD));}
        Mint operator *(const int y) {return Mint(int((ll)x * y % MOD));}
        Mint operator /(const Mint y) {return Mint(int((ll)x * power(y.x, MOD - 2) % MOD));}
        Mint &operator =(const Mint y) {x = normal(y.x); return *this;}
        Mint &operator +=(const Mint y) {x = normal(x + y.x); return *this;}
        Mint &operator -=(const Mint y) {x = normal(x - y.x); return *this;}
        Mint &operator *=(const Mint y) {x = int((ll)x * y.x % MOD); return *this;}
        Mint &operator *=(const int y) {x = int((ll)x * y % MOD); return *this;}
        Mint &operator /=(const Mint y) {x = int((ll)x * power(y.x, MOD - 2) % MOD); return *this;}
        bool operator ==(const int y) {return x == y;}
};
ostream& operator << (ostream& out, const Mint& x){ out << x.x; return out;}
#endif // int
template < typename T, typename TT > ostream& operator << (ostream& out, const pair < T, TT>& p) {out << p.fi << " " << p.se; return out;}
template < typename T, typename TT > pair < T, TT > operator + (const pair < T, TT >& p1, const pair < T, TT >& p2) {return make_pair(p1.fi + p2.fi, p1.se + p2.se);}
template < typename T, typename TT > pair < T, TT > operator += (pair < T, TT >& p1, const pair < T, TT>& p2) {p1.fi += p2.fi; p1.se += p2.se; return p1;}

int bp (int x, int y)
{
    ll res = 1;
    for (; y; y >>= 1, x = (x * x))
        if (y & 1) res = (res * x);
    return res;
}
ll bpm(ll x, ll y, ll md = MOD)
{
    ll res = 1;
    for (; y; y >>= 1, x = (x * x) % md)
        if (y & 1) res = (res * x) % md;
    return res;
}
#ifdef int
inline void normal(ll &x, int md = MOD)
{
    if (x < md && x >= 0) return;
    x %= md;
    if (x < 0) x += md;
}
inline int MUL(ll x, ll y, int md = MOD)
{
    normal(x, md); normal(y, md);
    return (x * y) % md;
}
inline int SQ(ll x, int md = MOD)
{
    normal(x, md);
    return MUL(x, x, md);
}
inline int ADD(int x, int y, int md = MOD)
{
    normal(x, md); normal(y, md);
    return (x + y >= md ? x + y - md : x + y);
}
inline int SUB(int x, int y, int md = MOD)
{
    normal(x, md); normal(y, md);
    x -= y;
    if (x < 0) x += md;
    return x;
}
inline int DIV(ll x, ll y, int md = MOD)
{
    normal(x, md); normal(y, md);
    y = bpm(y, md - 2, md);
    return MUL(x, y, md);
}
#endif

bool is_prime(int x)
{
    if (x <= 1) return 0;
    for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0;
    return 1;
}

inline int cd(char c){return c - '0';}
inline char cc(int x){return x + '0';}
inline char cb(int x){return x + 'A';}
inline int cn(char c){return c - 'A';}
inline int diff(int x, int y){return abs(x - y);}
inline void abandon(){cout << "NO";exit(0);}
inline int rng(int l, int r){return (rnd() % (r - l + 1) + l);}
inline int pw2(int i){return (1 << i);}
inline bool bit(int mask, int i){return ((mask >> i) & 1);}
inline int lcm(int x, int y) {return (x / gcd(x, y)) * y;}
inline int sign(int x) {return (x < 0 ? -1 : !!x);}
inline void coutmask(int mask, int sz) {FOR (i, 0, sz - 1) cout << bit(mask, i);}

const ll INF = 1e15 + 7;
const int N = 3e3 + 40, T = 4 * N, logN = (int)log2(N) + 2, Nlog = N * logN * 2, basic = 41/*379999*/, inf = 1e9 + 7, Mod = 998244353, /*NWSE or ULDR*/sx[4] = {-1, 0, 1, 0}, sy[4] = {0, -1, 0, 1}, mod = 1e9 + 3;
const int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dy[8] = {1, 0, -1, 1, -1, 1, 0, -1}, sqN = (int)sqrt(N), BL = 316, BL2 = 1000;
const double eps = 1e-12, pi = acos(-1);

ll rll(ll r=numeric_limits<ll>::max(), ll l=0){ /*random long long*/ static mt19937_64 rng(1); return uniform_int_distribution<ll>(l, r)(rng); }


int n, m, r, l, e, id, mx = -inf, mn = inf, w, timer, tst, delta = 2e8 + 1;

si S;
umii M;
int a[N], b[N];
int d[N][N], d1[N][N];
int ans[N];
int ans2[N];

int f;

void naive(){
    for(ll i = 1; i <= n; i++){
        set<vector<int>> pos;
        vector<int> cur(a+1, a+n+1);
        sort(all(cur));
        do{
            vector<int> ne(cur.begin(), cur.begin()+i);
            for(ll j = 1; j < ne.size(); j++) ne[j] = max(ne[j], ne[j-1]);
            pos.insert(ne);
        }while(next_permutation(all(cur)));
        /*
        for(auto i : pos){
            for(auto j : i) cout << j << ' ';
            cout << '\n';
        }
        cout << "ANS ";*/
        ans[i] = pos.size();
    }
}



void solve()
{
    ll x = 0, y = 0, z = 0;

    cin >> n;
    S.clear();
    FOR (i, 1, n)
    {
        cin >> a[i];
        S.ins(a[i]);
    }

    //naive();

    M.clear();
    w = 0;
    for (auto i : S)
    {
        M[i] = ++w;
    }
    srt(a, n);
    e = 0;
    FOR (i, 1, n)
    {
        a[i] = M[a[i]];
        e++;
        b[a[i]] = e;
    }

    FOR (i, 1, n)
    {
        FOR (j, 1, w) d[i][j] = d1[i][j] = 0;
    }
    FOR (i, 1, w)
    {
        d[1][i] = 1;
        d1[1][i] = i;
    }
    ans2[1] = w;
    cout << w << "\n";
    FOR (i, 2, n)
    {
        FOR (j, 1, w)
        {
            if (b[j] > i - 1) (d[i][j] += d[i - 1][j]) %= inf;
            (d[i][j] += d1[i - 1][j - 1]) %= inf;
            //FOR (k, 1, j - 1) d[i][j] += d[i - 1][k];
            //d[i + 1][j] += d[i][j] * (b[j] > i);
            //FOR (k, j + 1, id) d[i + 1][k] += d[i][j];
        }
        FOR (j, 1, w) d1[i][j] = (d1[i][j - 1] + d[i][j]) % inf;
        cout << d1[i][w] << "\n";
        ans2[i] = d1[i][w];
    }
    cout << endl;
}

void gen()
{
    n = 10;
    for(ll i = 1; i <= n; i++) a[i] = rll(n)*n;
    naive();
    solve();
    for(ll i = 1; i <= n; i++){
        if (ans[i] != ans2[i]){
            FOR (j, 1, n) cout << a[j] << " ";
            cout << endl;
            FOR (j, 1, n) cout << ans[j] << " ";
            cout << endl;
            FOR (j, 1, n) cout << ans2[j] << " ";
            cout << endl;

            cerr << "ERROR";
            exit(1);
        }
    }
}

signed main()
{
    int x, y, z;
    //setprecision(9);
    #ifdef LOCAL
    setIn("input.txt");
    setOut("output.txt");
    #else
    setIO();
    #endif
    //while (1) gen();
    int _ = 1;
    cin >> _;
    for (int i = 1; i <= _; ++i)
    {
        //cout << "Case " << i << ": ";
        solve();
        //cout << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 233ms
memory: 147804kb

input:

63
54
205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 205975085 2059...

output:

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

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29

3
6
10
15
21
28
36
45
55
66
78
91
10...

result:

wrong answer 55th lines differ - expected: '2', found: ''