답안 #344465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344465 2021-01-05T21:49:53 Z chienyu_xiong 사육제 (CEOI14_carnival) C++14
100 / 100
17 ms 396 KB
#include <bits/stdc++.h>

#define F first
#define S second

#define pb push_back
#define mp make_pair

typedef long long int lli;

#define pll pair<lli, lli>
#define pil pair<int, lli>
#define pli pair<lli, int>
#define pii pair<int, int>

using namespace std;

void setIO(string str, bool dbg) {
	ios_base::sync_with_stdio(0);

	cin.tie(0);
	cout.tie(0);

	if (!dbg) {
		freopen((str + ".in").c_str(), "r", stdin);
		freopen((str + ".out").c_str(), "w", stdout);
	}
}

const int MAX = 155;
const lli INF = 9e17;
const lli MOD = 1e9 + 7;

int _ = 1; // test cases

int n;
int cur = 0;
int val[MAX];
int ans[MAX];

int que(int cnt, int idx) {
	cout << cnt << " ";
	cout << idx << " ";
	for (int i = 1; i < cnt; i++)
		cout << val[i] << " ";
	cout << endl;

	int res;
	cin >> res;
	return res;
}

int slv(int num) {
	int lo = 1;
	int hi = cur + 1;
	while (lo < hi) {
		int mid = (lo + hi + 0) / 2;
		
		bool can = que(mid + 1, num) != mid + 1;
		if (can == 0) lo = mid + 1;
		if (can == 1) hi = mid;
	}
	return lo;
}

void fnc() {
	cin >> n;

	for (int i = 1; i <= n; i++) {
		ans[i] = slv(i);
		val[ans[i]] = i;
		cur = max(cur, ans[i]);
	}

	cout << "0 ";
	for (int i = 1; i <= n; i++)
		cout << ans[i] << " "; cout << endl;
}

int main() {
	//setIO("", 0);

	while (_--) fnc();

	return 0;
}

Compilation message

carnival.cpp: In function 'void fnc()':
carnival.cpp:76:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   76 |  for (int i = 1; i <= n; i++)
      |  ^~~
carnival.cpp:77:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   77 |   cout << ans[i] << " "; cout << endl;
      |                          ^~~~
carnival.cpp: In function 'void setIO(std::string, bool)':
carnival.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   freopen((str + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   freopen((str + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 14 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 8 ms 396 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 14 ms 364 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 11 ms 364 KB Output is correct
4 Correct 15 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 7 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 12 ms 364 KB Output is correct
4 Correct 16 ms 364 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 13 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 11 ms 364 KB Output is correct
7 Correct 17 ms 364 KB Output is correct