답안 #757706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757706 2023-06-13T15:23:10 Z Sam_a17 카멜레온의 사랑 (JOI20_chameleon) C++17
4 / 100
11 ms 336 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
// #include "chameleon.h"
// #include <atcoder/all>
#include <cstdio>
using namespace std;
 
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
 
#define sz(x) (int((x).size()))
#define len(x) (int)x.length()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define clr(x) (x).clear()
#define uniq(x) x.resize(unique(all(x)) - x.begin());
 
#define pb push_back
#define popf pop_front
#define popb pop_back
#define ld long double
#define ll long long
 
void print(long long t) {cerr << t;}
void print(int t) {cerr << t;}
void print(string t) {cerr << t;}
void print(char t) {cerr << t;}
void print(double t) {cerr << t;}
void print(unsigned long long t) {cerr << t;}
void print(long double t) {cerr << t;}
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define nl '\n'

// Indexed Set
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T> void print(T v[],T n) {cerr << "["; for(int i = 0; i < n; i++) {cerr << v[i] << " ";} cerr << "]";}
template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(Tree <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(deque <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]";}
 

 
// for random generations
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 myrand(131);
 
// for grid problems
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,1,0,-1,1,1,-1,-1};
 
long long ka() {
	long long x = 0;
	bool z = false;
	while (1)
	{
		char y = getchar();
		if (y == '-')
			z = true;
		else if ('0' <= y && y <= '9')
			x = x * 10 + y - '0';
		else
		{
			if (z)
				x *= -1;
			return x;
		}
	}
}
 
// lowest / (1 << 17) >= 1e5 / (1 << 18) >= 2e5 / (1 << 21) >= 1e6
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
}
// file in/out
void setIO(string str = "") {
  fastIO();
 
  if (str != "") {
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
  } else if(str == "input") {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
}

const int maxN = 1005;
bool vis[maxN];
int n;

int Query(const std::vector<int> &p);
void Answer(int a, int b);

void Solve(int N) {
  n = N;

  vector<int> toask;
  for(int i = 1; i <= 2 * n; i++) {
    toask.push_back(i);

    if(sz(toask) >= 2) {
      int ss = Query(toask);
      if(ss == sz(toask) - 1) {
        int ina = 0, inb = sz(toask) - 2, ans = -1;
        while(ina <= inb) {
          int mid = (ina + inb) / 2;
          vector<int> newask{i};

          for(int j = 0; j <= mid; j++) {
            newask.push_back(toask[j]);
          }

          if(Query(newask) == sz(newask) - 1) {
            ans = mid;
            inb = mid - 1;
          } else {
            ina = mid + 1;
          }
        }

        assert(ans != -1);

        vis[toask[ans]] = true;
        vis[i] = true;


        Answer(toask[ans], i);

        vector<int> newask;
        for(auto j: toask) {
          if(vis[j]) continue;
          newask.push_back(j);
        }
        toask.swap(newask);
      }
    }
  }


}

Compilation message

chameleon.cpp: In function 'void setIO(std::string)':
chameleon.cpp:95:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |     freopen((str + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chameleon.cpp:96:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |     freopen((str + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chameleon.cpp:98:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
chameleon.cpp:99:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 11 ms 332 KB Output is correct
4 Correct 10 ms 324 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 10 ms 328 KB Output is correct
7 Correct 10 ms 332 KB Output is correct
8 Correct 10 ms 332 KB Output is correct
9 Correct 10 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 11 ms 332 KB Output is correct
4 Correct 10 ms 324 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 10 ms 328 KB Output is correct
7 Correct 10 ms 332 KB Output is correct
8 Correct 10 ms 332 KB Output is correct
9 Correct 10 ms 336 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Incorrect 0 ms 208 KB Wrong Answer [6]
12 Halted 0 ms 0 KB -