# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361237 | 2021-01-28T21:08:28 Z | ogibogi2004 | Costinland (info1cup19_costinland) | C++14 | 1 ms | 296 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long ll n; char table[100][100]; ll a,b; bool used[100]; int main() { cin>>n; vector<ll>fib; fib.push_back(1); fib.push_back(1); for(;fib.back()<=n;) { fib.push_back(fib[fib.size()-1]+fib[fib.size()-2]); } if(fib.size()%2==0) { a=fib.size()/2+1; b=a+1; for(int i=1;i<b;i++) { table[1][i]='r'; table[a][i]='r'; } for(int i=1;i<a;i++) { table[i][1]='d'; table[i][b]='d'; } table[a][b]='.'; for(int i=1;i<a-1;i++) { table[i][i]='X'; } table[a][b]='.'; table[a-1][b-1]='d'; table[a-2][b-2]='d'; for(int i=1;i+2<a&&i+3<b;i++)table[i][i+1]='X'; for(int i=fib.size()-1;i>=0;i--) { if(n>=fib[i]) { used[i+1]=1; n-=fib[i]; } } for(int i=1;i<a;i++) { if(used[2*i-3]) { table[i][i-1]='X'; } else table[i][i-1]='r'; } for(int i=1;i+2<b;i++) { if(used[2*i]) { table[i][2+i]='X'; } else table[i][2+i]='d'; } if(!used[2*b-5])table[b-2][b-2]='r'; if(b==6&&n<=19) { cout<<a<<" "<<b-1<<endl; for(int i=1;i<=a;i++) { for(int j=1;j<b-1;j++) { if(table[i][j]=='.'||table[i][j]=='r'||table[i][j]=='d'||table[i][j]=='X') { } else if(i>j)table[i][j]='d'; else table[i][j]='r'; cout<<table[i][j]; } cout<<table[i][b]<<endl; } return 0; } cout<<a<<" "<<b<<endl; for(int i=1;i<=a;i++) { for(int j=1;j<=b;j++) { if(table[i][j]=='.'||table[i][j]=='r'||table[i][j]=='d'||table[i][j]=='X') { } else if(i>j)table[i][j]='d'; else table[i][j]='r'; cout<<table[i][j]; } cout<<endl; } /*int val[50][50]; val[1][1]=1; for(int i=1;i<=a;i++) { for(int j=1;j<=b;j++) { cout<<val[i][j]<<" "; if(table[i][j]=='r'||table[i][j]=='X') { val[i][j+1]+=val[i][j]; } if(table[i][j]=='d'||table[i][j]=='X') { val[i+1][j]+=val[i][j]; } } cout<<endl; }*/ } else { a=fib.size()/2+2; b=a; for(int i=1;i<b;i++) { table[1][i]='r'; table[a][i]='r'; } for(int i=1;i<a;i++) { table[i][1]='d'; table[i][b]='d'; } table[a][b]='.'; for(int i=1;i<=a;i++) { table[i][i]='X'; } table[a][b]='.'; table[a-1][b-1]='d'; for(int i=1;i+1<a&&i+2<b;i++)table[i][i+1]='X'; for(int i=fib.size()-1;i>=0;i--) { if(n>=fib[i]) { used[i+1]=1; n-=fib[i]; } } for(int i=1;i<a;i++) { if(used[2*i-3]) { table[i][i-1]='X'; } else table[i][i-1]='r'; } for(int i=1;i+2<b;i++) { if(used[2*i]) { table[i][2+i]='X'; } else table[i][2+i]='d'; } if(!used[2*b-5])table[b-2][b-2]='r'; cout<<a<<" "<<b<<endl; for(int i=1;i<=a;i++) { for(int j=1;j<=b;j++) { if(table[i][j]=='.'||table[i][j]=='r'||table[i][j]=='d'||table[i][j]=='X') { } else if(i>j)table[i][j]='d'; else table[i][j]='r'; cout<<table[i][j]; } cout<<endl; } int val[50][50]; val[1][1]=1; /*for(int i=1;i<=a;i++) { for(int j=1;j<=b;j++) { cout<<val[i][j]<<" "; if(table[i][j]=='r'||table[i][j]=='X') { val[i][j+1]+=val[i][j]; } if(table[i][j]=='d'||table[i][j]=='X') { val[i+1][j]+=val[i][j]; } } cout<<endl; }*/ } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Correct! Your size: 4 |
2 | Correct | 1 ms | 204 KB | Correct! Your size: 4 |
3 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
4 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
5 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
6 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
7 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
8 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
9 | Correct | 1 ms | 204 KB | Correct! Your size: 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Correct! Your size: 45 |
2 | Correct | 1 ms | 208 KB | Correct! Your size: 45 |
3 | Correct | 1 ms | 204 KB | Correct! Your size: 46 |
4 | Correct | 1 ms | 204 KB | Correct! Your size: 45 |
5 | Correct | 1 ms | 208 KB | Correct! Your size: 46 |
6 | Correct | 1 ms | 204 KB | Correct! Your size: 46 |
7 | Correct | 1 ms | 296 KB | Correct! Your size: 46 |
8 | Correct | 1 ms | 204 KB | Correct! Your size: 44 |