Submission #426299

#TimeUsernameProblemLanguageResultExecution timeMemory
426299dualityThe Collection Game (BOI21_swaps)C++14
71 / 100
15 ms416 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long int LLI; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vpii; #include "swaps.h" int used[500]; void solve(int N,int V) { V = min(V,100); srand(1234); int i,j; vi order; for (i = 0; i < N; i++) order.pb(i+1); random_shuffle(order.begin(),order.end()); int s = sqrt(N),c = 0; for (j = N/4; j > 0; j -= s/2+(rand() & 1)) { vi v1,v2; for (i = j; i < N; i++) { if (!used[i-j]) v1.pb(i),schedule(order[i-j],order[i]),used[i-j] = used[i] = 1; else v2.pb(i); } fill(used,used+N,0); vi r = visit(); for (i = 0; i < r.size(); i++) { if (!r[i]) swap(order[v1[i]-j],order[v1[i]]); } for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-j],order[v2[i]]); r = visit(); for (i = 0; i < r.size(); i++) { if (!r[i]) swap(order[v2[i]-j],order[v2[i]]); } c += 2; } for (j = 0; j < (V-c)/2; j++) { vi v1,v2; for (i = 1; i < N; i++) { if (i & 1) schedule(order[i-1],order[i]),v1.pb(i); else v2.pb(i); } vi r = visit(); for (i = 0; i < r.size(); i++) { if (!r[i]) swap(order[v1[i]-1],order[v1[i]]); } for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-1],order[v2[i]]); r = visit(); for (i = 0; i < r.size(); i++) { if (!r[i]) swap(order[v2[i]-1],order[v2[i]]); } } answer(order); }

Compilation message (stderr)

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
swaps.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-j],order[v2[i]]);
      |                     ~~^~~~~~~~~~~
swaps.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
swaps.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for (i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
swaps.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-1],order[v2[i]]);
      |                     ~~^~~~~~~~~~~
swaps.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for (i = 0; i < r.size(); 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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...