Codeforces Round #713 (Div. 3)题解

Problem - A - Codeforces

题目大意:给你一个数组,只由两个数字组成,其中一个数字只出现了一次,求该数字出现的下标位置.

思路:直接模拟

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
#define rep(x,y,z) for(int x=y; x<=z; ++x)
#define dec(x,y,z) for(int x=y; x>=z; --x)
int t, n;
set<int>s;
int a[105];
int main(){
   
    cin>>t;
    int cur;
    while(t--){
   
        s.clear();
        cin>>n;
        rep(i,1,n){
   
            cin>>a[i];
            if(s.count(a[i]))cur = a[i];
            else s.insert(a[i]);
        }
        rep(i,1,n){
   
            if (a[i] != cur){
   
                cout << i << endl;
            }
        }
    }

    return 0;
}

Problem - B - Codeforces

题目大意:在一张地图上给定两个"*",添加两个’’*“来使得所有的”*"凑成最小的矩形.

思路:直接模拟,如果两个"*"的不在一条直线上,那么另外两点只需要组合一下当前点的x,y.如果两点处在同一直线上,那么直接枚举一下移动一步的情况.

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
#define rep(x,y,z) for(int x=y; x<=z; ++x)
#define dec(x,y,z) for(int x=y; x>=z; --x)
char m[405][405];
int t, n;
int x[2], y[2];
int main(){
   
    cin>>t;
    while(t--){
   
        cin>>n;
        rep(i,1,n){
   
            rep(j,1,n){
   
                cin>>m[i][j];
            }
        }
        int index= 0;
        rep(i,1,n){
   
            rep(j,1,n){
   
                if (m[i][j] == '*'){
   
                    x[index] = i;
                    y[index] = j
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值