Acwing第 24 场周赛【完结】
24 AcWing 周赛 完结
2023-09-11 14:15:52 时间
打的很烂T2调试了好久,AK了,但是时间有点长,看来还得努力。
4070. 异或【签到】
https://www.acwing.com/problem/content/4073/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5*2+10;
int n,m,t,a[N];
int main(void)
{
cin>>n;
int ans=-1e9;
for(int i=0;i<n;i++) cin>>a[i],ans=max(ans,a[i]);
int temp=ans^a[n-1];
cout<<temp<<endl;
return 0;
}
4071. 国际象棋【暴力枚举】
https://www.acwing.com/problem/content/4074/
#include<bits/stdc++.h>
using namespace std;
int a[15][15],x,y,xx,yy;
int dx[8]={-2,-2,-1,-1,1,1,2,2};
int dy[8]={-1,1,-2,2,-2,2,-1,1};
string s1,s2;
int get(char c)
{
if(c<='9') return c-'1';
else return c-'a';
}
void init()
{
for(int i=0;i<8;i++) a[x][i]=1;//攻击的位置
for(int i=0;i<8;i++) a[i][y]=1;
a[x][y]=-1;//标记棋子在哪里
a[xx][yy]=-1;
for(int i=0;i<8;i++)
{
int tempx=xx+dx[i];
int tempy=yy+dy[i];
if(tempx<0||tempx>=8) continue;
if(tempy<0||tempy>=8) continue;
a[tempx][tempy]=1;
}
}
bool check(int x,int y)
{
if(a[x][y]) return false;//该位置有棋子或者是别人的攻击范围内
for(int i=0;i<8;i++)
{
int tempx=x+dx[i];
int tempy=y+dy[i];
if(tempx<0||tempx>=8) continue;
if(tempy<0||tempy>=8) continue;
if(a[tempx][tempy]==-1) return false;//攻击到了其他棋子
}
return true;
}
int main(void)
{
cin>>s1>>s2;
y=get(s1[0]),x=get(s1[1]);
yy=get(s2[0]),xx=get(s2[1]);
init();
int cnt=0;
for(int i=0;i<8;i++)
for(int j=0;j<8;j++)
if(check(i,j)) cnt++;
cout<<cnt<<endl;
return 0;
}
4072. 习题册【模拟 小根堆】
https://www.acwing.com/problem/content/description/4075/
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
const int N=1e5*2+10;
struct node{int p,a,b;}temp,s[N];
priority_queue<PII,vector<PII>,greater<PII> >heap[5];
int n,m;
unordered_map<int,int>mp;
int main(void)
{
cin>>n;
for(int i=0;i<n;i++) scanf("%d",&s[i].p);
for(int i=0;i<n;i++) scanf("%d",&s[i].a),heap[s[i].a].push({s[i].p,i});
for(int i=0;i<n;i++) scanf("%d",&s[i].b),heap[s[i].b].push({s[i].p,i});
scanf("%d",&m);
for(int i=0;i<m;i++)
{
int x; scanf("%d",&x);
while(heap[x].size())
{
auto t=heap[x].top();
int u=t.second;
if(mp[u]) heap[x].pop();
else break;
}
if(heap[x].size())
{
auto t=heap[x].top();
int w=t.first;
int u=t.second;
printf("%d ",w);
mp[u]=1; heap[x].top();//标记为已经买走了
}else printf("-1 ");
}
return 0;
}
相关文章
- 【网络流24题】运输问题(费用流)
- 《惢客创业日记》2019.01.24(周四)小米产品经理给我的启发
- Adecco调查24国1.7万求职者,迄今最全面研究报告,发布招聘、应聘新趋势
- 24条 Docker 建议
- 少儿学编程系列 --- 使用python程序暴力求解:数学游戏 24 Game的答案
- 第24周一
- 第24周四经验感受想法
- Qt编写可视化大屏电子看板系统24-模块2当月计划
- Qt编写安防视频监控系统24-自定义悬浮条
- mysql5.7.24启动报错:ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
- 【历史上的今天】2 月 24 日:乔布斯生日;苹果推出 Thunderbolt 接口;WhatsApp 创始人诞生
- 【历史上的今天】2 月 24 日:乔布斯出生;苹果推出 Thunderbolt 接口;WhatsApp 创始人诞生
- 7月24日云栖精选夜读:未来的超级智能网络攻击需要AI竞技俱乐部来拯救
- 王道数据结构 (24) 顺序表的基本操作——插入
- msp430入门编程24
- 24深入理解C指针之---指针和数组