首页 > 其他分享 >Codeforces Round #401 (Div. 2) 题解 (待续)

Codeforces Round #401 (Div. 2) 题解 (待续)

时间:2022-10-24 19:37:45浏览次数:57  
标签:待续 ch return int 题解 ll Codeforces long define


A Shell Game

#include<bits/stdc++.h>
using namespace std;
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
For(j,m-1) cout<<a[i][j]<<' ';\
cout<<a[i][m]<<endl; \
}
#pragma
#define
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
int main()
{
// freopen("A.in","r",stdin);
// freopen(".out","w",stdout);
int n=read(),x=read();
n%=6;
while(n>=1) {
if (n&1) {
if(x==1) x=0;
else if (x==0) x=1;
} else {
if(x==1) x=2;
else if (x==2) x=1;
}--n;
}

cout<<x<<endl;
return 0;
}

B Game of Credit Cards

#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p])
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
For(j,m-1) cout<<a[i][j]<<' ';\
cout<<a[i][m]<<endl; \
}
#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
char s[10000],s2[10000];
multiset<int> S,S2;
int main()
{
// freopen("B.in","r",stdin);
// freopen(".out","w",stdout);

int n=read();
cin>>s;
Rep(i,n) S.insert(s[i]);
cin>>s2;
Rep(i,n) S2.insert(s2[i]);
int t=0;
Rep(i,n) {
multiset<int>::iterator p=S.upper_bound(s2[i]);
if (p!=S.begin()) {
--p;
++t;
S.erase(p);
}
}
cout<<n-t<<endl;
t=0;
Rep(i,n) {
multiset<int>::iterator p=S2.upper_bound(s[i]);
if (p!=S2.end()) {
++t;
S2.erase(p);
}
}

cout<<t<<endl;

return 0;
}

C Alyona and Spreadsheet

#include<bits/stdc++.h>
using namespace std;
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
For(j,m-1) cout<<a[i][j]<<' ';\
cout<<a[i][m]<<endl; \
}
#pragma
#define
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
#define
int l[MAXN];
int up[MAXN],u[MAXN]={};
int main()
{
// freopen("C.in","r",stdin);
// freopen(".out","w",stdout);
int n=read(),m=read();
For(i,n+1) {
For(j,m) {
int p=0;
if (i<=n) p=read();
if (up[j]<=p) {
up[j]=p;
} else {
l[u[j]+1]=max(i-1,l[u[j]+1]);
up[j]=p;
u[j]=i-1;
}
}
}
Fork(i,2,n) l[i]=max(l[i],l[i-1]);

int k=read();
while(k--) {
int L=read(),R=read();
if (l[L]>=R) puts("Yes");
else puts("No");
}
return 0;
}

D Cloud of Hashtags

#include<bits/stdc++.h>
using namespace std;
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
For(j,m-1) cout<<a[i][j]<<' ';\
cout<<a[i][m]<<endl; \
}
#pragma
#define
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
int n;
string s[512345];
int main()
{
// freopen("D.in","r",stdin);
// freopen(".out","w",stdout);
cin>>n;
For(i,n) cin>>s[i];
ForD(i,n-1) {
int len=min(s[i+1].length(),s[i].length());
int fl=0;
Rep(j,len) {
if (s[i][j]<s[i+1][j]) {
fl=1;break;
}
if (s[i][j]>s[i+1][j]) {
s[i]=s[i].substr(0,j); fl=-1;break;
}
}
if (!fl) {
s[i]=s[i].substr(0,len);
}
}
For(i,n) cout<<s[i]<<endl;


return 0;
}


标签:待续,ch,return,int,题解,ll,Codeforces,long,define
From: https://blog.51cto.com/u_15724837/5791023

相关文章

  • April Fools Contest 2017 题解
    ANumbersJokeJoke数列,OEIS#include<bits/stdc++.h>usingnamespacestd;#define#define#define#define#define#define#define#define#define#define#define#define#define......
  • Codeforces Round #402 (Div. 1) 题解(待续)
    AStringGame#include<bits/stdc++.h>usingnamespacestd;#define#define#define#define#define#define#define#define#define#define#define#define#define#define#defin......
  • BZOJ 4747-4749题解 Usaco2016 Dec
    BZOJ4747:[Usaco2016Dec]CountingHaybales给出N(1≤N≤100,000)个数,和Q(1≤Q≤100,000)个询问。每个询问包含两个整数A,B(0≤A≤B≤1,000,000,000)。对于每个询问,给出数值......
  • Codeforces Round #395 (Div. 1) 题解
    ATimofeyandatree#include<bits/stdc++.h>usingnamespacestd;#define#define#define#define#define#define#define#define#define#define#define#define#define#defin......
  • Spring常见问题解决办法汇总
     解决Theprefix'context'forelement'context:component-scan'isnotbound<beansxmlns="http://www.springframework.org/schema/beans"   xmlns:xsi="http://w......
  • BSOJ7075题解
    感觉这一类DP至少不应该被叫做“LCS模型”,本质应该是其他的东西......先来考虑经典的LCS:\(dp[n][m]\)表示\(S[n]\)和\(T[m]\)匹配上的最长的长度。那么我们不妨......
  • GCJ 2017 R2 题解(待续)
    ProblemA.FreshChocolateProblemYouarethepublicrelationsmanagerforachocolatemanufacturer.Unfortunately,thecompany’simagehassufferedbecausecus......
  • 北方大学 ACM 多校训练赛 第四场 题解
    A.恶魔包毁灭世界已知一张二分图,问哪些边是二分图的可行边?先跑最小流,再把残余网络建图,几个重要结论是:·最小割的可行边(满流&&2点不在一个SCC中)·最小割的必行边(可行......
  • GCJ Qualification Round 2017 题解(部分)
    OversizedPancakeFlipper#include<bits/stdc++.h>usingnamespacestd;#define#define#define#define#define#define#define#define#define#define#define#define#define#......
  • 长安大学第二届ACM程序设计竞赛校赛 题解
    ACountCircles描述StupidAguinfeelsconfusedwhilereading.Thebookshowsfollowingequations:6=9,8=1010,144=75,690=801StupidAguindoesn’tknow......