Submission #998700

# Submission time Handle Problem Language Result Execution time Memory
998700 2024-06-14T14:23:56 Z 8pete8 Minerals (JOI19_minerals) C++17
6 / 100
6 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")
void Solve(int n){
  int root=sqrt(n);
  vector<int>done(2*n+1,0);
  int cnt=0;
  while(cnt!=2*n){
    set<int>v;
    int last=0,yes=0;
    for(int i=1;i<=2*n;i++){
      if(done[i])continue;
      int x=Query(i);
      if(x!=last){
        if(yes||v.size()>root)Query(i),yes=1;
        else v.insert(i),last=x;
      }
      else{
        for(auto j:v){
          if(Query(j)==x){
            Query(i);
            Answer(i,j);
            done[i]=1,done[j]=1;
            cnt+=2;
            v.erase(v.find(j));
            last--;
            break;
          }
          else Query(j);
        }
      }
    }
  }
}

/*
when add new element and no of type doesnt change
we can try taking one out in the current set if no of type stay the same then they are a pair
this will cost n^2

do sqrt?
*/

Compilation message

minerals.cpp:33:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   33 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
minerals.cpp:34:17: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   34 | void Solve(int n){
      |                 ^
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:45:25: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if(yes||v.size()>root)Query(i),yes=1;
      |                 ~~~~~~~~^~~~~
# 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 2 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Incorrect 6 ms 600 KB Wrong Answer [2]
5 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 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 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Incorrect 6 ms 600 KB Wrong Answer [2]
9 Halted 0 ms 0 KB -