QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100476 | #5553. Alternative Architecture | PetroTarnavskyi# | WA | 2ms | 3292kb | C++17 | 1.3kb | 2023-04-26 15:21:05 | 2023-04-26 15:21:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
struct Fenwick
{
int n;
VI v;
void init(int nn)
{
n = nn;
v.resize(n);
}
void inc(int i, int x)
{
for (; i < n; i = (i | (i + 1)))
v[i] += x;
}
int sum(int i)
{
int s = 0;
for (; i >= 0; i = (i & (i + 1)) - 1)
s += v[i];
return s;
}
};
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
Fenwick f;
f.init(n);
int cnt = 0;
vector<bool> bl(n, 0);
FOR(i, 0, q)
{
char c;
cin >> c;
if (c == '?')
{
int a, b;
cin >> a >> b;
a--, b--;
if (a > b) swap(a, b);
int x = f.sum(b) - f.sum(a - 1);
if ((x == cnt || x == 0) && (!bl[a] && !bl[b]))
cout << "possible\n";
else
cout << "impossible\n";
}
else
{
int a;
cin >> a;
a--;
if (c == '+')
{
cnt--;
bl[a] = 0;
f.inc(a, -1);
}
else
{
bl[a] = 1;
cnt++;
f.inc(a, 1);
}
}
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3292kb
input:
6 11
output:
result:
wrong answer 1st lines differ - expected: '6', found: ''