D. Time to Run-1301(构造)
程序员文章站
2022-07-12 13:50:54
...
总结
构造一个最大路线数量,然后模拟,注意宽跟列为1的情况
void f1(int n,int m,int k)
{
vector<pair<int,char> >vec;
for(int i=0; i<m-1&&k; i++)
{
if(k)
vec.pb( {1,'R'} ),k--;
if(k&&n-1)
vec.pb( {min(k,n-1),'D'} ),k-=min(k,n-1);
if(k&&n-1)
vec.pb( {min(k,n-1),'U'} ),k-=min(k,n-1);
}
if(k&&m-1)
vec.pb( {min(k,m-1),'L'} ),k-=min(k,m-1);
for(int i=1; i<n&&k; i++)
{
if(k)
vec.pb( {1,'D'} ),k--;
if(k&&m-1)
vec.pb( {min(k,m-1), 'R'} ),k-=min(k,m-1);
if(k&&m-1)
vec.pb( {min(k,m-1), 'L'} ),k-=min(k,m-1);
}
if(k)
vec.pb( {k,'U'} );
cout<<"YES"<<endl;
cout<<vec.size()<<endl;
for(int i=0; i<vec.size(); i++)
{
cout<<vec[i].F<<" "<<vec[i].S<<endl;
}
}
signed main()
{
IOS;
//file();
int n,m,k;
cin>>n>>m>>k;
if(4*n*m-2*n-2*m<k)
cout<<"NO"<<endl;
else
f1(n,m,k);
return 0;
}
上一篇: 按照数组中的对象属性进行比较排序
下一篇: HK Missing Numbers
推荐阅读
-
Codeforces Round #619 (Div. 2) D. Time to Run
-
F. Nastya and Time Machine(搜索 构造)
-
D. Time to Run-1301(构造)
-
D. Make Them Equal(思维+构造)
-
Moment.js 如何使用 Epoch Time 来构造对象
-
Moment.js 如何使用 Epoch Time 来构造对象
-
D. Pair of Topics(构造+排序+优化处理)Codeforces Round #627 (Div. 3)
-
Codeforces Raif Round 1 (Div. 1 + Div. 2) D. Bouncing Boomerangs(思维+构造)
-
Educational Codeforces Round 55 (Rated for Div. 2) D. Maximum Diameter Graph (构造图)
-
Codeforces Round #630 (Div. 2) D. Walk on Matrix(思维+构造)