QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#318886#8139. Ayano and sequencesPetroTarnavskyiCompile Error//C++202.4kb2024-02-01 06:43:072024-02-01 06:43:07

Judging History

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

  • [2024-02-01 06:43:07]
  • 评测
  • [2024-02-01 06:43:07]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#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 SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;


const int N = 500'447;
ULL b[N];
const int T = 0;

struct Node
{
	ULL c, w, t;
	ULL p;
};

struct Segtree
{
	int n;
	vector<Node> t;
	
	void init(int _n)
	{
		n = 1;
		while (n < _n) n *= 2;
		t.resize(2 * n - 1);
	}
	
	Node combine(Node& a, Node& b)
	{
		if (a.t != b.t)
			return {-1, -1, -1, -1};
		return {a.c + b.c, a.w + b.w, a.t, -1};
	}
	
	void push(int v, int tl, int tr)
	{
		if (t[v].p == -1)
			return;
		if (t[v].t != -1)
		{
			int l = tr - tl;
			t[v].w += p * l * (T - t[v].t);
			t[v].c = p * l;
			t[v].t = T;
		}
		if (tl + 1 == tr)
			return;
		t[v * 2 + 1].p += t[v].p;
		t[v * 2 + 2].p += t[v].p;
		t[v].p == -1;
	}
	
	void upd(int v, int tl, int tr, int l, int r, int x)
	{
		push(v, tl, tr);
		if (l >= tr || tl >= r) return;
		if (l <= tl && tr <= r && t[v].t != -1)
		{
			t[v].p += x;
			return;
		}
		int tm = (tl + tr) / 2;
		upd(v * 2 + 1, tl, tm, l, r, x);
		upd(v * 2 + 2, tm, tr, l, r, x);
		t[v] = combine(t[v * 2 + 1], t[v * 2 + 2]);
	}
	
	void upd(int l, int r, int x)
	{
		upd(0, 0, n, l, r, x);
	}
	
	ULL query(int v, int tl, int tr, int l, int r, int time)
	{
		push(v, tl, tr);
		if (l >= tr || tl >= r) return 0;
		if (l <= tl && tr <= r && t[v].t != -1)
		{
			int l = tr - tl;
			return t[v].c * (T - time) - t[v].w;
		}
		int tm = (tl + tr) / 2;
		return query(v * 2 + 1, tl, tm, l, r, time) + 
			   query(v * 2 + 2, tm, tr, l, r, time); 
	}
	
	ULL query(int l, int r, int time)
	{
		return query(0, 0, n, l, r);
	}
	
	void reset(int v, int tl, int tr, int l, int r)
	{
		return;
	}
	
	void reset(int l, int r)
	{
		reset(0, 0, n, l, r);
	}
};


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, q;
	cin >> n >> q;
	VI a(n);
	set<PII> s;
	FOR (i, 0, n)
	{
		cin >> a[i];
		s.insert({i, 0});
	}
	s.insert({n, 0});
	
	Segtree st;
	st.init(n);
	FOR (i, 0, q)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			
		}
		
		T++;
	}
	
	return 0;
}

Details

answer.code: In member function ‘Node Segtree::combine(Node&, Node&)’:
answer.code:46:33: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULL’ {aka ‘long long unsigned int’} [-Wnarrowing]
   46 |                         return {-1, -1, -1, -1};
      |                                 ^~
answer.code:47:52: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ULL’ {aka ‘long long unsigned int’} [-Wnarrowing]
   47 |                 return {a.c + b.c, a.w + b.w, a.t, -1};
      |                                                    ^~
answer.code: In member function ‘void Segtree::push(int, int, int)’:
answer.code:57:35: error: ‘p’ was not declared in this scope
   57 |                         t[v].w += p * l * (T - t[v].t);
      |                                   ^
answer.code: In member function ‘ULL Segtree::query(int, int, int)’:
answer.code:104:29: error: no matching function for call to ‘Segtree::query(int, int, int&, int&, int&)’
  104 |                 return query(0, 0, n, l, r);
      |                        ~~~~~^~~~~~~~~~~~~~~
answer.code:88:13: note: candidate: ‘ULL Segtree::query(int, int, int, int, int, int)’
   88 |         ULL query(int v, int tl, int tr, int l, int r, int time)
      |             ^~~~~
answer.code:88:13: note:   candidate expects 6 arguments, 5 provided
answer.code:102:13: note: candidate: ‘ULL Segtree::query(int, int, int)’
  102 |         ULL query(int l, int r, int time)
      |             ^~~~~
answer.code:102:13: note:   candidate expects 3 arguments, 5 provided
answer.code: In function ‘int main()’:
answer.code:146:17: error: increment of read-only variable ‘T’
  146 |                 T++;
      |                 ^