QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#21795 | #2831. Game Theory | gogo# | Compile Error | / | / | C++20 | 3.5kb | 2022-03-08 15:43:28 | 2022-05-18 04:12:01 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-05-18 04:12:01]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-03-08 15:43:28]
- 提交
answer
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l); i <= (r); i ++)
#define per(i, r, l) for(int i = (r); i >= (l); i --)
#define trv(i, u, v) for(int i = head[u], v = e[i].to; i; v = e[i = e[i].nxt].to)
#define fi first
#define se second
#define all(s) s.begin(), s.end()
#define sz(s) (int)(s.size())
#define lb(s) ((s) & -(s))
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
mt19937_64 hua(time(0));
template<typename T> inline bool chkmx(T &x, T y) {return x < y ? x = y, 1 : 0;}
template<typename T> inline bool chkmn(T &x, T y) {return y < x ? x = y, 1 : 0;}
template<int T> using A = array<int, T>;
inline int read() {
int x = 0, f = 1; char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = 0;
for(; isdigit(c); c = getchar()) x = x * 10 + c - '0';
return f ? x : -x;
}
const int maxn = 2e5;
const int mod = 998244353;
inline int add(int a, int b) {return (a += b) >= mod ? a - mod : a;}
int n, m;
char s[maxn + 5];
struct Segment {
#define ls u << 1
#define rs u << 1 | 1
struct Node {
int sum[4], rev;
}a[maxn + 5 << 2];
void pushup(int u) {
rep(c, 0, 3) a[u].sum[c] = add(a[ls].sum[c], a[rs].sum[c]);
}
void seta(int u) {
swap(a[u].sum[0], a[u].sum[1]);
swap(a[u].sum[2], a[u].sum[3]);
a[u].rev ^= 1;
}
void pushdown(int u) {
if(a[u].rev) seta(ls), seta(rs), a[u].rev = 0;
}
void update(int u, int l, int r, int ql, int qr) {
if(l >= ql && r <= qr) return seta(u);
int mid = l + r >> 1; pushdown(u);
if(qr <= mid) update(ls, l, mid, ql, qr);
else if(ql > mid) update(rs, mid + 1, r, ql, qr);
else update(ls, l, mid, ql, qr), update(rs, mid + 1, r, ql, qr);
pushup(u);
}
int query(int u, int l, int r, int ql, int qr, int c) {
if(l >= ql && r <= qr) return a[u].sum[c];
int mid = l + r >> 1; pushdown(u);
if(qr <= mid) return query(ls, l, mid, ql, qr, c);
else if(ql > mid) return query(rs, mid + 1, r, ql, qr, c);
else return query(ls, l, mid, ql, qr, c) + query(rs, mid + 1, r, ql, qr, c);
}
int find(int u, int l, int r, int p, int &cnt, int c) {
if(a[u].sum[c] < cnt) {
cnt -= a[u].sum[c];
return -1;
}
if(l == r) return l;
int mid = l + r >> 1; pushdown(u);
if(p > mid) return find(rs, mid + 1, r, p, cnt, c);
else {
int x = find(ls, l, mid, p, cnt, c);
return x == -1 ? find(rs, mid + 1, r, p, cnt, c) : x;
}
}
void build(int u, int l, int r) {
a[u].rev = 0;
if(l == r) {
rep(i, 0, 3) a[u].sum[i] = 0;
// cout << s[l] - '0' << '\n';
a[u].sum[s[l] - '0'] = 1;
a[u].sum[s[l] - '0' + 2] = 1;
return ;
}
int mid = l + r >> 1;
build(ls, l, mid), build(rs, mid + 1, r);
pushup(u);
// rep(i, 0, 3) cout <<a[u].sum[i] << ' '; cout << '\n';
}
}ds;
void solve() {
cin >> s + 1;
ds.build(1, 1, n);
rep(i, 1, m) {
int l = read(), r = read();
// cout << l << ' '<< r << '\n';
ds.update(1, 1, n, l, r);
// cout << "wqwq\n";
int p = ds.query(1, 1, n, 1, n, 1);
// cout << p << '\n';
int col = ds.query(1, 1, n, p, p, 1);
// cout << p << ' ' << col << '\n';
ll s1 = ds.query(1, 1, n, 1, p, !col + 2), lcnt = ds.query(1, 1, n, 1, p, !col);
// cout << p << ' ' << col << ' ' << s1 << ' ' << lcnt << '\n';
int rcnt = lcnt + !col;
ll ans = - s1 + lcnt * p + rcnt * p;
ll q = ds.find(1, 1, n, p, rcnt, col), s2 = p + 1 <= q ? ds.query(1, 1, n, p + 1, q, col + 2) : 0;
cout << (2 * ans + p) % mod << '\n';
}
}
int main() {
// freopen("in.txt", "r", stdin);
while(cin >> n >> m) {
solve();
}
return 0;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:92:13: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’) 92 | cin >> s + 1; | ~~~ ^~ ~~~~~ | | | | | char* | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match) 168 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/11/istream:168:7: note: conversion of argument 1 would be ill-formed: answer.code:92:18: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’ 92 | cin >> s + 1; | ~~^~~ In file included from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match) 172 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/11/istream:172:7: note: conversion of argument 1 would be ill-formed: answer.code:92:18: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive] 92 | cin >> s + 1; | ~~^~~ | | | char* answer.code:92:18: error: cannot bind rvalue ‘(short int)(((char*)(& s)) + 1)’ to ‘short int&’ In file included from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match) 175 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/11/istream:175:7: note: conversion of argument 1 would be ill-formed: answer.code:92:18: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive] 92 | cin >> s + 1; | ~~^~~ | | | char* answer.code:92:18: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& s)) + 1)’ to ‘short unsigned int&’ In file included from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match) 179 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/11/istream:179:7: note: conversion of argument 1 would be ill-formed: answer.code:92:18: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive] 92 | cin >> s + 1; | ~~^~~ | | | char* answer.code:92:18: error: cannot bind rvalue ‘(int)(((char*)(& s)) + 1)’ to ‘int&’ In file included from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/istream:182:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match) 182 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/11/istream:182:7: note: conversion of argument 1 would be ill-formed: answer.code:92:18: error: invalid conversion ...