QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111637 | #5504. Flower Garden | namelessgugugu | Compile Error | / | / | C++14 | 5.0kb | 2023-06-07 20:00:26 | 2023-06-07 20:00:38 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-07 20:00:38]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-07 20:00:26]
- 提交
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cassert>
#define FILEIO(filename) (freopen(filename ".in", "r", stdin), freopen(filename ".out", "w", stdout))
typedef long long ll;
typedef unsigned long long ull;
const int N = 500005;
int Test;
int n, q, nn, rt, pos[N];
struct Limit
{
int a, b, c, d;
} e[N];
int id[N], ls[N], rs[N], tot;
std::vector<int> E[N];
int build(int l, int r, int ty)
{
if(l == r)
{
if(ty == 0)
{
int x = ++tot;
id[x] = l, pos[l] = x;
return x;
}
else
return pos[l];
}
int x = ++tot;
int mid = (l + r) >> 1;
ls[x] = build(l, mid, ty);
rs[x] = build(mid + 1, r, ty);
if (ty == 0)
{
E[ls[x]].push_back(x);
E[rs[x]].push_back(x);
}
else
{
E[x].push_back(ls[x]);
E[x].push_back(rs[x]);
}
return x;
}
void add(int x, int l, int r, int ql, int qr, int v, int ty)
{
if(l >= ql && r <= qr)
{
if(ty == 0)
E[x].push_back(v + 6 * n - 1);
else
E[v + 6 * n - 1].push_back(x);
return;
}
int mid = (l + r) >> 1;
if(ql <= mid)
add(ls[x], l, mid, ql, qr, v, ty);
if(qr > mid)
add(rs[x], mid + 1, r, ql, qr, v, ty);
return;
}
std::vector<int> G[2][N];
int dfn[N], low[N], tt;
int stk[N], top;
bool ins[N];
int cnt;
int bel[N], siz[N];
void tarjan(int x)
{
dfn[x] = low[x] = ++tt;
stk[++top] = x;
for(int y : E[x])
{
if(!dfn[y])
tarjan(y), low[x] = std::min(low[x], low[y]);
else if(ins[y])
low[x] = std::min(low[x], dfn[y]);
}
if(dfn[x] == low[x])
{
++cnt;
for (int tmp = -1; tmp != x;)
{
tmp = stk[top--];
ins[tmp] = 0;
bel[tmp] = cnt;
if (id[tmp])
++siz[cnt];
}
}
return;
}
int col[N];
char ans[N];
int main(void) // Rose:0 Violet:1
{
scanf("%d", &Test);
while(Test--)
{
scanf("%d%d", &n, &q), nn = 9 * n + q - 2;
memset(pos, 0, sizeof(int) * (3 * n + 5));
tot = 0;
for (int i = 1; i <= 12 * n + 5; ++i)
E[i].clear(), id[i] = ls[i] = rs[i] = 0;
for (int o = 0; o < 2;++o)
for (int i = 1; i <= nn + 5; ++i)
G[o][i].clear();
memset(dfn, 0, sizeof(int) * (nn + 5)), tot = 0;
memset(low, 0, sizeof(int) * (nn + 5));
cnt = 0;
memset(bel, 0, sizeof(int) * (nn + 5));
memset(siz, 0, sizeof(int) * (nn + 5));
memset(col, 0, sizeof(int) * (nn + 5));
memset(ans, 0, sizeof(char) * (nn + 5));
for (int i = 1; i <= q;++i)
scanf("%d%d%d%d", &e[i].a, &e[i].b, &e[i].c, &e[i].d);
rt = build(1, 3 * n, 0);
for (int i = 1; i <= q; ++i)
add(rt, 1, 3 * n, e[i].a, e[i].b, i, 0);
rt = build(1, 3 * n, 1);
for (int i = 1; i <= q;++i)
add(rt, 1, 3 * n, e[i].c, e[i].d, i, 1);
assert(tot == 9 * n - 2);
for (int i = 1; i <= nn; ++i)
if (!dfn[i])
tarjan(i);
for (int i = 1; i <= nn;++i)
for(int j : E[i])
if(bel[i] != bel[j])
G[0][bel[i]].push_back(bel[j]), G[1][bel[j]].push_back(bel[i]);
int big = -1;
for (int i = 1; i <= cnt;++i)
if(siz[i] >= n)
{
big = i;
break;
}
bool flag = 0;
if (big == -1)
{
flag = 1;
int now = 0;
for (int i = 1; now < n && i <= cnt;++i)
col[i] = 1, now += siz[i];
assert(now >= n && now <= 2 * n);
}
else
{
for (int o = 0; o < 2; ++o)
{
for (int i = 1; i <= cnt;++i)
col[i] = o;
col[big] = o ^ 1;
for (int i = 1; i <= cnt; ++i)
if(col[i] != o)
for(int j : G[o][i])
}
for (int i = cnt; i >= 1; --i)
if (col[i] != o)
for (int j : G[o][i])
col[j] = o ^ 1;
int now = 0;
for (int i = 1; i <= cnt;++i)
now += col[i] * siz[i];
if(now >= n && now <= 2 * n)
{
flag = 1;
break;
}
}
}
if(!flag)
puts("NIE");
else
{
puts("TAK");
int sss = 0;
for (int i = 1; i <= nn; ++i)
if(id[i])
ans[id[i]] = col[bel[i]] ? 'F' : 'R', sss += col[bel[i]];
assert(sss >= n && sss <= 2 * n);
puts(ans + 1);
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:159:21: error: expected primary-expression before ‘}’ token 159 | } | ^ answer.code:161:35: error: ‘o’ was not declared in this scope 161 | if (col[i] != o) | ^ answer.code:174:13: error: ‘flag’ was not declared in this scope 174 | if(!flag) | ^~~~ answer.code: At global scope: answer.code:187:5: error: expected unqualified-id before ‘return’ 187 | return 0; | ^~~~~~ answer.code:188:1: error: expected declaration before ‘}’ token 188 | } | ^ answer.code: In function ‘int main()’: answer.code:99:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 99 | scanf("%d", &Test); | ~~~~~^~~~~~~~~~~~~ answer.code:102:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 102 | scanf("%d%d", &n, &q), nn = 9 * n + q - 2; | ~~~~~^~~~~~~~~~~~~~~~ answer.code:118:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 118 | scanf("%d%d%d%d", &e[i].a, &e[i].b, &e[i].c, &e[i].d); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~