-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
#include <cstring> | ||
#define ll long long | ||
using namespace std; | ||
int const N=1000+10,mod=998244353; | ||
int n,kk; | ||
int poss[N]; | ||
bool vis[N]; | ||
int main(){ | ||
cin>>n>>kk; | ||
char c;int k; | ||
fill(poss,poss+N,kk); | ||
memset(vis,0,N); | ||
for(int i=0;i<kk;++i){ | ||
cin>>c>>k; | ||
if(c=='L'){ | ||
for(int j=1;j<=k;++j)--poss[j]; | ||
}else{ | ||
for(int j=n;j>=k;--j)--poss[j]; | ||
} | ||
vis[k]=1; | ||
} | ||
ll ans=1; | ||
for(int i=1;i<=n;++i)if(!vis[i])ans=(ans*poss[i])%mod; | ||
cout<<ans<<'\n'; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); | ||
using namespace std; | ||
int const N=2000+10; | ||
int n; | ||
int a[N],b[N],c[N],ans[N]; | ||
int main(){ | ||
Hirasawa_Yui_My_Wife | ||
cin>>n; | ||
for(int i=0;i<n;++i)cin>>a[i]; | ||
for(int i=0;i<n;++i)cin>>b[i]; | ||
sort(b,b+n); | ||
int goal,k=0;bool flag; | ||
for(int i=0;i<n;++i){ | ||
goal=a[0]^b[i]; | ||
for(int i=0;i<n;++i)c[i]=a[i]^goal;//a[i]^c[i]=goal | ||
sort(c,c+n); | ||
flag=1; | ||
for(int i=0;i<n;++i)if(b[i]!=c[i]){flag=0;break;} | ||
if(flag)ans[k++]=goal; | ||
} | ||
sort(ans,ans+k); | ||
k=unique(ans,ans+k)-ans; | ||
cout<<k<<'\n'; | ||
for(int i=0;i<k;++i)cout<<ans[i]<<'\n'; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <iostream> | ||
#include <cstring> | ||
#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); | ||
using namespace std; | ||
int const N=2e5+10; | ||
int n,m,a[N],cl[N],cr[N],li=0,ri=0,ans=0; | ||
bool vis[N]; | ||
int main(){ | ||
Hirasawa_Yui_My_Wife | ||
cin>>n>>m; | ||
for(int i=0;i<n+m;++i)cin>>a[i]; | ||
memset(vis,0,N); | ||
for(int i=0;i<n+m;++i){ | ||
if(vis[i])continue; | ||
bool l=0,r=0; | ||
int cur=i,len=0; | ||
while(!vis[cur]){ | ||
vis[cur]=1; | ||
++len; | ||
if(cur<n)l=1; | ||
else r=1; | ||
cur=a[cur]-1; | ||
} | ||
if(len==1)continue; | ||
if(l&&r)ans+=len-1; | ||
else if(l)cl[li++]=len; | ||
else cr[ri++]=len; | ||
} | ||
for(int i=0;i<li;++i)ans+=cl[i]; | ||
for(int i=0;i<ri;++i)ans+=cr[i]; | ||
ans+=abs(li-ri); | ||
cout<<ans<<'\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#define ll long long | ||
#define Hirasawa_Yui_My_Wife ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); | ||
using namespace std; | ||
int const N=3060;//I want a 3060 QAQ | ||
ll const INF=1ll<<62; | ||
struct reader{ | ||
int arr,time;//arrive time and reading time | ||
bool operator<(reader o){//other | ||
return arr==o.arr?time<o.time:arr<o.arr; | ||
} | ||
inline int end(){ | ||
return arr+time; | ||
} | ||
}pro[N],stu[N]; | ||
ll dp[N][N][2]; | ||
int n,m; | ||
//dp[i][j] means the minimum time that first i pros and first j stus finished the book(redundant stus are deleted) | ||
//dp[i][j][0] means the last reader is student, dp[i][j][1] means that is a pro. | ||
int main(){ | ||
Hirasawa_Yui_My_Wife | ||
cin>>n>>m; | ||
//input | ||
for(int i=1;i<=n;++i)cin>>pro[i].arr>>pro[i].time; | ||
for(int i=1;i<=m;++i)cin>>stu[i].arr>>stu[i].time; | ||
//sort by arrive time | ||
sort(pro+1,pro+n+1); | ||
sort(stu+1,stu+m+1); | ||
int k=0; | ||
//delete redundant students | ||
for(int i=1;i<=m;++i){//k is always less than i | ||
while(k&&stu[k].time<=stu[i].time){//stu[k] arrives before stu[i], so if stu[k] need less time, he/she can always complete the book when stu[i] is reading. | ||
k--; | ||
} | ||
stu[++k]=stu[i]; | ||
} | ||
//there are n pros and k stus now | ||
for(int i=0;i<=n;++i)for(int j=0;j<=k;++j)dp[i][j][0]=dp[i][j][1]=INF; | ||
dp[0][0][0]=dp[0][0][1]=0; | ||
for(int i=0;i<=n;++i){ | ||
for(int j=0;j<=k;++j){ | ||
dp[i][j+1][0]=min(dp[i][j+1][0], | ||
min(max(dp[i][j][0],(ll)stu[j+1].end()), | ||
max(dp[i][j][1],(ll)stu[j+1].arr)+(ll)stu[j+1].time)); | ||
dp[i+1][j][1]=min(dp[i+1][j][1], | ||
max(min(dp[i][j][0],dp[i][j][1]),(ll)pro[i+1].arr) | ||
+(ll)pro[i+1].time); | ||
} | ||
} | ||
cout<<min(dp[n][k][0],dp[n][k][1])<<'\n'; | ||
} |