Submission #487273

#TimeUsernameProblemLanguageResultExecution timeMemory
487273minhcoolMinerals (JOI19_minerals)C++17
0 / 100
1 ms712 KiB
#include<minerals.h> #include<bits/stdc++.h> using namespace std; //#define int long long #define fi first #define se second #define pb push_back typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 1e5 + 5; const int oo = 1e18 + 7, mod = 1e9 + 7; int n, a[N]; set<int> slices; vector<int> le, ri; vector<ii> answer; queue<pair<vector<int>, vector<int>>> que; void Solve(int N){ n = N; le.clear(); ri.clear(); slices.clear(); answer.clear(); int lst = 0; for(int i = 1; i <= 2 * n; i++){ int temp = Query(i); slices.insert(i); if(lst < temp){ le.pb(i); } else{ ri.pb(i); } lst = temp; } for(int i = 1; i <= 2 * n; i++) Query(i); slices.clear(); //vector<int> que.push({le, ri}); while(!que.empty()){ vector<int> a = que.front().fi, b = que.front().se; que.pop(); //assert(a.size() == b.size()); if(a.size() == 1){ answer.pb({a[0], b[0]}); continue; } int mid = (a.size() - 1) / 2; vector<int> a1, b1, a2, b2; for(int i = 0; i < mid; i++){ Query(a[i]); slices.insert(a[i]); a1.pb(a[i]); } for(int i = mid; i < a.size(); i++) a2.pb(a[i]); int lst = 0; for(int i = 0; i < b.size(); i++){ int temp = Query(b[i]); slices.insert(b[i]); if(temp != lst){ b2.pb(b[i]); lst = temp; } else b1.pb(b[i]); } for(auto it : slices) Query(it); slices.clear(); if(a1.size() != b1.size()){ assert(a.size() == n); cout << "DAMM\n"; } if(a2.size() != b2.size()) cout << "DAMM\n"; if(a1.size()) que.push({a1, b1}); if(a2.size()) que.push({a2, b2}); } for(auto it : answer) Answer(it.fi, it.se); }

Compilation message (stderr)

minerals.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:65:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int i = mid; i < a.size(); i++) a2.pb(a[i]);
      |                          ~~^~~~~~~~~~
minerals.cpp:67:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for(int i = 0; i < b.size(); i++){
      |                        ~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from minerals.cpp:2:
minerals.cpp:79:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |           assert(a.size() == n);
      |                  ~~~~~~~~~^~~~
#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...