Submission #93528

# Submission time Handle Problem Language Result Execution time Memory
93528 2019-01-09T11:16:16 Z Sa1loum Norela (info1cup18_norela) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define F first
#define S second
#define Si size
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)1e5+10;
int n,m,x,a[100],q[100][100],num[100];
string s;
string to_string(int n){
    string t;
    t.clear();
    int x=10;
    while (n%x) {
        t+=(char)(n%x+'0');
        n/=x;
    }
    reverse(t.begin(),t.end());
    t+=" ";
    return t;
}
bool possible(int a[100],int i) {
    /*
    for (int k=0;k<num[i];k++) {
        a[q[i][k]]++;
    }*/
    int p=1;
    for (int l=1;l<=n;l++) {
        if (a[l]%2==0) p=0;
    }
    if (p) return 1;
    for (int j=i;j<m;j++) {
        s+=to_string(j+1);
        for (int k=0;k<num[j];k++) {
            a[q[j][k]]++;
        }
        if (possible(a,j+1)) {
            return 1;
        }
        else {
            s.pop_back();
            while (s[s.size()-1]!=' ') s.pop_back();
            for (int k=0;k<num[j];k++) {
                a[q[j][k]]--;
            }
        }
    }
    return 0;
}
int main()
{
    s.clear();
    s+=" ";
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++) {
        cin>>num[i];
        for (int j=0;j<num[i];j++) {
            cin>>q[i][j];
        }
    }
    for (int i=0;i<m;i++) {
        if (possible(a,i)) {
            cout<<s;
            return 0;
        }
        s.clear();
    }
}

Compilation message

norela.cpp: In function 'bool possible(int*, int)':
norela.cpp:38:25: error: call of overloaded 'to_string(int)' is ambiguous
         s+=to_string(j+1);
                         ^
norela.cpp:15:8: note: candidate: std::__cxx11::string to_string(int)
 string to_string(int n){
        ^~~~~~~~~
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from norela.cpp:1:
/usr/include/c++/7/bits/basic_string.h:6454:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6445:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6436:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6430:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6424:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6418:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6413:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6407:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^~~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6402:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^~~~~~~~~
norela.cpp: In function 'int main()':
norela.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~