QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#406336#8229. 栈c#Compile Error//C++203.7kb2024-05-07 10:17:352024-05-07 10:17:37

Judging History

This is the latest submission verdict.

  • [2024-05-07 10:17:37]
  • Judged
  • [2024-05-07 10:17:35]
  • Submitted

answer

// MagicDark
#include <bits/stdc++.h>
// #define int long long
#define debug cerr << "\033[32m[" << __LINE__ << "]\033[0m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T& x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T& x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 1e5 + 10, B = 5000, X = N / B + 5, Y = B + 5;
int n, m, op[N], l[N], r[N], tl[X], tr[X], id[N];
ll x[N], y[N], ans[N];
vector <int> v[N];
vector <int> vv[N];
ll a[X];
int b[X];
pair <int, int> s[X][Y];
pair <ll, ll> ss[X][Y];
pair <int, ll> tt[Y];
// ll pre[X][Y];
#define int long long
bool vis[N];
void remake(int w) {
	a[w] = b[w] = 0;
	F(i, l[w], r[w]) if (vis[i]) {
		if (op[i] == 1) s[w][++b[w]] = make_pair(x[i], y[i]);
		else {
			ll g = x[i];
			while (g && b[w]) {
				ll t = min(g, (ll) s[w][b[w]].first);
				g -= t;
				if (!(s[w][b[w]].first -= t)) b[w]--;
			}
			if (g) a[w] += g;
		}
	}
	F(i, 1, b[w]) {
		ss[w][i].first = ss[w][i - 1].first + s[w][i].first;
		ss[w][i].second = ss[w][i - 1].second + (ll) s[w][i].first * s[w][i].second;
	}
	// c[w] = ss[w][b[w]].first;
}
ll qq(int t, ll lim) {
	int l = 0, r = b[t] + 1;
	while (l + 1 < r) {
		int mid = (l + r) >> 1;
		if (ss[t][mid].first <= lim) l = mid;
		else r = mid;
	}
	return ss[t][l].second + (lim - ss[t][l].first) * s[t][r].second;
}
ll query(int t, ll l, ll r) {
	if (t > id[m]) {
		// debug << "~ " << t << ' ' << y[t] << " " << l << ' ' << r << ' ' << (r - l + 1) * y[t] << endl;
		return (r - l + 1) * y[t - id[m]];
	}
	return qq(t, r) - qq(t, l - 1);
}
signed main() {
	read(n), read(m);
	F(i, 1, m) {
		id[i] = (i - 1) / B + 1;
		read(op[i]);
		if (op[i] == 1) {
			read(l[i]), read(r[i]);
			read(x[i]), read(y[i]);
			vv[l[i]].push_back(i);
			vv[r[i] + 1].push_back(i);
		}
		if (op[i] == 2) {
			read(l[i]), read(r[i]);
			read(x[i]);
			vv[l[i]].push_back(i);
			vv[r[i] + 1].push_back(i);
		}
		if (op[i] == 3) {
			read(x[i]);
			read(l[i]), read(r[i]);
			v[x[i]].push_back(i);
		}
	}
	F(i, 1, id[m]) tl[i] = (i - 1) * B + 1, tr[i] = max(i * B, m);
	// 	F(j, tl[i], tr[i]) {
	// 		if (op[j] == 1) {
	// 		}
	// 	}
	// }
	F(i, 1, n) {
		for (int j: vv[i]) {
			vis[j] ^= true;
			remake(id[j]);
		}
		for (int j: v[i]) {
			// debug << j << " " << id[j] << endl;
			int ts = 0;
			F(t, 1, id[j] - 1) {
				ll w = a[t];
				while (w && ts) {
					ll t = min(w, tt[ts].second);
					if (!(tt[ts].second -= t)) ts--;
					w -= t;
				}
				tt[++ts] = make_pair(t, ss[t][b[t]].first);
			}
			F(t, tl[id[j]], j) if (vis[t]) {
				if (op[t] == 1) tt[++ts] = make_pair(id[m] + t, x[t]);
				else {
					ll w = x[t];
					while (w && ts) {
						ll t = min(w, tt[ts].second);
						if (!(tt[ts].second -= t)) ts--;
						w -= t;
					}
				}
			}
			ll w = 0;
			F(t, 1, ts) {
				ll wl = max((ll) 1, l[j] - w), wr = min(tt[t].second, r[j] - w);
				// debug << j << ' ' << tt[t].first << ' ' << tt[t].second << endl;
				if (wl <= wr) ans[j] += query(tt[t].first, wl, wr);//, debug << j << " " << ans[j] << ' ' << tt[t].first << ' ' << tt[t].second << ' ' << wl << ' ' << wr << endl;
				w += tt[t].second;
			}
		}
	}
	F(i, 1, m)
		if (op[i] == 3) cout << ans[i] << '\n';
	return 0;
}
/* why?
*/

详细

answer.code: In function ‘int main()’:
answer.code:93:60: error: no matching function for call to ‘max(long long int, int&)’
   93 |         F(i, 1, id[m]) tl[i] = (i - 1) * B + 1, tr[i] = max(i * B, m);
      |                                                         ~~~^~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:93:60: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   93 |         F(i, 1, id[m]) tl[i] = (i - 1) * B + 1, tr[i] = max(i * B, m);
      |                                                         ~~~^~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:93:60: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   93 |         F(i, 1, id[m]) tl[i] = (i - 1) * B + 1, tr[i] = max(i * B, m);
      |                                                         ~~~^~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:93:60: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   93 |         F(i, 1, id[m]) tl[i] = (i - 1) * B + 1, tr[i] = max(i * B, m);
      |                                                         ~~~^~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:93:60: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   93 |         F(i, 1, id[m]) tl[i] = (i - 1) * B + 1, tr[i] = max(i * B, m);
      |                                                         ~~~^~~~~~~~~~