제출 #705463

#제출 시각아이디문제언어결과실행 시간메모리
705463YassineBenYounes동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
/* ID: Yassine BenYounes TASK: guard LANG: C++ */ #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pbds tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1}; int dy[8] = {0, 1, -1, 0, 1, -1, -1, 1}; #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ////////////////////Only Clear Code////////////////////////// vi primes; const int ppppp = 3e6+9; ll mod = 1e9+7; bool prime[ppppp]; ll fact[ppppp]; void sieve(int n){ memset(prime, 1, sizeof prime); prime[1] = 0; for(int i = 2; i < n;i++){ if(!prime[i])continue; primes.pb(i); for(int j = 2*i;j < n;j+=i){ prime[j] = 0; } } } vi factors(int n){ vi res; for(int i = 0; i < primes.size() && primes[i]*primes[i] <= n;i++){ if(n % primes[i] == 0)res.pb(primes[i]); while(n % primes[i] == 0){ n /= primes[i]; } } if(n > 1)res.pb(n); return res; } ll binpow(ll a, ll b){ if(b == 0)return 1; ll x = binpow(a, b/2) % mod; ll g = x*x; g %= mod; if(b%2 == 0)return g; g*=a; g%=mod; return g; } ll modinv(ll a){ return binpow(a, mod-2); } ll sub(ll a, ll b){ ll c = (a%mod)-(b%mod); while(c < 0)c+=mod; return c; } ll add(ll a, ll b){ return (((a%mod)+(b%mod)) % mod); } ll mult(ll a, ll b){ a %= mod; b %= mod; ll c = a*b; c %= mod; return c; } ll divide(ll a, ll b){ a %= mod; b = modinv(b) % mod; ll c = a*b; c%=mod; return c; } void pre_fact(int n){ fact[0]=1; for(int i = 1; i < n;i++){ fact[i] = mult(fact[i-1],i); } } ll choose(ll k, ll n){ ll c = mult(mult(fact[n],modinv(fact[k])), modinv(fact[n-k])); return c; } ll perm(ll n){ return fact[n]; } ll arrange(ll k, ll n){ ll c = mult(fact[n],modinv(fact[n-k])); return c; } void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 2e5+9; const int LOG = 25; const ll inf = 1e15; int pos[mx], door[mx], tr[mx]; int tryCombination(int pos[]); void answer(int pos[], int door[]); void exploreCave(int n){ memset(pos, -1, sizeof pos); for(int i = 0; i < n;i++){ // iterate on doors bool right = 0; for(int j = 0;j < n;j++){ // iterate on switches if(pos[j] == -1)tr[j] = right; else tr[j] = pos[j]; } int x = tryCombination(tr); if(x == i)right = 1; int l = 0, r = n-1; while(l < r){ int md = (l+r)/2; for(int j = 0; j < n;j++){ // iterate on switches if(j >= l && j <= md){ if(pos[j] == -1)tr[j] = right; else tr[j] = pos[j]; } else{ if(pos[j] == -1)tr[j] = !right; else tr[j] = pos[j]; } } int x = tryCombination(tr); if(x == i){ l = md+1; } else{ r = md; } } // switch for i-th door : l door[l] = i; pos[l] = right; } answer(pos, door); } /* void run_case(){ } int main(){ //freopen("promote.in", "r", stdin); //freopen("promote.out", "w", stdout); init(); speed; //sieve(ppppp); //pre_fact(ppppp); int t; cin >> t; //t=1; while(t--){ run_case(); } }*/ /* NEVER GIVE UP! DOING SMTHNG IS BETTER THAN DOING NTHNG!!! Your Guide when stuck: - Continue keyword only after reading the whole input - Don't use memset with testcases - Check for corner cases(n=1, n=0) - Check where you declare n(Be careful of declaring it globally and in main) */

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

cave.cpp: In function 'std::vector<int> factors(int)':
cave.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i = 0; i < primes.size() && primes[i]*primes[i] <= n;i++){
      |                    ~~^~~~~~~~~~~~~~~
cave.cpp: In function 'void init()':
cave.cpp:131:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  131 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cave.cpp:133:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  133 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc4iSRfZ.o: in function `init()':
cave.cpp:(.text+0x600): multiple definition of `init()'; /tmp/ccH2LxqZ.o:grader.c:(.text+0x110): first defined here
/usr/bin/ld: /tmp/cc4iSRfZ.o: in function `exploreCave(int)':
cave.cpp:(.text+0x6db): undefined reference to `tryCombination(int*)'
/usr/bin/ld: cave.cpp:(.text+0x757): undefined reference to `tryCombination(int*)'
/usr/bin/ld: cave.cpp:(.text+0x7db): undefined reference to `answer(int*, int*)'
/usr/bin/ld: /tmp/ccH2LxqZ.o: in function `main':
grader.c:(.text.startup+0x10): undefined reference to `exploreCave'
collect2: error: ld returned 1 exit status