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

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

We will hold AtCoder Beginner Contest 412.

We are looking forward to your participation!

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

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

Why did the Rated Range is 0-2799 some days ago but 0-1999 now?

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

Why is the color above bule ?

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

Why is the colour above blue? (I don't like blue,so do anybody know how to switch it back?)

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

why can't I participate as a rated participant?

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

F is a very good expectation question.

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

D is a trash idea

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

Segmented sieve is new for me. Pretty cool approach!!

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

Problem D is nice. The way to solve it is so ingenious.

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

Someone please help me with question C :( I tried greedy with binary search, it didn't pass 12/32 cases.

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

I am pretty sure that problem D or something very similar has already occur somewhere with much stricter constraints.

I solved it today with MCMF on a graph: s -> v of capacity 2 cost 0, (v + n) -> t capacity 2 cost 0, and u -> (v + n) capacity 1 cost (1 if there were no such edge initially and -1 otherwise). Answer == (m * 2 + mincost) / 2.

However, this approach is kinda hard to prove, because it is not necessary that if edge (u -> (v + n)) is taken to the flow, then (v -> (u + n)) is also taken. If the graph is directed, then there is no issue, problem solved. However, it also works for undirected(i mean that the answer is correct, not that the flow is built in a way that all edges are taken in pairs). But i cannot prove it. Can anyone?

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

    What an overkill)

    I solve it following way. Degree of all vertices is two, hence the graph is set of cycles. There is a bijection between such graphs and permutations (edges are $$$(i, a[i]) \; \forall i \in [1, n]$$$). Iterate on permutations. We need to just check, that there is no loop $$$i = a[i]$$$ and no multiedge $$$i = a[a[i]]$$$.

    Let $$$X$$$ be the number of edges in permutation, that are given, and $$$Y$$$ be the number of edges in permutation, that are not given. Then the possible answer is $$$(m - X) + Y$$$.

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

    orz

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

In problem F editorial I can't understand anything. Can someone, please, explain it more adequately?

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

About geminipromc: is he an AI?

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

D in $$$ O(n!.n log(n)) $$$ Link

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

I think E is very hard.I noticed that the prime solving,but I got a TLE...........Because my algorithm for factoring prime factors is not good.......

But I think D is an easy problem , It just use a DP

C is a problem to practice thinking,I got the solution in 18min。I use a Binary search and greedy to solve it.

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

can any one please explain how to cross the 4th problem barrier at atcoder.......

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

i am getting WA in C submission any testcase where it will fail

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

I haven't seen a problem which can search to get the full score for a long time.

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

I think I can say that, here we go again, for today's problem F.

:D https://mirror.codeforces.com/blog/entry/142558#comment-1272566

It seems that ABC really likes this kind of dp, which asks to find out max or min of some expectation.

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

appreciate any help i could get about my WA on C!

void solve() {
    int N; cin >> N;
    deque<int> S(N); for (auto& x : S) cin >> x;

    int curr = S.front(); S.pop_front();
    int end = S.back(); S.pop_back();

    sort(all(S));

    S.push_front(curr);
    S.push_back(end);

    int answer = 2;
    for (int i = 1; i < N; i++) {
        if (2 * curr >= end) break;

        if (2 * curr < S[i]) {
            curr = S[i - 1];
            answer += 1;

            if (2 * curr < S[i]) {
                cout << -1 << endl;
                return;
            }
        }
    }

    if (2 * curr >= end) cout << answer << endl;
    else cout << -1 << endl;
}

https://atcoder.jp/contests/abc412/submissions/67211725

thank you in advance!

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

In F, if two drawers have the same no. Of socks, the expectation should be the same, right??

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
constexpr int mod = 998244353;

int binpow(int a, int b, int m)
{
	int res = 1;
	a = a % m;
	while (b != 0)
	{
		if (b & 1)
		{
			res = (res * a) % m;
		}
		a = (a * a) % m;
		b = b >> 1;
	}
	return res;
}

void solve()
{
	int n, c;
	cin >> n >> c;

	vector<int> a(n);

	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	sum++;
	sum = sum % mod;
	c--;
	a[c]++;


	sort(a.begin(), a.end());

	int pp = 1e18;
	int sum1 = 0, kk = 0;
	map<int,int> dp;
	int z = (sum - 1 + mod) % mod;
	for (int i = n - 1; i >= 0; i--)
	{
		sum1 += a[i];
		int y = (sum - sum1) % mod;
		//cout << y << " " << a[i] << " " << z << endl;
		int mm = (y * binpow(z, mod - 2, mod)) % mod;
		mm = (1 - mm + mod) % mod;
		//cout << kk << endl;
		mm = binpow(mm, mod - 2, mod);
		//cout<<((1 + kk) * mm) % mod<<endl;
		dp[a[i]] = ((1 + kk) * mm) % mod;
		int oo = (a[i]) % mod;
		oo = (oo * binpow(z, mod - 2, mod)) % mod;
		kk = (kk + (dp[a[i]] * oo) % mod) % mod;
	}

	cout << dp[a[c]] << endl;

	return;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;

	while (t-- != 0)
	{
		solve();
	}
	return 0;
}

also if someone can tell me what's wrong in this edit: got it I think I need to sleep

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

Can somebody explain me the problem E please i tried to follow the editorial but that didn't helped me . Somebody please explain in simpler terms Thankyou

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

For problem C,I wanna to use priorityqueue to solve ,but it doesn't work for 5 tests,and I can't find the mistakes...

import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- != 0) {
            solve(in);
        }

    }

    public static void solve(Scanner in) {
        int n = in.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = in.nextInt();
        }
        if (s[0] * 2 >= s[n - 1]) {
            System.out.println(2);
            return;
        }
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int i = 1; i < n - 1; i++) {
            pq.offer(s[i]);
        }
        if (pq.isEmpty()) {
            System.out.println(-1);
            return;
        }
        int starth = s[0];
        int endh = s[n - 1];
        int ans = 2;
        while (!pq.isEmpty()) {
            int g = -1;
            while (!pq.isEmpty() && pq.peek() <= 2 * starth) {
                g = pq.poll();
            }
            if (g != -1) {
                ans++;
                starth = g;
                if (starth * 2 >= endh) {
                    System.out.println(ans);
                    return;
                }
            } else {
                System.out.println(-1);
                return;
            }
        }
    }
}