Submission #519444

#TimeUsernameProblemLanguageResultExecution timeMemory
519444KeshiL-triominoes (CEOI21_ltriominoes)C++17
0 / 100
1 ms460 KiB
//In the name of God #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const ll maxn = 2e5 + 100; const ll mod = 1e9 + 7; const ll inf = 1e18; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout); #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() ll pw(ll a, ll b){ ll c = 1; while(b){ if(b & 1) c = c * a % mod; a = a * a % mod; b >>= 1; } return c; } vector<int> merge(vector<int> a, vector<int> b){ for(int i : b){ a.pb(i); } return a; } vector<int> get(int x, int t){ if(x == 0) return vector<int>(1, ((t & 1) ? 7 : x)); if(x == 7) return vector<int>(1, ((t & 1) ? 0 : x)); if(x == 3) return vector<int>(1, ((t & 1) ? 6 : x)); if(x == 6) return vector<int>(1, ((t & 1) ? 3 : x)); if(x == 1) return vector<int>(1, ((t & 1) ? 4 : x)); if(x == 4) return vector<int>(1, ((t & 1) ? 1 : x)); if(x == 2) return vector<int>(0); vector<int> vec; vec.pb(3); vec.pb(6); return vec; } int n, m, k; pii a[maxn]; map<int, int> mp; vector<int> vec, b; int main(){ fast_io; cin >> n >> m >> k; swap(n, m); assert(m == 3); for(int i = 0; i < k; i++){ cin >> a[i].F >> a[i].S; swap(a[i].F, a[i].S); vec.pb(a[i].F); mp[a[i].F] |= (1 << (a[i].S - 1)); } vec.pb(1); vec.pb(n + 1); sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin()); b.pb(0); for(int i = 0; i + 1 < Sz(vec); i++){ vector<int> bb; for(int j : b){ if((j & mp[vec[i]])) continue; //cout << "^ " << j << " " << (j | mp[vec[i]]) << "\n"; bb = merge(bb, get(j | mp[vec[i]], vec[i + 1] - vec[i])); } b = bb; /* cout << "# " << vec[i] << " -> "; for(int j : b){ cout << j << " "; } cout << "\n";*/ } for(int i : b){ // cout << i << " "; if(i == 0){ cout << "YES\n"; return 0; } } cout << "NO\n"; return 0; }
#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...