제출 #230141

#제출 시각아이디문제언어결과실행 시간메모리
230141xiaowuc1새로운 문제 (POI13_spa)C++14
49 / 100
5090 ms244756 KiB
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <complex> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_set> #include <vector> using namespace std; // BEGIN NO SAD #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define derr if(1) cerr typedef vector<int> vi; // END NO SAD typedef long long ll; typedef pair<int, int> pii; typedef vector<vector<ll>> matrix; typedef pair<int, pii> state; ll parse() { string s; cin >> s; ll ret = 0; for(int i = 0; i < sz(s); i++) { ret <<= 1; ret |= s[i] == '1'; } return ret; } vector<ll> bad; int n, k; unordered_set<ll> s; ll all[5000001]; bool done = false; bool finite(ll src, ll snk) { s.clear(); int allsz = 0; all[allsz++] = src; s.insert(src); for(int i = 0; i < allsz && allsz <= n*k; i++) { for(int j = 0; j < n; j++) { ll curr = all[i] ^ (1LL << j); if(s.count(curr)) continue; auto it = lower_bound(all(bad), curr); if(it != bad.end() && *it == curr) continue; s.insert(curr); all[allsz++] = curr; } } if(s.count(snk)) done = true; return !s.count(snk) && allsz <= n*k; } void solve() { cin >> n >> k; ll src = parse(); ll snk = parse(); bad.reserve(k); for(int i = 0; i < k; i++) { bad.push_back(parse()); } sort(all(bad)); if(finite(src, snk)) { cout << "NIE\n"; return; } if(!done && finite(snk, src)) { cout << "NIE\n"; return; } cout << "TAK\n"; } // are there edge cases (N=1?) // are array sizes proper (scaled by proper constant, for example 2* for koosaga tree) // integer overflow? // DS reset properly between test cases int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...