Submission #57323879


Source Code Expand

Copy
#include<bits/stdc++.h>
#define file(NAME)\
freopen(NAME".in","r",stdin);\
freopen(NAME".out","w",stdout);
#define ll long long
#define pii pair<ll,ll>
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define per(i,l,r) for(ll i=r;i>=l;i--)
using namespace std;
mt19937 rnd(random_device{}());
const int N=2e5+5,M=1e6;
ll h,w,n,d[M],g;
pii a[N];
map<ll,ll> ls;
#define X 1,w,1
#define Y int x,int y,int p
#define D int mid=(x+y)/2
#define L x,mid,p*2
#define R mid+1,y,p*2+1
pii t[N*5];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define file(NAME)\
	freopen(NAME".in","r",stdin);\
	freopen(NAME".out","w",stdout);
#define ll long long
#define pii pair<ll,ll>
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define per(i,l,r) for(ll i=r;i>=l;i--)
using namespace std;
mt19937 rnd(random_device{}());
const int N=2e5+5,M=1e6;
ll h,w,n,d[M],g;
pii a[N];
map<ll,ll> ls;

#define X 1,w,1
#define Y int x,int y,int p
#define D int mid=(x+y)/2
#define L x,mid,p*2
#define R mid+1,y,p*2+1
pii t[N*5];
pii fnd(Y,int l,int r)
{
	if(x>r||y<l) return make_pair(0,0);
	if(l<=x&&y<=r) return t[p];
	D;return max(fnd(L,l,r),fnd(R,l,r));
}
void cng(Y,int w,pii v)
{
	if(x==y) {t[p]=max(t[p],v);return;}
	D;
	if(mid>=w) cng(L,w,v);
	else cng(R,w,v);
	t[p]=max(t[p*2],t[p*2+1]);
}

int main()
{
	scanf("%lld%lld%lld",&h,&w,&n);
	rep(i,1,n) scanf("%lld%lld",&a[i].first,&a[i].second);
	a[++n].first=1,a[n].second=1;
	a[++n].first=h,a[n].second=w;
	sort(a+1,a+n+1);
	rep(i,1,n)
	{
		pii j=fnd(X,1,a[i].second);
		ll p=(a[i].first-1)*w+a[i].second;
		ls[p]=j.second,j.second=p;
		if(p==1||p==h*w) j.first+=1e9;
		else j.first++;
		cng(X,a[i].second,j);
	}
	printf("%lld\n",fnd(X,1,w).first-(ll)2e9);
	for(ll i=fnd(X,1,w).second;i!=1;i=ls[i])
	{
		ll ii=ls[i];
		while((ii-1)/w!=(i-1)/w) d[++g]=1,ii+=w;
		while(ii!=i) d[++g]=0,ii++;
	}
	per(i,1,g) printf(d[i]?"D":"R");
	return 0;
}

Submission Info

Submission Time
Task F - Gather Coins
User Aje453_Revival
Language C++ 20 (gcc 12.2)
Score 500
Code Size 1410 Byte
Status AC
Exec Time 203 ms
Memory 30876 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%lld%lld%lld",&h,&w,&n);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:40:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |         rep(i,1,n) scanf("%lld%lld",&a[i].first,&a[i].second);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 44
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 03_random3_06.txt, 03_random3_07.txt, 03_random3_08.txt, 03_random3_09.txt, 04_full_00.txt, 04_full_01.txt, 04_full_02.txt, 05_handmade_00.txt, 05_handmade_01.txt, 05_handmade_02.txt, 05_handmade_03.txt, 05_handmade_04.txt, 05_handmade_05.txt, 05_handmade_06.txt, 05_handmade_07.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3720 KB
00_sample_01.txt AC 1 ms 3684 KB
00_sample_02.txt AC 1 ms 3824 KB
01_random_00.txt AC 175 ms 29068 KB
01_random_01.txt AC 168 ms 28224 KB
01_random_02.txt AC 155 ms 27624 KB
01_random_03.txt AC 87 ms 17240 KB
01_random_04.txt AC 33 ms 11996 KB
01_random_05.txt AC 197 ms 30612 KB
01_random_06.txt AC 194 ms 30816 KB
01_random_07.txt AC 196 ms 30640 KB
01_random_08.txt AC 192 ms 30876 KB
01_random_09.txt AC 199 ms 30816 KB
02_random2_00.txt AC 186 ms 30764 KB
02_random2_01.txt AC 191 ms 30576 KB
02_random2_02.txt AC 194 ms 30536 KB
02_random2_03.txt AC 190 ms 30532 KB
02_random2_04.txt AC 194 ms 30620 KB
02_random2_05.txt AC 198 ms 30664 KB
02_random2_06.txt AC 201 ms 30648 KB
02_random2_07.txt AC 200 ms 30816 KB
02_random2_08.txt AC 198 ms 30676 KB
02_random2_09.txt AC 203 ms 30644 KB
03_random3_00.txt AC 152 ms 30672 KB
03_random3_01.txt AC 151 ms 30636 KB
03_random3_02.txt AC 151 ms 30756 KB
03_random3_03.txt AC 151 ms 30756 KB
03_random3_04.txt AC 151 ms 30536 KB
03_random3_05.txt AC 152 ms 30644 KB
03_random3_06.txt AC 151 ms 30808 KB
03_random3_07.txt AC 152 ms 30620 KB
03_random3_08.txt AC 153 ms 30640 KB
03_random3_09.txt AC 153 ms 30868 KB
04_full_00.txt AC 16 ms 6480 KB
04_full_01.txt AC 65 ms 14240 KB
04_full_02.txt AC 30 ms 8728 KB
05_handmade_00.txt AC 178 ms 30860 KB
05_handmade_01.txt AC 177 ms 30648 KB
05_handmade_02.txt AC 147 ms 30668 KB
05_handmade_03.txt AC 160 ms 22664 KB
05_handmade_04.txt AC 180 ms 30864 KB
05_handmade_05.txt AC 158 ms 29064 KB
05_handmade_06.txt AC 105 ms 20896 KB
05_handmade_07.txt AC 15 ms 6888 KB


2025-03-05 (Wed)
18:08:30 +00:00