Submission #65065594
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
int n;
ll k,cnt[111][111];
bool check(VI c) {
int z=0,w=0;
per(i,0,SZ(c)) {
w+=c[i];
z+=w;
}
return (k-z)%(SZ(c)+1)==0;
}
int main() {
scanf("%d%lld",&n,&k);
--k;
cnt[0][0]=k;
for (int i=1;i<=n;i++) {
VI dif;
for (int j=1;j<i;j++) {
dif.pb(cnt[i-1][j-1]-cnt[i-1][j]);
}
set<VI> st;
for (int c=0;c<i;c++) {
VI ndif=dif;
ndif.insert(ndif.begin()+c,0);
if (check(ndif)) {
st.insert(ndif);
}
ndif=dif;
ndif.insert(ndif.begin()+c,1);
if (check(ndif)) {
st.insert(ndif);
}
}
assert(SZ(st)==1);
auto c=*st.begin();
int z=0,w=0;
per(i,0,SZ(c)) {
w+=c[i];
z+=w;
}
ll b=(k-z)/(SZ(c)+1);
cnt[i][i]=b;
per(j,0,SZ(c)) {
cnt[i][j]=cnt[i][j+1]+c[j];
}
//rep(j,0,i+1) printf("%lld ",cnt[i][j]); puts("");
}
string ans1,ans2;
int y=0;
for (int x=1;x<n;x++) {
if (cnt[x][y]>cnt[x][y+1]) y++,ans1.pb('R'),ans2.pb('D');
else ans1.pb('D'),ans2.pb('R');
cnt[x][y]+=1;
}
reverse(all(ans2));
ans1+=ans2;
puts(ans1.c_str());
//rep(i,0,n) printf("%d\n",)
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Human Exercise |
| User | apiad |
| Language | C++ 20 (gcc 12.2) |
| Score | 1100 |
| Code Size | 1807 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 3900 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d%lld",&n,&k);
| ~~~~~^~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-20.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, sample-01.txt, sample-02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 1 ms | 3628 KiB |
| 01-02.txt | AC | 1 ms | 3516 KiB |
| 01-03.txt | AC | 1 ms | 3772 KiB |
| 01-04.txt | AC | 1 ms | 3712 KiB |
| 01-05.txt | AC | 1 ms | 3692 KiB |
| 01-06.txt | AC | 1 ms | 3716 KiB |
| 01-07.txt | AC | 1 ms | 3900 KiB |
| 01-08.txt | AC | 1 ms | 3700 KiB |
| 01-09.txt | AC | 1 ms | 3720 KiB |
| 01-10.txt | AC | 1 ms | 3688 KiB |
| 01-11.txt | AC | 1 ms | 3560 KiB |
| 01-12.txt | AC | 1 ms | 3720 KiB |
| 01-13.txt | AC | 1 ms | 3732 KiB |
| 01-14.txt | AC | 1 ms | 3636 KiB |
| 01-15.txt | AC | 1 ms | 3652 KiB |
| 01-16.txt | AC | 1 ms | 3776 KiB |
| 01-17.txt | AC | 1 ms | 3784 KiB |
| 01-18.txt | AC | 2 ms | 3580 KiB |
| 01-19.txt | AC | 2 ms | 3788 KiB |
| 01-20.txt | AC | 2 ms | 3804 KiB |
| 02-01.txt | AC | 1 ms | 3636 KiB |
| 02-02.txt | AC | 1 ms | 3588 KiB |
| 02-03.txt | AC | 1 ms | 3692 KiB |
| 02-04.txt | AC | 1 ms | 3692 KiB |
| 02-05.txt | AC | 1 ms | 3676 KiB |
| 02-06.txt | AC | 1 ms | 3896 KiB |
| 02-07.txt | AC | 1 ms | 3716 KiB |
| 02-08.txt | AC | 1 ms | 3772 KiB |
| 02-09.txt | AC | 1 ms | 3584 KiB |
| 02-10.txt | AC | 1 ms | 3708 KiB |
| 02-11.txt | AC | 1 ms | 3704 KiB |
| 02-12.txt | AC | 1 ms | 3688 KiB |
| 02-13.txt | AC | 1 ms | 3632 KiB |
| 02-14.txt | AC | 1 ms | 3588 KiB |
| 02-15.txt | AC | 1 ms | 3708 KiB |
| 02-16.txt | AC | 1 ms | 3600 KiB |
| 02-17.txt | AC | 1 ms | 3648 KiB |
| 02-18.txt | AC | 1 ms | 3704 KiB |
| 02-19.txt | AC | 1 ms | 3632 KiB |
| 02-20.txt | AC | 1 ms | 3648 KiB |
| 03-01.txt | AC | 1 ms | 3644 KiB |
| 03-02.txt | AC | 1 ms | 3776 KiB |
| 03-03.txt | AC | 1 ms | 3716 KiB |
| 03-04.txt | AC | 1 ms | 3736 KiB |
| 03-05.txt | AC | 2 ms | 3880 KiB |
| 03-06.txt | AC | 2 ms | 3816 KiB |
| 03-07.txt | AC | 2 ms | 3820 KiB |
| 03-08.txt | AC | 2 ms | 3800 KiB |
| sample-01.txt | AC | 1 ms | 3540 KiB |
| sample-02.txt | AC | 1 ms | 3720 KiB |