Submission #35325756
Source Code Expand
/* Generated by powerful Codeforces Tool
* You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
* Author: shuger
* Time: 2022-10-01 23:26:16
**/
#include <stdio.h>
#include <string>
#include <utility>
#include <algorithm>
#include <ctime>
#include <iostream>
using namespace std;
#define ll long long
#define P pair
#define mkp(a,b) make_pair(a,b)
#define fir first
#define sec second
//#define debug
bool _t(char c) {
return ((c<='9' && c>='0') || c=='-');
}
template <typename Tp>
void read(Tp &_a) {
_a=0;
int flg=1;
char c;
while(!_t(c=getchar())) ;
if(c=='-') flg=-1,c=getchar();
_a=c-'0';
while((c=getchar())!='-' && _t(c)) _a=_a*10+c-'0';
_a*=flg;
}
template <typename Tp>
void write(Tp _a) {
char s[45]={};
int cnt=0;
if(_a<0) putchar('-'),_a=-_a;
if(_a==0) {
putchar('0');
return ;
}
while(_a) s[++cnt]=_a%10+48,_a/=10;
while(cnt) putchar(s[cnt--]);
}
bool dp[10005][2]={};
string str[10005][2]={};
int a[105][2]={};
void wk() {
int n,s;
read(n),read(s);
dp[0][0]=true;
for(int i=1;i<=n;++i) {
for(int j=0;j<=1;++j) read(a[i][j]);
}
for(int i=1;i<=n;++i) {
for(int j=0;j<=s;++j) dp[j][i&1]=false,str[j][i&1]="";
for(int j=0;j<=1;++j) {
for(int k=a[i][j];k<=s;++k) {
if(dp[k-a[i][j]][1-(i&1)]) {
dp[k][i&1]=true;
str[k][i&1]=str[k-a[i][j]][1-(i&1)]+(j==0?"H":"T");
}
}
}
}
if(dp[s][n&1]) {
printf("Yes\n");
cout << str[s][n&1];
}
else printf("No\n");
}
signed main() {
#ifdef debug
double st=clock();
#endif
int t=1;
// read(t);
while(t--) wk();
#ifdef debug
freopen("time_op.txt","w",stdout);
printf("%.2lf ms",clock()-st);
#endif
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Flip and Adjust |
| User | shuger |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 2007 Byte |
| Status | AC |
| Exec Time | 46 ms |
| Memory | 6528 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, handmade_00.txt, handmade_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 9 ms | 4080 KiB |
| example_01.txt | AC | 4 ms | 4084 KiB |
| handmade_00.txt | AC | 14 ms | 4656 KiB |
| handmade_01.txt | AC | 40 ms | 5956 KiB |
| test_00.txt | AC | 18 ms | 4832 KiB |
| test_01.txt | AC | 4 ms | 4044 KiB |
| test_02.txt | AC | 8 ms | 4356 KiB |
| test_03.txt | AC | 17 ms | 4668 KiB |
| test_04.txt | AC | 11 ms | 4000 KiB |
| test_05.txt | AC | 15 ms | 4748 KiB |
| test_06.txt | AC | 20 ms | 5100 KiB |
| test_07.txt | AC | 19 ms | 5088 KiB |
| test_08.txt | AC | 15 ms | 4652 KiB |
| test_09.txt | AC | 17 ms | 4728 KiB |
| test_10.txt | AC | 11 ms | 4392 KiB |
| test_11.txt | AC | 8 ms | 4304 KiB |
| test_12.txt | AC | 20 ms | 4668 KiB |
| test_13.txt | AC | 4 ms | 4096 KiB |
| test_14.txt | AC | 10 ms | 4376 KiB |
| test_15.txt | AC | 31 ms | 5480 KiB |
| test_16.txt | AC | 4 ms | 4044 KiB |
| test_17.txt | AC | 9 ms | 4316 KiB |
| test_18.txt | AC | 29 ms | 5268 KiB |
| test_19.txt | AC | 40 ms | 6356 KiB |
| test_20.txt | AC | 15 ms | 4632 KiB |
| test_21.txt | AC | 46 ms | 6528 KiB |