Submission #1125280

#TimeUsernameProblemLanguageResultExecution timeMemory
1125280pemguimnL-triominoes (CEOI21_ltriominoes)C++20
0 / 100
1715 ms589824 KiB
#include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int T = 5; int t, n[T], m[T], k[T]; vector<pii> a[T]; bool c1(){ for(int i = 0; i < t; i++){ if(n[i] > 8 || m[i] > 8) return false; } return true; } bool c3(){ for(int i = 0; i < t; i++){ if(k[i] > 0) return false; } return true; } namespace brute{ const int N = 10; int b[N][N], r, c; bool reached = false; void brute(int i, int j){ if(reached) return; if(b[i][j]) return brute(i, j + 1); if(j == c + 1) return brute(i + 1, 1); if(i == r + 1) return reached = true, void(); if(i == r) return; if(j < c && i < r && b[i][j + 1] == 0 && b[i + 1][j + 1] == 0){ b[i][j + 1] = b[i][j] = b[i + 1][j + 1] = 1; brute(i, j + 1); b[i][j + 1] = b[i][j] = b[i + 1][j + 1] = 0; } if(j < c && i < r && b[i + 1][j] == 0 && b[i + 1][j + 1] == 0){ b[i + 1][j] = b[i][j] = b[i + 1][j + 1] = 1; brute(i, j + 1); b[i + 1][j] = b[i][j] = b[i + 1][j + 1] = 0; } if(j > 1 && i < r && b[i + 1][j] == 0 && b[i + 1][j - 1] == 0){ b[i + 1][j] = b[i][j] = b[i + 1][j - 1] = 1; brute(i, j + 1); b[i + 1][j] = b[i][j] = b[i + 1][j - 1] = 0; } if(j < c && i < r && b[i + 1][j] == 0 && b[i][j + 1] == 0){ b[i + 1][j] = b[i][j] = b[i][j + 1] = 1; brute(i, j + 1); b[i + 1][j] = b[i][j] = b[i][j + 1] = 0; } } void solve(){ for(int i = 0; i < t; i++){ r = n[i], c = m[i], reached = false; for(int i = 0; i <= r + 1; i++){ for(int j = 0; j <= c + 1; j++) b[i][j] = 0; } for(pii coor : a[i]) b[coor.first][coor.second] = 1; brute(1, 1); cout << (reached ? "YES" : "NO") << '\n'; } } } namespace sub3{ void solve(){ for(int i = 0; i < t; i++){ if(n[i] * m[i] % 6 == 0) cout << "YES\n"; else cout << "NO\n"; } } } namespace wtfisthisalgo{ void solve(){ } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); #define task "MOTOR" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> t; for(int i = 0; i < t; i++){ cin >> n[i] >> m[i] >> k[i]; for(int j = 0; j < k[i]; j++){ int x, y; cin >> x >> y; a[i].push_back({x, y}); } } if(c1()) return brute::solve(), 0; sub3::solve(); return 0; } /* 3 4 3 3 1 1 1 3 4 3 5 2 4 1 2 2 1 5 1 5 2 2 3 0 */

Compilation message (stderr)

ltrominoes.cpp: In function 'int main()':
ltrominoes.cpp:90:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ltrominoes.cpp:91:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...