Submission #1012622

# Submission time Handle Problem Language Result Execution time Memory
1012622 2024-07-02T12:19:26 Z 8pete8 Minerals (JOI19_minerals) C++17
0 / 100
2 ms 600 KB
#include "minerals.h"
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
const ll inf=1e9;
void Solve(int n){
  vector<int>st,on((2*n)+1,0);
  int last=0;
  for(int i=1;i<=2*n;i++)if(Query(i)>last)last++,st.pb(i),on[i]=1;
  for(int i=1;i<=2*n;i++)Query(i);
  vector<pii>bound(n+1,{1,2*n});
  for(int i=0;i<n;i++)bound[i].f=st[i]+1;
  vector<int>ans(n+1,inf);
  vector<int>done(2*n+1,0);
  int what=0;
  while(1){
    vector<pii>q;
    for(int i=0;i<st.size();i++){
      if(bound[i].f<=bound[i].s)q.pb({(bound[i].f+bound[i].s)/2,i});
      else done[st[i]]=done[ans[i]]=1;
    }
    sort(all(q));
    if(q.empty())break;
    int cur=0,sz=0;
    for(int j=1;j<=2*n;j++){
      if(cur==q.size())break;
      if(!on[j]&&!done[j])sz=Query(j);
      while(cur<q.size()&&q[cur].f==j){
        int x=Query(st[q[cur].s]);
        if(x==sz){
          bound[q[cur].s].s=q[cur].f-1;
          ans[q[cur].s]=min(ans[q[cur].s],q[cur].f);
        }
        else bound[q[cur].s].f=q[cur].f+1;
        cur++;
      }
    }
    for(int i=1;i<=q.back().f;i++)if(!done[i])Query(i);
    what++;
  }
  for(int i=0;i<n;i++)Answer(st[i],ans[i]);
}
/*
p bs?
*/

Compilation message

minerals.cpp:33:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   33 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
minerals.cpp:35:17: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   35 | void Solve(int n){
      |                 ^
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i=0;i<st.size();i++){
      |                 ~^~~~~~~~~~
minerals.cpp:55:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |       if(cur==q.size())break;
      |          ~~~^~~~~~~~~~
minerals.cpp:57:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |       while(cur<q.size()&&q[cur].f==j){
      |             ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -