Submission #1254933

#TimeUsernameProblemLanguageResultExecution timeMemory
1254933thdh__Library (JOI18_library)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "library.h"
#define ll long long
#define pb push_back
#define eb emplace_back
#define pu push
#define ins insert
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fu(x,a,b) for (auto x=a;x<=b;x++)
#define fd(x,a,b) for (auto x=a;x>=b;x--)

using namespace std;
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

/*
Competitive Programming notes that I need to study & fix my dumbass self:

1. Coding:
- Always be sure to check the memory of arrays (maybe use vectors), for loops
- Always try to maximize the memory if possible, even if you are going for subtasks
- Do not exploit #define int long long, it will kill you

2. Stress: 
- Always try generating big testcases and try if they run

3. Time management:
- Don't overcommit or undercommit, always spend a certain amount of time to think a problem, don't just look at it and say I'm fucked
- Do not spend too much time coding brute-force solutions, they should be easily-codable solutions that don't take up too much time

Time management schedule:
Offline / LAH days (4 problems - 3h):
15' thinking of solution / idea
1. no idea: skip
2. yes idea: continue thinking for <= 15'

+ implementing: <= 20'
+ brute-force: <= 5'
+ test generator: <= 5'

I hate offline because I am dumb
*/

typedef pair<int, int> ii;
const int N = 2e5+5;
const int B = 750;
const int mod = 1e9+7;
const int inf = 1e18;
using cd = complex<double>;
const long double PI = acos(-1);
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;} 

void Solve(int N)
{
	if (N == 1) 
	{
		Answer({1});
		return;
	} else if (N == 2) 
	{
		Answer({1, 2});
		return;
	}
	vector<int> ans;
	vector<int> q(N, 1);
	for (int i = 1; i <= n; i++)
	{
		q[i-1] = 0;
		if (Query(q) == 1) 
		{
			ans.pb(i); break;
		}
		q[i-1] = 1;
	}
	vector<int> q1(N, 0), q2(N, 0);
	q1[ans[0]] = 1;
	vector<int> rem;
	for (int i = 1; i <= n; i++) if (i != ans[0]) rem.pb(i);
	for (int i = 1; i < n; i++) 
	{
		int l = 0, r = rem.size()-1, res;
		while (l <= r) 
		{
			int mid = l+r>>1;
			for (int j = 0; j < mid; j++) q1[rem[j]] = q2[rem[j]] = 1;
			int v1 = Query(q1), v2 = Query(q2);
			if (v1-v2 == 1) res = mid, r = mid-1;
			else l = mid+1;
		}
		ans.pb(rem[res]);
		q1[ans.back()] = 1;
		rem.erase(rem.begin()+res);
	}
	Answer(ans);
}

/*
Go through the mistakes you usually make and revise your code, for god's sake...
*/

signed main()
{
	bruh
	//freopen("input.inp","r",stdin);
	//freopen("output.inp","w",stdout);
}

Compilation message (stderr)

library.cpp:50:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   50 | const int inf = 1e18;
      |                 ^~~~
library.cpp: In function 'void Solve(int)':
library.cpp:68:30: error: 'n' was not declared in this scope
   68 |         for (int i = 1; i <= n; i++)
      |                              ^
library.cpp:80:30: error: 'n' was not declared in this scope
   80 |         for (int i = 1; i <= n; i++) if (i != ans[0]) rem.pb(i);
      |                              ^
library.cpp:81:29: error: 'n' was not declared in this scope
   81 |         for (int i = 1; i < n; i++)
      |                             ^