Submission #212373

#TimeUsernameProblemLanguageResultExecution timeMemory
212373M0REDAChameleon's Love (JOI20_chameleon)C++14
100 / 100
138 ms636 KiB
#include <bits/stdc++.h> #include "chameleon.h" #define debug(x) cerr << #x << " = " << x << ", "; #define ll long long #define pb push_back using namespace std; #define FAST_IO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); vector<vector<int>> v; vector<int> graph; vector<vector<int>> seq; vector<int> cutoff(int l, int r, vector<int> v) { vector<int> ret; for (int i = l; i <= r; i += 1) { ret.push_back(v[i]); } return ret; } int binarysearch(int l, int r, vector<int> v1, int x) { r += 1; while (r - l > 1) { int m = (l + r) / 2; vector<int> q = cutoff(m, r - 1, v1); q.push_back(x); if (Query(q) == q.size()) { r = m; } else { l = m; } } v[x].push_back(v1[l]); v[v1[l]].push_back(x); return l - 1; } void Solve(int N) { v.resize(2 * N + 1); graph.resize(2 * N + 1, -1); vector<bool> done(2 * N + 1, true); seq.resize(4); for (int i = 1; i <= 2 * N; i++) { for (int j = 0; j < 4; j++) { if (seq[j].size() == 0) { if (done[i]) { seq[j].pb(i); done[i] = false; } continue; } bool asd = true; vector<int> p; p = seq[j]; p.pb(i); int l = 0, r = p.size() - 2; vector<int> q = cutoff(l, r, p); q.pb(i); while (r >= l && Query(q) != q.size()) { asd = false; r = binarysearch(l, r, p, i); q = cutoff(l, r, p); q.push_back(i); } if (done[i] && asd) { seq[j].pb(i); done[i] = false; } } } for (auto a : v) { for (auto b : a) { cerr << b << " "; } cerr << endl; } for (int i = 1; i <= 2 * N; i++) { if (v[i].size() == 1) { continue; } for (int j = 0; j < 3 && graph[i] == -1; j++) { for (int k = j + 1; k < 3; k++) { vector<int> p; p.pb(i); p.pb(v[i][j]); p.pb(v[i][k]); if (Query(p) == 1) { graph[i] = v[i][3 - j - k]; break; } } } } for (int i = 1; i <= 2 * N; i++) { debug(i); cerr << endl; cerr << " tttttttttt " << endl; if (v[i].size() == 1) { debug(i); debug(v[i][0]); cerr << endl; cerr << "===================" << endl; if (i < v[i][0]) Answer(i, v[i][0]); continue; } for (int j = 0; j < 3; j++) { debug(i); debug(v[i][j]); cerr << endl; if (v[i][j] == graph[i] || i == graph[v[i][j]]) { continue; } cerr << "passed" << endl; cerr << "===================" << endl; if (i < v[i][j]) Answer(i, v[i][j]); break; } } }

Compilation message (stderr)

chameleon.cpp: In function 'int binarysearch(int, int, std::vector<int>, int)':
chameleon.cpp:32:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Query(q) == q.size())
             ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:72:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while (r >= l && Query(q) != q.size())
                              ~~~~~~~~~^~~~~~~~~~~
#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...