Submission #1012634

# Submission time Handle Problem Language Result Execution time Memory
1012634 2024-07-02T12:35:48 Z 8pete8 Minerals (JOI19_minerals) C++17
40 / 100
32 ms 3288 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,dc=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;
        sz=x;
        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:57: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]
   57 |       if(cur==q.size())break;
      |          ~~~^~~~~~~~~~
minerals.cpp:59: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]
   59 |       while(cur<q.size()&&q[cur].f==j){
      |             ~~~^~~~~~~~~
minerals.cpp:44:14: warning: unused variable 'dc' [-Wunused-variable]
   44 |   int what=0,dc=0;
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 600 KB Output is correct
3 Correct 5 ms 600 KB Output is correct
4 Correct 12 ms 856 KB Output is correct
5 Correct 25 ms 1460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
15 Incorrect 32 ms 3288 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
15 Incorrect 32 ms 3288 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
15 Incorrect 32 ms 3288 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
15 Incorrect 32 ms 3288 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
15 Incorrect 32 ms 3288 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 12 ms 856 KB Output is correct
9 Correct 25 ms 1460 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 18 ms 1160 KB Output is correct
12 Correct 27 ms 1528 KB Output is correct
13 Correct 10 ms 1504 KB Output is correct
14 Correct 15 ms 1460 KB Output is correct
15 Incorrect 32 ms 3288 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -