QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#511428#5449. 楼梯ewrilan#0 28ms5800kbC++206.8kb2024-08-09 21:06:362024-08-09 21:06:37

Judging History

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

  • [2024-08-09 21:06:37]
  • 评测
  • 测评结果:0
  • 用时:28ms
  • 内存:5800kb
  • [2024-08-09 21:06:36]
  • 提交

answer

//
#ifndef __SIZEOF_INT128__
  #define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
// #define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
    string name{""};
    time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
    duration<float, std::milli> dur;
    Timer() = default;
    Timer(string nm): name(nm) {}
    ~Timer() {
        end = high_resolution_clock::now(); dur= end - start;
        cout << "@" << name << "> " << dur.count() << " ms" << '\n';
    }
};
template <typename T = int> inline T in()
{
    static T x;
    std::cin >> x;
    return x;
}
std::string yn(bool b)
{
    if(b) return "YES\n";
    else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
    for(const auto& i : wek)out << i << ' ';
    return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
    out << '{'<<par.first<<", "<<par.second<<"}";
    return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
pair <ll, ll> odp(char c, ll a, ll b)
{
    static map <int, ll> ar;
    static stack <pair <int, int>> dd; 
    ar[0] = 0;
    switch(c)
    {
        case '+':
            ar[a] += b;
            dd.push({a, b});
            return {-2, -2};
        case 'R':
            rep(j, 0, a){
                auto [a, b] = dd.top(); dd.pop();
                if(a == -1)continue;
                ar[a] -= b;
                if(!ar[a])ar.erase(a);
            }
            return {-2, -2};
        case '-':
            while(sz(dd))dd.pop();
            ar[a-1] += b;
            while(b){
                if(ar.rbegin()->second > b){
                    ar.rbegin()->second -= b;
                    b = 0;
                }
                else{
                    b -= ar.rbegin()->second;
                    ar.erase(prev(ar.end()));
                }
            }
            return {-2, -2};
        case '?':
            dd.push({-1, -1});
            if(ar.rbegin()->first == 0)
                return {-1, -1};
            auto p(ar.rbegin()), k(ar.rbegin());
            ll s(1);
            ll px(p->second);
            while(next(k) != ar.rend()){
                while(p != k && s > a){
                    s -= p->first - next(p)->first;
                    s -= next(p)->second;
                    ++p;
                    px += p->second;
                }
                if(s <= a && a <= s + p->second-1)
                    return {k->first, px - (a-s)};
                if(s + p->second <= a && a < s + p->second-1 + k->first - next(k)->first )
                    return {k->first - (a - s - p->second+1), px - (p->second-1)};
                ++k;
                s += k->second;
                s += prev(k)->first - k->first;
            }
            return {-1, -1};
    }
}
#define wys
std::int32_t main()
{
#ifdef wys
    std::cout.tie(nullptr); //for luck
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(0);
    
    int m(in());
    if(1 || m <= 1000)
    {
        rep(i, 0, m){
            char c(in<char>());
            ll a(in<ll>()), b(-1);
            if(c == '+' || c == '-')cin >> b;
            auto [o1, o2] = odp(c, a, b);
            if(o1 != -2){
                if(o1 == -1)cout << "-1\n";
                else cout << o1 << ' ' << o2 << '\n';
            }
        }
        return 0;
    }
    
#else
    srand(in());
    int m(in()), n(in()), k(in());
    vector <int> ar(n);
    rep(i, 0, m){
        char c("+++-R????"[rand()%9]);
        int a, b;
        stack <pair <int, int>> dd;
xd:
        switch(c)
        {
            case '+':
                a = rand()%n;
                b = rand()%k+1;
                dd.push({a, b});
                odp(c, a+1, b);
                rep(i, 0, a+1)ar[i] += b;
                cout << c << ' ' << a+1 << ' ' << b << '\n';
                break;
            case '-':
                a = rand()%n;
                b = rand()%k+1;
                while(sz(dd))dd.pop();
                odp(c, a+1, b);
                rep(i, a, n)ar[i] = max(ar[i]-b, 0);
                cout << c << ' ' << a+1 << ' ' << b << '\n';
                break;
            case 'R':
                if(!sz(dd)){
                    c = '+';
                    goto xd;
                }
                a = rand()%sz(dd)+1;
                odp(c, a, -1);
                rep(i, 0, a){
                    auto [a, b] = dd.top(); dd.pop();
                    rep(i, 0, a+1)ar[i] -= b;
                }
                cout << c << ' ' << a << '\n';
                break;
            case '?':
                int mx(ar[0]);
                rep(i, 1, n)mx += !!ar[i];
                vector <int> mz;
                rep(i, 1, mx+1)if(mx%i == 0)mz.pb(i);
                if(!sz(mz)){
                    c = '-';
                    goto xd;
                }
                a = mz[rand() % sz(mz)];
                auto [x, y] = odp(c, a, -1);
                if(x > 0 && y > 0){
                    --x;
                    --y;
                    if(ar[x] <= y){
                        cout << c << ' ' << a << " ERROR: " << x << ',' << y << " DOESNT EXIST\n";
                        return 1;
                    }
                    int w(ar[x] - y);
                    rep(i, x+1, n)w += !!(ar[i] > y);
                    if(w != a){
                        cout << c << ' ' << a << " ERROR: " << x << ',' << y << " GIVES " << w << '\n';
                        return 2;
                    }
                }
                cout << c << ' ' << a << ' ' << "OK: " << x << ',' << y << '\n';
                break;
        }
        if(c != '?'){
            rep(i, 0, n){
                rep(j, 0, ar[i])cout << '#';
                cout << '\n';
            }
        }
    }
    return 0;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3796kb

input:

1000
- 1 999995
? 770771330
? 688406105220012703
? 466054413
? 1466199
? 940610359316496655
? 310504014100463831
? 765557590
? 419614901
? 830584303
? 85199513
? 768715778674812284
? 742663363105169125
? 859012516258231128
? 168409807482711289
? 842755243
? 618667253264707663
? 957265852
+ 1 1
+ 1 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 1
1 3
1 1
1 1
1 3
1 1
1 3
1 1
1 1
1 1
1 3
1 3
1 3
1 3
1 1
1 1
1 1
1 1
1 3
1 3
1 3
1 3
1 2
1 1
1 2
1 1
1 2
-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
1 1
1 2
1 2
1 2
1 1
1 2
1 2
1 1
1 2
1 1
1 1
1 2
1 1
1 1
1 1
1 1
1 1
1 2
1 1
1 2
1...

result:

wrong answer query 10: not a cell

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Wrong Answer

Test #111:

score: 0
Wrong Answer
time: 28ms
memory: 5800kb

input:

300000
? 308230551
? 154394919
? 77796824
? 523232316
? 601650936815206607
? 986805724
? 283169431815882827
? 781223930
? 785380179984309713
? 36818911074958611
? 452850684
? 392810692
? 812929344
? 9753139
? 236758865441063408
? 448106017
? 382652997142237763
? 667762111
? 201388730
? 433119061
? 6...

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
-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
...

result:

wrong output format Unexpected end of file - int64 expected

Subtask #7:

score: 0
Skipped

Dependency #1:

0%