问问大佬们(编译可以,洛谷不行)

#include <bits/stdc++.h>
using namespace std;
map<pair<char,char>,bool>m;
int main(){
    int n;
    cin>>n;
    int sum=0;
    while(n--){
        string x;
        cin>>x;
        if(!m.count(make_pair<char,char>(x[0],x[1]))){
            m[make_pair<char,char>(x[0],x[1])]=1;
            sum++;
        }
    }
    cout<<52-sum;
}

https://www.luogu.com.cn/problem/P11227

2 条评论

  • 我都看不懂你写的啥

  • @ 2024-10-28 13:11:05

    洛谷反馈

    编译信息
    编译失败
    /tmp/compiler_a5coyl4x/src: 在函数‘int main()’中:
    /tmp/compiler_a5coyl4x/src:11:45: 错误:cannot bind rvalue reference of type ‘char&&’ to lvalue of type ‘__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type’ {aka ‘char’}
       11 |   if(!m.count(make_pair<char,char>(x[0],x[1]))){
          |                                             ^
    In file included from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/bits/stl_algobase.h:64,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/bits/char_traits.h:39,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/ios:40,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/istream:38,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/sstream:38,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/complex:45,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/ccomplex:39,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
                     from /tmp/compiler_a5coyl4x/src:1:
    /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/bits/stl_pair.h:524:21: 附注:  初始化‘constexpr std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = char; _T2 = char; typename std::__decay_and_strip<_T2>::__type = char; typename std::__decay_and_strip<_Tp>::__type = char]’的实参 1
      524 |     make_pair(_T1&& __x, _T2&& __y)
          |               ~~~~~~^~~
    /tmp/compiler_a5coyl4x/src:12:36: 错误:cannot bind rvalue reference of type ‘char&&’ to lvalue of type ‘__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type’ {aka ‘char’}
       12 |    m[make_pair<char,char>(x[0],x[1])]=1;
          |                                    ^
    In file included from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/bits/stl_algobase.h:64,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/bits/char_traits.h:39,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/ios:40,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/istream:38,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/sstream:38,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/complex:45,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/ccomplex:39,
                     from /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h:54,
                     from /tmp/compiler_a5coyl4x/src:1:
    /nix/store/bbmwawbq7wjb54fa35wr72alcm083d1f-luogu-gcc-9.3.0/include/c++/9.3.0/bits/stl_pair.h:524:21: 附注:  初始化‘constexpr std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = char; _T2 = char; typename std::__decay_and_strip<_T2>::__type = char; typename std::__decay_and_strip<_Tp>::__type = char]’的实参 1
      524 |     make_pair(_T1&& __x, _T2&& __y)
          |               ~~~~~~^~~
    
  • 1

信息

ID
1000
难度
7
分类
(无)
标签
递交数
1537
已通过
289
通过率
19%
被复制
29
上传者