제출 #619395

#제출 시각아이디문제언어결과실행 시간메모리
619395Dremix10Unscrambling a Messy Bug (IOI16_messy)C++17
70 / 100
3 ms340 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; //#define endl '\n' #define all(x) (x).begin(),(x).end() #define F first #define S second #ifdef dremix #define p(x) cerr<<#x<<" = "<<x<<endl; #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl; #define pp(x) cerr<<#x<<" = "<<x.F<<"-"<<x.S<<endl; #define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl; #define ppv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v.F<<"-"<<v.S<<", ";cerr<<"}"<<endl; #else #define p(x) {} #define p2(x,y) {} #define pp(x) {} #define pv(x) {} #define ppv(x) {} #endif const int N = 3e5+5; const int MOD = 1e9+7; const ll INF = 1e18+5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution <ll> distr; ll rnd(ll x, ll y){return distr(rng)%(y-x+1)+x;} std::vector<int> restore_permutation(int n, int w, int r) { int i; string s = "", reset = ""; /// for sub 3: /// can write 32 numbers for each of the 32 bits /// can read 10 numbers for each of the 32 bits for(i=0;i<n;i++)reset += '0'; int B = 11; vector<int> blocks = {12,12,12,12,12,12,12,12,12,12,8}; if(n==8){ B = 4; blocks = {2,2,2,2}; } else if(n==32){ B = 6; blocks = {6,6,5,5,5,5}; } int j; string base = reset; int k = 0; vector<int> temp(n); iota(all(temp),0); shuffle(all(temp),rng); for(auto x : temp)cerr<<x<<" "; cerr<<endl; for(i=0;i<B;i++){ s = base; for(j=0;j<blocks[i];j++){ s[k+j] = '1'; base[k+j] = '1'; //p2(s,base) add_element(s); add_element(base); s[k+j] = '0'; } k += blocks[i]; } k = 0; s = reset; s[0] = '1'; for(i=0;i<B-1;i++){ s[k + blocks[i]] = '1'; //p(s) add_element(s); s[k] = '0'; k += blocks[i]; } compile_set(); vector<int> ans(n,-1); s = reset; vector<vector<int> > idx(B); bool v[n] = {}; for(i=0;i<B;i++){ for(j=0;j<n;j++){ if(v[j])continue; s[j] = '1'; bool p = check_element(s); s[j] = '0'; if(p){ idx[i].push_back(j); v[j] = true; } } assert(idx[i].size() == blocks[i]); for(auto x : idx[i]) s[x] = '1'; } s = reset; int singles[B]; for(auto x : idx[0])for(auto y : idx[1]){ s[x] = '1'; s[y] = '1'; //p(s) bool p = check_element(s); s[x] = '0'; s[y] = '0'; if(p){ singles[0] = x; singles[1] = y; ans[x] = 0; ans[y] = blocks[0]; break; } } k = blocks[0] + blocks[1]; for(i=2;i<B;i++){ s[singles[i-1]] = '1'; for(auto x : idx[i]){ s[x] = '1'; //p(s) bool p = check_element(s); s[x] = '0'; if(p){ singles[i] = x; ans[x] = k; break; } } s[singles[i-1]] = '0'; k += blocks[i]; } pv(singles) k = 0; for(i=0;i<B;i++){ pv(idx[i]) s[singles[i]] = '1'; p(s) for(j=1;j<blocks[i];j++){ for(auto x : idx[i]){ if(ans[x] != -1)continue; ///p2(k+j,x) s[x] = '1'; bool p = check_element(s); if(p){ ///p2(k+j,x) ans[x] = k+j; break; } s[x] = '0'; } } k += blocks[i]; } /* add_element("0"); compile_set(); check_element("0"); return std::vector<int>(); */ return ans; }

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

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from messy.cpp:2:
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:106:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
  106 |         assert(idx[i].size() == blocks[i]);
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...