Submission #1116420

# Submission time Handle Problem Language Result Execution time Memory
1116420 2024-11-21T15:50:44 Z biximo Walk (POI13_spa) C++17
0 / 100
100 ms 17224 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 300005, INF = 1000000000;
int n, k;
long long x, y;
set<long long> nt;
long long getNum(string s) {
	long long v = 0;
	for(char i: s) {
		v = v*2+i-'0';
	}
	return v;
}
int getSz(long long st) {
	queue<long long> que;
	unordered_set<long long> vs;
	que.push(st);
	vs.insert(st);
	while(que.size() && vs.size() <= 5000000) {
		long long c =que.front(); que.pop();
		for(int i = 0; i < n; i ++) {
			if(c&1LL<<i) continue;
			if(vs.count(c|1LL<<i)) continue;
			if(nt.count(c|1LL<<i)) continue;
			vs.insert(c|1LL<<i);
			que.push(c|1LL<<i);
		}
	}
	return vs.size();
}
bool contains(long long st, long long gl) {
	queue<long long> que;
	unordered_set<long long> vs;
	que.push(st);
	vs.insert(st);
	while(que.size() && vs.size() <= 5000000) {
		long long c =que.front(); que.pop();
		for(int i = 0; i < n; i ++) {
			if(c&1LL<<i) continue;
			if(vs.count(c|1LL<<i)) continue;
			if(nt.count(c|1LL<<i)) continue;
			vs.insert(c|1LL<<i);
			que.push(c|1LL<<i);
		}
	}
	return vs.count(gl);
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k;
    string a, b;
    cin >> a >> b; x = getNum(a); y = getNum(b);
    while(k--) {
    	cin >> a;
    	nt.insert(getNum(a));
    }
    if(getSz(x) >= 5000000 && getSz(y) >= 5000000 || contains(x,y)) {
    	cout << "TAK\n";
    } else {
    	cout << "NIE\n";
    }
}

Compilation message

spa.cpp: In function 'int main()':
spa.cpp:57:28: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   57 |     if(getSz(x) >= 5000000 && getSz(y) >= 5000000 || contains(x,y)) {
      |        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 17224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 11336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 10060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 14920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 14360 KB Output isn't correct
2 Halted 0 ms 0 KB -