Блог пользователя atcoder_official

Автор atcoder_official, история, 3 года назад, По-английски

We will hold AtCoder Beginner Contest 343.

We are looking forward to your participation!

  • Проголосовать: нравится
  • +53
  • Проголосовать: не нравится

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope to solve A,B,C,D,E!

»
3 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

ABC 343 ......

Looks like questions will involve palindromes?

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Why this code is getting TLE for task F

»
3 года назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

What are those 2 test cases in problem E ??

there were many WA's in Problem E.

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    No idea. I too want to know.

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +38 Проголосовать: не нравится

    You cannot fixate the first cube to be in (0,0,0) and require that both of the other 2 have positive coordinates. The symmetry is wrong. Imagine a cube1 in the middle, cube 2 with positive y and positive z and cube 3 with negative y and positive z. Here are the cases for which your solutions should fail:

    Test cases
»
3 года назад, скрыть # |
 
Проголосовать: нравится +53 Проголосовать: не нравится

E is the most garbage problem I've ever had the misfortune of attempting

»
3 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

G is the same as this task.

But the data range of that task is smaller.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem G is a direct application of a standard technique and CF1200E: Compress Words.

I've added hints and thought process for this problem on CF Step

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please tell me what is wrong with my solution to Problem F? I get the TLE part, but not the WA.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

JasonQin is a cheater. He asked me solutions during the contest.

»
3 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

For problem E,is there any special conditions that I should take into consideration? I got 24/26 AC and it drove me crazy。

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

This is my solution for F.Luckily i didn't got tle.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone Please give me the Solution of Problem-F — Second Largest Query ...

»
3 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

I try to find point B and C in [0,14], but I got wrong answer on 04_killer2_00.txt and 04_killer2_00.txt. Who can tell me why :(

»
3 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

F can be solve even if we need to find the number of occurrences of the k-th maximum.

If k <= 20, we can still used Segment Tree

If k <= n, simple 3D Mo does the task: Code

  • »
    »
    3 года назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Can you explain get_ans() function in your code? I used map<value, occurrence_num> to track the occurrence of all elements inside [L:R] then get the second largest value by std::next(map.begin()) but got TLE.

    • »
      »
      »
      3 года назад, скрыть # ^ |
       
      Проголосовать: нравится +1 Проголосовать: не нравится

      It is a well-known trick. We use additional sqrt-decomposition to find the number of occurrences of x (CNT array).

      You have a problem: you are changing cnt array during 3D Mo (you use cnt to maintain a set of current elements). And you need to know the k-th minimum of the current set of numbers. We want to modify cnt in O(1) and get k-th minimum in O(sqrt(n)). The number of modify queries is O(n^5/3) and the number of get queries is O(q) — we call get exactly once for each query.

      We can perform these queries in required time. Divide array into blocks size of sqrt(n). For each block we maintain the number of different elements in it. Modify is trivial. To get k-th minimum, we need to find a prefix of blocks with >= k different elements, and then find the k-th minimum in the last of these blocks.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

$$$O(n\sqrt{n})$$$ passes in 500 ms in F.

»
3 года назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone help me point out why my solution for problem C fails on testcase17.txt https://atcoder.jp/contests/abc343/submissions/50848352

and my solution for problem D only fails on the last testcase: https://atcoder.jp/contests/abc343/submissions/50851607

edit: found the cause for WA in problem D, integer overflow. Idk cause for problem C still

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have one question to ask: Do Atcoder encourages participants to use Surfing and Searching Internet for solution? In today's problem E editorial's video, it encouraged to use ChatGPT to convert a python written code to a C++ version. Doesn't it break the fairplay and similar to cheating? (As in almost every official contest, it's punishable to surf and search internet during contest)

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have a way to solve problem use $$$O(n \sqrt n \log n)$$$ .(My English is quite bad , don't mind)

First,divide the array into $$$\sqrt n$$$ blocks.For each block ,we give it a map<int,int> it means that number x appear map[x] times in the block.A change for A[x] only need $$$\log n$$$ time.

So,We can find the Largest number by auto it = map.end();it--; it is a pair<int,int> that the first value is the largest number and it's appear count is the second value.For the second large number,we can use the same way and the only difference is to it-- 2 times.(Note: there maybe only 1 value that map.size()=1 ,so we should have a special decision.

For each query,We can record the max and the 2nd.For block which is all in the query range,We should get the max and 2nd (only this two can change our recording) by following the above method.It take $$$O(\sqrt n \log n)$$$ time.For other pos,We can record in brute force because the number of it will not be larger than $$$2\sqrt n$$$.

My code is here:Code

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My first code gives ACx31, WAx1 on Problem C.

I thought of enumerating from $$$\sqrt[3]{n}$$$ to $$$1$$$ and checking if its cube is a palindrome.

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
unsigned long long n,cub,tmp;
bool check(unsigned long long qaq)
{
	int a[30];
	int cnt = 0;
	while (qaq)
	{
		a[++cnt] = qaq % 10;
		qaq /= 10;
	}
	for (int i = 1,j = cnt;i <= j;i++,j--)
		if (a[i] != a[j]) return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	cub = floor(cbrt(n));
	for (unsigned long long i = cub;i >= 1;i--)
	{
		tmp = i * i * i;
		if (check(tmp))
		{
			cout << tmp << '\n';
			return 0;
		}
	}
}

While my second solution gots AC: (pre-calculating palindromic cube number and do binary search)

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
const int N = 1e6 + 10;
long long n,l,r,mid,ans,cnt1;
long long a[N];
long long tmp;
bool check(__int128_t qaq)
{
	long long a[30];
	int cnt = 0;
	while (qaq)
	{
		a[++cnt] = qaq % 10;
		qaq /= 10;
	}
	if (a[cnt] == 0) return false;
	for (int i = 1,j = cnt;i <= j;i++,j--)
		if (a[i] != a[j]) return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	for (long long i = 1;i <= 1e6;i++)
		if (check(i * i * i)) a[++cnt1] = i * i * i;
	cin >> n;
	l = 1;
	r = cnt1;
	while (l <= r)
	{
		mid = (l + r) >> 1;
		if (a[mid] <= n)
		{
			ans = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	}
	cout << a[ans] << '\n';
}

What happened? I think two solutions are the same.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone prove why for problem E

the solution that first cube placed at (0,0,0)

second cube from 0->7 and third cube from 0->14 fails.

i am trying to visualize the placement of 3 cubes not possible from this kind of arrangement, but i am not able to find any such placement.

»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

йеша