3 条题解

  • 0
    @ 2021-12-20 20:01:25
    
    #include <iostream>
    #include <map>
    #include <algorithm>
    using namespace std;
    const int maxn = 100000;
    int main()
    {
        map<int, int> map;
        int n;
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            int a, b;
            cin >> a >> b;
            if (map.find(a) != map.end())
            {
                map[a]++;
            }
            else
            {
                map.insert({a, 1});
            }
        }
        int ans = count_if(map.begin(), map.end(), [=](const pair<int, int> pair)
                           { return pair.second == 2; });
    
        cout << ans << endl;
        return 0;
    }
    
    
  • 0

    #include <iostream>
    #include <cstdio>
    #include <map>
    using namespace std;

    int main() {
    // freopen( "H:\命题\0 网站\3\Test\Input\input4.txt","r",stdin);
    // freopen("H:\命题\0 网站\3\Test\Output\output4.txt","w",stdout);
    int n;
    cin>>n;
    multimap<int,int> map;
    for(int i=0; i<n; i++) {
    int a,b;
    cin>>a>>b;
    map.insert((pair<int,int>(a,b)));
    }
    multimap<int,int>::iterator it=map.begin();
    int ans=0;
    while(it!=map.end()) {
    int a=it->first, n=0;
    while(it!=map.end() && it->first==a) {
    n++;
    it++;
    }
    if(n==2) ans++;
    }
    cout<<ans<<endl;
    return 0;
    }

  • 0
    @ 2018-12-07 16:39:51
    #include <iostream>
    #include <cstdio>
    #include <map>
    using namespace std;
    
    int main() {
    //  freopen(  "H:\\命题\\0 网站\\3\\Test\\Input\\input4.txt","r",stdin);
    //  freopen("H:\\命题\\0 网站\\3\\Test\\Output\\output4.txt","w",stdout);
        int n;
        cin>>n;
        multimap<int,int> map;
        for(int i=0; i<n; i++) {
            int a,b;
            cin>>a>>b;
            map.insert((pair<int,int>(a,b)));
        }
        multimap<int,int>::iterator it=map.begin();
        int ans=0;
        while(it!=map.end()) {
            int a=it->first, n=0;
            while(it!=map.end() && it->first==a) {
                n++;
                it++;
            }
            if(n==2) ans++;
        }
        cout<<ans<<endl;
        return 0;
    }
    
  • 1

信息

难度
8
分类
(无)
标签
递交数
881
已通过
125
通过率
14%
被复制
11
上传者