QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#450774#5555. Chaotic ConstructionEbiarat#WA 28ms3708kbC++202.2kb2024-06-22 17:53:062024-06-22 17:53:07

Judging History

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

  • [2024-06-22 17:53:07]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:3708kb
  • [2024-06-22 17:53:06]
  • 提交

answer

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <sstream>
#include <ctime>
#include <iterator>
#include <string.h>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <fstream>
#include <assert.h>
#include <numeric>
#include <complex>
#include <random>
#include <utility>



#define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define PB push_back
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define VI vector<int>
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VL vector<long long >
#define FILL(a, value) memset(a, value, sizeof(a))
const int nax = 2 * (int)1e5 + 147;
 
using namespace std;
 
const int MOD = 998244353;
const int INF = 1e9 +47 ;
const long long LINF = (long long)1e18 + 4747;
 
typedef long long LL;
const double EPS=1e-6;

int main() {
    int n, q;
        cin >> n >> q;
        set<int >s ;
        FOR (i, 0, q)
        {
            char c;
            int a, b;
            cin >> c >> a;
            if (c == '+')
                s.erase(a);
            else if (c == '-')
                s.insert(a);
            else
            {
                cin >> b;
                if (SZ(s) < 2)
                {
                    cout << "possible\n";
            continue;
                }
                if (a > b)
                    swap(a, b);
                auto it1 = s.lower_bound(a);
                bool check1 = (*it1 >= a && *it1 <= b);
                bool check2 = false;
                auto it2 = s.lower_bound(b);
                if(it2!=s.end())check2 = true;
                if(*s.begin() <= a )check2 = true;
                if (check1 && check2 )
                    cout << "impossible\n";
                else
                {
                    cout << "possible\n";
                }
            }
        }

        return 0;

    
    
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10 12
? 1 5
- 2
- 8
? 9 2
? 9 8
? 9 7
? 6 7
? 3 7
? 1 9
? 9 1
+ 8
? 10 3

output:

possible
impossible
impossible
impossible
possible
possible
possible
possible
possible

result:

ok 9 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3392kb

input:

20 20
? 17 4
- 11
+ 11
? 16 1
- 8
- 13
? 18 12
? 17 11
? 9 16
+ 8
? 18 4
? 8 4
- 20
- 14
? 7 12
? 19 20
? 6 10
+ 13
? 5 11
+ 20

output:

possible
possible
impossible
impossible
impossible
possible
possible
possible
impossible
possible
possible

result:

ok 11 lines

Test #3:

score: -100
Wrong Answer
time: 28ms
memory: 3544kb

input:

10 100000
- 10
? 6 4
? 4 10
? 8 7
? 9 3
+ 10
? 1 9
- 10
+ 10
? 5 10
? 4 9
- 1
? 2 9
- 4
- 6
- 5
+ 1
? 7 4
? 1 5
- 2
+ 4
? 7 3
+ 2
- 7
+ 5
? 4 8
- 5
- 9
- 2
? 6 8
- 4
+ 7
- 8
+ 8
? 8 5
+ 2
? 2 4
+ 9
+ 4
? 6 4
? 4 6
+ 6
- 1
? 1 7
? 6 5
+ 1
- 4
? 2 1
? 7 10
? 7 9
+ 4
+ 5
? 8 4
- 6
? 7 2
+ 6
- 7
- 4
- 1...

output:

possible
possible
possible
possible
possible
possible
possible
possible
impossible
impossible
impossible
possible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
possible
possible
possible
possible
possible
possible
impossible
possible
possible
possible
impossible
possib...

result:

wrong answer 2nd lines differ - expected: 'impossible', found: 'possible'