제출 #524217

#제출 시각아이디문제언어결과실행 시간메모리
524217LoboUnscrambling a Messy Bug (IOI16_messy)C++17
컴파일 에러
0 ms0 KiB
#include "messy.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
// #define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 

vector<int> restore_permutation(int n, int w, int r) {
    srand("pinto");
    vector<pair<int,int>> v;

    for(int i = 0; i < n; i++) {
        v.pb(mp(rand()%150,i));
    }
    sort(all(v));

    vector<int> p1(n,0);

    for(int i = 1; i <= n; i++) {
        string s;
        for(int j = 0; j < i; j++) s.pb('1');
        for(int j = 0; j < n-i; j++) s.pb('0');

        add_element(s);
    }

    compile_set();
    string cur(n,'0');
    for(int i = 0; i < n; i++) {
        //encontrar qual j tem p[j] = i

        for(auto X : v) {
            int j = X.sc;
            if(cur[j] == '1') continue;
            cur[j] = '1';
            bool ok;
            // cout << cur << " " << ok ? "false" : "true" << endl;
            ok = check_element(cur);
            // cout << cur << " " << ok ? "false" : "true" << endl;
            if(ok) {
                p1[j] = i;
                break;
            }
            cur[j] = '0';
        }
    }

    return p1;
}

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:19:11: error: invalid conversion from 'const char*' to 'unsigned int' [-fpermissive]
   19 |     srand("pinto");
      |           ^~~~~~~
      |           |
      |           const char*
In file included from /usr/include/c++/10/cstdlib:75,
                 from /usr/include/c++/10/ext/string_conversions.h:41,
                 from /usr/include/c++/10/bits/basic_string.h:6535,
                 from /usr/include/c++/10/string:55,
                 from messy.h:4,
                 from messy.cpp:1:
/usr/include/stdlib.h:455:33: note:   initializing argument 1 of 'void srand(unsigned int)'
  455 | extern void srand (unsigned int __seed) __THROW;
      |                    ~~~~~~~~~~~~~^~~~~~