3 条题解

  • 1
    @ 2023-11-26 10:00:15

    题目说要用容器,可我想不明白用容器怎么做,数组不是更简单吗?但碍于题解中已经有数组的题解了,所以我之能用容器了,下面是AC Code

    #include <bits/stdc++.h>
    using namespace std;
    vector<long long> v;
    int n;
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            long long x;
            cin >> x;
            v.push_back(x);
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                if (v[i] == v[j])
                {
                    cout << 1 << endl;
                    return 0;
                }
            }
        }
        cout << 0 << endl;
        return 0;
    }
    
    • 0
      @ 2024-3-9 20:08:05

      蒟蒻狐在这来个map不在意吧~ 需要搞那烦人的iterator 开long long,不然我怕过不了

      #include <bits/stdc++.h>
      using namespace std;
      map<string,long long> v;
      map<string,long long>::iterator it;
      int n,q,a,x;
      string s,s2;
      int main(){
      	cin>>n;
      	for(int i=1;i<=n;i++){
      		cin>>s;
      		v[s]++;
      	}
      	for(it=v.begin();it!=v.end();it++){
      		if(it->second>1){
      			cout<<1;
      			return 0;
      		}
      	}
      	cout<<0;
      	return 0;
      }
      
      • 0
        @ 2023-2-24 20:23:09
        //嗯确认应该没人发题解
        #include <iostream>
        using namespace std;
        int main()
        {
            int n;
            cin >> n;
            long long a[n + 5];
            for (int i = 1; i <= n; i++)
            {
                cin >> a[i];
                if (i > 1)
                {
                    for (int j = i - 1; j >= 1; j--)
                    {
                        if (a[i] == a[j])
                        {
                            cout << 1;
                            return 0;
                        }
                    }
                }
            }
            cout << 0;
            return 0;
        }
        
        • 1

        信息

        ID
        504
        时间
        1000ms
        内存
        128MiB
        难度
        3
        标签
        递交数
        46
        已通过
        27
        上传者