T1
| |
| |
| |
| #include<bits/stdc++.h> |
| #define int long long |
| using namespace std; |
| |
| int k,n,ans; |
| int a[31][31]; |
| |
| signed main(){ |
| ios::sync_with_stdio(0); |
| cin>>k>>n; |
| for(int i=1;i<=k;i++) |
| for(int j=1;j<=n;j++) |
| cin>>a[i][j]; |
| for(int i=1;i<=n;i++){ |
| for(int j=i+1;j<=n;j++){ |
| bool f1=1,f2=1; |
| for(int x=1;x<=k;x++){ |
| int p1,p2; |
| for(int y=1;y<=n;y++) if(a[x][y]==i) p1=y; |
| for(int y=1;y<=n;y++) if(a[x][y]==j) p2=y; |
| if(p1>p2){ f1=0; break; } |
| } |
| for(int x=1;x<=k;x++){ |
| int p1,p2; |
| for(int y=1;y<=n;y++) if(a[x][y]==i) p1=y; |
| for(int y=1;y<=n;y++) if(a[x][y]==j) p2=y; |
| if(p2>p1){ f2=0; break; } |
| } |
| if(f1||f2) |
| |
| ans++; |
| } |
| } |
| cout<<ans; |
| return 0; |
| } |
T2
| |
| |
| |
| |
| |
| #include<bits/stdc++.h> |
| #define int long long |
| using namespace std; |
| |
| int vis[131],flag[131]; |
| char guess[31][31],ans[31][31]; |
| |
| int get_green(){ |
| int cnt=0; |
| for(int i=0;i<3;i++) |
| for(int j=0;j<3;j++) |
| if(guess[i][j]==ans[i][j]) |
| cnt++,flag[guess[i][j]]++; |
| return cnt; |
| } |
| int get_yellow(){ |
| int cnt=0; |
| for(int i=0;i<3;i++){ |
| for(int j=0;j<3;j++){ |
| char now=guess[i][j]; |
| |
| int s1=0,s2=0; |
| for(int x=0;x<3;x++) |
| for(int y=0;y<3;y++) |
| s1+=(guess[x][y]==now); |
| for(int x=0;x<3;x++) |
| for(int y=0;y<3;y++) |
| s2+=(ans[x][y]==now); |
| |
| if(s1&&s2&&!vis[now]){ |
| |
| cnt+=min(s2-flag[now],s1-flag[now]),vis[now]=1; |
| |
| } |
| } |
| } |
| return cnt; |
| } |
| |
| signed main(){ |
| ios::sync_with_stdio(0); |
| for(int i=0;i<3;i++) |
| for(int j=0;j<3;j++) |
| cin>>guess[i][j]; |
| for(int i=0;i<3;i++) |
| for(int j=0;j<3;j++) |
| cin>>ans[i][j]; |
| cout<<get_green()<<'\n'; |
| cout<<get_yellow(); |
| return 0; |
| } |
T3
| |
| |
| |
| |
| #include<bits/stdc++.h> |
| #define int long long |
| using namespace std; |
| |
| int s,now=1; |
| deque<int> dq; |
| |
| signed main(){ |
| ios::sync_with_stdio(0); |
| cin>>s; |
| while(s--){ |
| char op1,op2; int k; |
| cin>>op1>>op2; |
| if(op1=='A'){ |
| if(op2=='L') dq.push_front(now++); |
| else dq.push_back(now++); |
| } |
| else{ |
| cin>>k; |
| if(op2=='L'){ |
| for(int i=1;i<=k;i++) |
| if(!dq.empty()) dq.pop_front(); |
| } |
| else{ |
| for(int i=1;i<=k;i++) |
| if(!dq.empty()) dq.pop_back(); |
| } |
| } |
| } |
| while(!dq.empty()) |
| cout<<dq.front()<<'\n',dq.pop_front(); |
| return 0; |
| } |
T4
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #include<bits/stdc++.h> |
| using namespace std; |
| |
| int n,p,cur; |
| bool vis[10031]; |
| char s[10031],sorted[10031],ans[10031]; |
| |
| int main(){ |
| cin>>n; |
| for(int i=1;i<=n;i++) cin>>s[i],sorted[i]=s[i]; |
| cin>>p; |
| sort(sorted+1,sorted+n+1); |
| |
| ans[1]=s[p]; |
| for(int i=1;i<=n;i++) |
| if(sorted[i]==s[p]){ |
| cur=i; break; |
| } |
| |
| for(int i=n;i>=2;i--){ |
| ans[i]=s[cur],vis[cur]=1; |
| for(int j=n;j>=1;j--) |
| if(sorted[j]==s[cur]&&!vis[j]){ |
| cur=j; break; |
| } |
| } |
| |
| for(int i=1;i<=n;i++) cout<<ans[i]; |
| return 0; |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】