QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100476#5553. Alternative ArchitecturePetroTarnavskyi#WA 2ms3292kbC++171.3kb2023-04-26 15:21:052023-04-26 15:21:09

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-26 15:21:09]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3292kb
  • [2023-04-26 15:21:05]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3292kb

input:

6 11

output:


result:

wrong answer 1st lines differ - expected: '6', found: ''