Submission #1077868

#TimeUsernameProblemLanguageResultExecution timeMemory
10778680npataSuper Dango Maker (JOI22_dango3)C++17
22 / 100
262 ms1112 KiB
#include "dango3.h" #include<bits/stdc++.h> using namespace std; #define vec vector const int MXSZ = 400*25; vec<int> ri_to; vec<int> ri_from; int query(vec<int> v) { for(int i = 0; i<v.size(); i++) { v[i] = ri_to[v[i]]+1; //cerr << v[i] << ' '; } //cerr << '\n'; return Query(v); } void Solve(int N, int M) { srand(69); ri_to = vec<int>(N*M); iota(ri_to.begin(), ri_to.end(), 0); random_shuffle(ri_to.begin(), ri_to.end()); vec<vec<int>> cols_inds{}; vec<int> rem(N*M); iota(rem.begin(), rem.end(), 0); while(cols_inds.size() < N) { //cerr << "NEW ONE" << '\n'; vec<int> v{}; for(auto cis : cols_inds) { v.push_back(cis[0]); } int l = 0; int r = rem.size(); while(l<r) { int m = (l+r)/2; vec<int> qv = v; for(int i = 0; i<=m; i++) { qv.push_back(rem[i]); } //cerr << '\n'; int res = query(qv); if(res >= 1) { r = m; } else { l = m+1; } } vec<int> col_inds{rem[l]}; for(int i = 0; i<l; i++) v.push_back(rem[i]); // now v contains everything at least once except the col // therefore the first one will always correspond to the same col while(col_inds.size() < M) { //cerr << "HERE" << '\n'; l++; int last = l; int r = rem.size(); while(l<r) { int m = (l+r)/2; auto qv = v; for(int i = last; i<=m; i++) { qv.push_back(rem[i]); } int res = query(qv); if(res >= 1) { r = m; } else { l = m+1; } } col_inds.push_back(rem[l]); } assert(col_inds.size() == M); cols_inds.push_back(col_inds); set<int> nrem(rem.begin(), rem.end()); for(int ind : col_inds) { //cerr << ind << ' '; nrem.erase(ind); } //cerr << '\n'; rem = vec<int>(nrem.begin(), nrem.end()); } for(int i = 0; i<M; i++) { vec<int> ans(N); for(int j = 0; j<N; j++) { ans[j] = ri_to[cols_inds[j][i]]+1; } Answer(ans); } }

Compilation message (stderr)

dango3.cpp: In function 'int query(std::vector<int>)':
dango3.cpp:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0; i<v.size(); i++) {
      |                    ~^~~~~~~~~
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:34:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     while(cols_inds.size() < N) {
      |           ~~~~~~~~~~~~~~~~~^~~
dango3.cpp:61:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         while(col_inds.size() < M) {
      |               ~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dango3.cpp:2:
dango3.cpp:82:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |         assert(col_inds.size() == M);
      |                ~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...