제출 #1146948

#제출 시각아이디문제언어결과실행 시간메모리
1146948jahongirGardening (RMI21_gardening)C++20
11 / 100
38 ms744 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace std; using namespace __gnu_pbds; using pi = pair<int,int>; using vi = vector<int>; #define f first #define s second #define pb push_back #define ll long long #define all(v) (v).begin(),(v).end() typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; void setIO(string name = ""){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if(name.empty()){ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); }else{ freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } const int mxn = 210; void solve2(vector<vector<int>> &ans, int cnt, int k, int a, int b, int sx, int sy){ //Base case if(k<=0) return; if(a <= 0 || b <= 0) return; //Outer shell is required if(a*b+2-k >= a+b){ for(int i = 0; i < a; i++){ ans[sx+2*i][sy] = ans[sx+2*i+1][sy] = cnt; ans[sx+2*i][sy+2*b-1] = ans[sx+2*i+1][sy+2*b-1] = cnt; } for(int i = 0; i < b; i++){ ans[sx][sy+2*i] = ans[sx][sy+2*i+1] = cnt; ans[sx+2*a-1][sy+2*i] = ans[sx+2*a-1][sy+2*i+1] = cnt; } solve2(ans,cnt+1,k-1,a-1,b-1,sx+1,sy+1); return; } int dx = 0, dy = 0; if(b*(a-1) < k){ dy = a*b-k; dx = 2; }else{ dy = b; dx = a*b + 2 - k - b; } for(int i = 0; i < a; i++){ for(int j = 0; j < b; j++){ if(i < dx && j < dy) continue; ans[sx+2*i][sy+2*j] = ans[sx+2*i][sy+2*j+1] = cnt; ans[sx+2*i+1][sy+2*j] = ans[sx+2*i+1][sy+2*j+1] = cnt; cnt++; } } solve2(ans,cnt,k-(a*b-dx*dy),dx,dy,sx,sy); } void solve(){ int n,m,k; cin >> n >> m >> k; if(n%2==1 || m%2==1){ cout << "NO\n"; return; } int a = n/2, b = m/2; if((a%3==0 && a==b && k == a+1) || (k < max(a,b)) || (k > a*b) || (k==a*b-1)){ cout << "NO\n"; return; } vector<vector<int>> ans(n,vector<int>(m,0)); solve2(ans,1,k,a,b,0,0); cout << "YES\n"; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++) cout << ans[i][j] << ' '; cout << '\n'; } } signed main(){ // setIO(); int t = 1; cin >> t; while(t--) solve(); }

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

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen((name+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen((name+".out").c_str(), "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...