0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-26 09:31:59 +00:00
OI-codes/LibreOJ/2162/data/checker.cpp

80 lines
1.8 KiB (Stored with Git LFS)
C++

#include <unordered_map>
#include <cassert>
#include "testlib.h"
#define MAXN 100005
#define MAXM 1000005
std::unordered_map <long long, int> e;
int u[MAXM], v[MAXM], c[MAXM], allM;
std::set <int> s[MAXN];
std::vector <int> visp;
bool vis[MAXN];
int main(int argc, char *argv[])
{
registerTestlibCmd(argc, argv);
std::string jans = ans.readToken();
if (jans == "NIE")
{
std::string pans = ouf.readToken();
if (pans == jans)
quitf(_ok, "OK");
else
quitf(_wa, "participant found an answer, but jury didn't.");
}
int n = inf.readInt();
int m = inf.readInt();
for (int i = 1; i <= m; i++)
{
u[i] = inf.readInt();
v[i] = inf.readInt();
assert(s[u[i]].count(v[i]) == 0);
int S = inf.readInt();
c[i] = inf.readInt();
e[1LL * (u[i] - 1) * n + v[i]] = S;
s[u[i]].insert(v[i]);
}
int k = ouf.readInt();
if (k < 0)
quitf(_wa, "k is negative.");
while (k--)
{
int ki = ouf.readInt();
allM += ki;
if (allM > 5 * m)
quitf(_wa, "too many edges.");
int x = ouf.readInt(1, n);
int st = x;
vis[x] = true; visp.push_back(x);
for (; ki; --ki)
{
int y = ouf.readInt(1, n);
if (vis[y] && y != st)
quitf(_wa, "not a simple circle.");
vis[y] = true;
visp.push_back(y);
if (!s[x].count(y))
{
if (!s[y].count(x))
quitf(_wa, "edge %d-%d does not exist.", x, y);
e[1LL * (y - 1) * n + x] ^= 1;
}
else
e[1LL * (x - 1) * n + y] ^= 1;
x = y;
}
if (!ouf.seekEoln())
quitf(_wa, "output more integers.");
for (int v : visp) vis[v] = false;
visp.clear();
}
for (int i = 1; i <= m; i++)
if (e[1LL * (u[i] - 1) * n + v[i]] != c[i])
quitf(_wa, "edge %d-%d: color does meet the requirement.", u[i], v[i]);
quitf(_ok, "OK");
return 0;
}