제출 #1125182

#제출 시각아이디문제언어결과실행 시간메모리
1125182cpptowinToy (CEOI24_toy)C++20
14 / 100
1598 ms90320 KiB
#include <bits/stdc++.h> #define fo(i, d, c) for (int i = d; i <= c; i++) #define fod(i, c, d) for (int i = c; i >= d; i--) #define maxn 1000010 #define N 1510 #define fi first #define se second #define pb emplace_back #define en cout << "\n"; #define bitcount(x) __builtin_popcountll(x) #define pii pair<int, int> #define vii vector<pii> #define lb(x) x & -x #define bit(i, j) ((i >> j) & 1) #define offbit(i, j) (i ^ (1LL << j)) #define onbit(i, j) (i | (1LL << j)) #define vi vector<int> #define all(x) x.begin(), x.end() #define ss(x) (int)x.size() #define UNIQUE(v) v.erase(unique(all(v)),v.end()) template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) { a = b; return true; } return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; } using namespace std; const int nsqrt = 450; const int mod = 1e9 + 7; void add(int &x, int k) { x += k; x %= mod; if(x < 0) x += mod; } void del(int &x, int k) { x -= k; x %= mod; if(x < 0) x += mod; } int n,m,k,l; int a[N][N],p[N][N]; pii s,t,f; int get(int l,int r,int u,int v) { return p[u][v] - p[l - 1][v] - p[u][r - 1] + p[l - 1][r - 1]; } bool save1(pii x) { return x.fi and x.fi <= n - k + 1 and x.se and x.se <= m and get(x.fi,x.se,x.fi + k - 1,x.se) == 0; } bool save2(pii x) { return x.fi and x.fi <= n and x.se and x.se <= m - l + 1 and get(x.fi,x.se,x.fi,x.se + l - 1) == 0; } bool save(pii x,pii y) { return x.fi <= y.fi and x.fi + k - 1 >= y.fi and y.se <= x.se and y.se + l - 1 >= x.se; } bool ok1(pii x) { return x.fi <= f.fi and x.fi + k - 1 >= f.fi and x.se == f.se; } bool ok2(pii x) { return x.fi == f.fi and x.se <= f.se and x.se + l - 1 >= f.se; } int dx[] = {1,-1,0,0}; int dy[] = {0,0,1,-1}; main() { #define name "TASK" if (fopen(name ".inp", "r")) { freopen(name ".inp", "r", stdin); freopen(name ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> m >> n >> l >> k; cin >> t.se >> t.fi >> s.se >> s.fi; t.fi++,t.se++,s.fi++,s.se++; // cout << t.fi << ' ' << t.se << ' ' << s.fi << ' ' << s.se;en; fo(i,1,n) fo(j,1,m) { char t;cin >> t; if(t == 'X') a[i][j] = 1; if(t == '*') f = {i,j}; p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + a[i][j]; } // cout << f.fi << ' ' << f.se;en; set<pair<pii,pii>> st; queue<pair<pii,pii>> q; q.push({s,t}); st.insert({s,t}); while(ss(q)) { auto [x,y] = q.front(); q.pop(); if(ok1(x) and ok2(y)) { return cout << "YES",0; } fo(k,0,3) { pii x1 = {x.fi + dx[k],x.se + dy[k]}; if(save1(x1) and save(x1,y) and st.find({x1,y}) == st.end()) { st.insert({x1,y}); q.push({x1,y}); } pii y1 = {y.fi + dx[k],y.se + dy[k]}; if(save2(y1) and save(x,y1) and st.find({x,y1}) == st.end()) { st.insert({x,y1}); q.push({x,y1}); } } } cout << "NO"; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:85:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   85 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.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(name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.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(name ".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...