Submission #523862

#TimeUsernameProblemLanguageResultExecution timeMemory
523862BaytoroCostinland (info1cup19_costinland)C++17
100 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define Baytoro_MayrambekovOrz void solve() #define ios ios::sync_with_stdio(false); cin.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define int long long #define endl '\n' #define yes cout<<"YES\n"; #define no cout<<"NO\n"; void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int binpow(int a,int n){ if(n==0) return 1; if(n%2==1) return binpow(a, n-1)*a; else{ int b=binpow(a, n/2); return b*b; } } char ar[55][55]; int dp[55][55]; int a,b,c,n,m,i,j,k,x,y,cnt=0,sum=0,res=0; Baytoro_MayrambekovOrz{ ar[1][1]='X'; dp[1][1]=1; for(i=1;i<=48;i++){ for(j=1;j<=48;j++){ if(j>=i){ if(j-i<=2){ ar[i][j]='X'; dp[i+1][j]+=dp[i][j]; dp[i][j+1]+=dp[i][j]; } else{ ar[i][j]='.'; dp[i][j+1]+=dp[i][j]; } } else{ if(i-j==1){ ar[i][j]='X'; dp[i+1][j]+=dp[i][j]; dp[i][j+1]+=dp[i][j]; } else{ ar[i][j]='.'; dp[i+1][j]+=dp[i][j]; } } } } cin>>n; int k=46; while(dp[k][k]>n) k--; cout<<k+1<<' '<<k+1<<endl; n-=dp[k][k]; ar[k][k]='.'; for(i=k-1;i>=1;i--){ if(dp[i][k]>n) ar[i][min(i+2,k)]='d'; else n-=dp[i][k]; if(dp[k][i]>n) ar[i+1][i]='r'; else n-=dp[k][i]; } for(i=1;i<=k;i++){ for(j=1;j<=k;j++){ cout<<ar[i][j]; } cout<<"d\n"; } for(i=1;i<=k;i++) cout<<"r"; cout<<'.'; //cout<<dp[k][k]; } main(){ // ios; int T=1; //cin>>T; while(T--){ solve(); } }

Compilation message (stderr)

costinland.cpp:90:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   90 | main(){
      | ^~~~
costinland.cpp: In function 'void fopn(std::string)':
costinland.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
costinland.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...