2 条题解
-
0
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,f; signed main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>a>>b>>c>>d>>e>>f; if(a==c)cout<<e<<' '; else if(c==e)cout<<a<<' '; else cout<<c<<' '; if(b==d)cout<<f<<'\n'; else if(d==f)cout<<b<<'\n'; else cout<<d<<'\n'; return 0; } -
0
没想到吧,红题我也要写题解!
思路
注意到一个矩阵的四个顶点的横纵坐标一定是两两重复的,不妨进行枚举,找到是缺少了那个顶点,输出坐标即可。
但是这还是太屎了,有没有更好的解法?
答案肯定是有的,我们只需要开一个数组存储哪些坐标点出现过,输出那些只出现过一次的坐标即可。
AC代码
#include<bits/stdc++.h> using namespace std; int cnt[300]; int main() { int a,b,c,d,e,f;scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f); cnt[a+100]++; cnt[c+100]++; cnt[e+100]++; if(cnt[a+100]==1)printf("%d ",a); if(cnt[c+100]==1)printf("%d ",c); if(cnt[e+100]==1)printf("%d ",e); memset(cnt,0,sizeof(cnt)); cnt[b+100]++; cnt[d+100]++; cnt[f+100]++; if(cnt[b+100]==1)printf("%d ",b); if(cnt[d+100]==1)printf("%d ",d); if(cnt[f+100]==1)printf("%d ",f); return 0; }
- 1
信息
- ID
- 12439
- 时间
- 2000ms
- 内存
- 1024MiB
- 难度
- 6
- 标签
- 递交数
- 15
- 已通过
- 12
- 上传者