QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#53724#1869. Power Station of Artdjwj233WA 1375ms40408kbC++1.9kb2022-10-05 21:05:452022-10-05 21:05:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-05 21:05:46]
  • 评测
  • 测评结果:WA
  • 用时:1375ms
  • 内存:40408kb
  • [2022-10-05 21:05:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define fo(v,a,b) for(int v=a;v<=b;v++)
#define fr(v,a,b) for(int v=a;v>=b;v--)
#define cl(a,v) memset(a,v,sizeof(a))

const int N = 1000010;

int n, m; vector<int> g[N];
int a[N], b[N]; char c[N], d[N];

int va[N], vb[N], cntA, cntB;

namespace N5 {
	typedef array<int, 5> sta;
	sta S, T; set<sta> Vis; queue<sta> q;
	bool gr[10][10];
	void solve() {
		while(q.size()) q.pop(); Vis.clear(), cl(gr, 0);
		fo(x,1,n) for(int y : g[x]) gr[x][y] = true;
		fo(i,1,5) S[i - 1] = T[i - 1] = 0;
		fo(i,1,n) {
			S[i - 1] = (c[i] == 'R' ? 1 : -1) * a[i];
			T[i - 1] = (d[i] == 'R' ? 1 : -1) * b[i];
		}
		
		Vis.insert(S), q.push(S);
		while(q.size()) {
			auto now = q.front(); q.pop();
			if(now == T) return puts("YES"), void();
			fo(x,1,n) fo(y,1,n) if(gr[x][y]) {
				auto nxt = now;
				int v1 = abs(nxt[x - 1]), d1 = nxt[x - 1] / v1;
				int v2 = abs(nxt[y - 1]), d2 = nxt[y - 1] / v2;
				if(d1 == d2) d1 *= -1, d2 *= -1;
				nxt[x - 1] = v2 * d1, nxt[y - 1] = v1 * d2;
				if(Vis.find(nxt) == Vis.end())
					Vis.insert(nxt), q.push(nxt);
			}
		} puts("NO");
	}
}

void reset() {
	cntA = cntB = 0; fo(i,1,n) g[i].clear();
}
void solve() {
	scanf("%d%d", &n, &m), reset();
	fo(i,1,m) {
		int u, v; scanf("%d%d", &u, &v);
		assert(u != v);
		g[u].push_back(v), g[v].push_back(u);
	}
	fo(i,1,n) scanf("%d", &a[i]), a[i]++, va[i] = a[i];
	scanf("%s", c + 1); fo(i,1,n) cntA += (c[i] == 'R');

	fo(i,1,n) scanf("%d", &b[i]), b[i]++, vb[i] = b[i];
	scanf("%s", d + 1); fo(i,1,n) cntB += (c[i] == 'R');

	if((cntA & 1) != (cntB & 1)) return puts("NO"), void();
	sort(va + 1, va + n + 1), sort(vb + 1, vb + n + 1);
	fo(i,1,n) if(va[i] != vb[i]) return puts("NO"), void();

	if(n <= 5) return N5 :: solve();
	puts("YES");
}

int main()
{
	int T; cin >> T;
	while(T--) solve();
	
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 27124kb

input:

3
2 1
1 2
3 4
RR
4 3
BB
3 2
1 2
2 3
1 1 1
RBR
1 1 1
BBB
3 3
1 2
2 3
3 1
1 1 1
RBR
1 1 1
BBB

output:

YES
NO
YES

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 1375ms
memory: 40408kb

input:

25054
5 10
4 5
4 2
4 3
4 1
5 2
5 3
5 1
2 3
2 1
3 1
12 2 9 10 7
RRRBB
10 2 9 7 12
RRBRB
1 0
4
R
4
R
8 4
4 3
1 5
8 5
6 5
7 2 11 10 9 6 3 5
RBRBBRBR
7 2 10 11 6 5 3 9
RBRBBRBR
7 4
7 2
5 1
5 6
5 4
12 5 9 14 5 12 12
RRBRBRR
14 12 9 5 12 12 5
RBBRBRB
10 1
4 6
5 3 2 9 7 3 11 11 6 8
RRRBRRBBBR
5 3 2 3 7 9 1...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
...

result:

wrong answer 21st lines differ - expected: 'NO', found: 'YES'