Codeforces Round #366 (Div. 2)

Source: Internet
Author: User

CF Avengers Federation Field ...

Water Problem A-hulk (Hulk)

Output Love hate ...

#include <bits/stdc++.h>typedef long long ll;const int n = 1e5 + 5;int main () {    int n;    scanf ("%d", &n);    printf ("I hate");    for (int i=1, i<n; ++i) {        if (I & 1) printf ("That's Love");        else printf ("that I hate");    }    Puts ("it");    return 0;}

Game + Play table to find the Law B-spider Man (Spiderman)

Notice that each time more than one lap, the previous or initial state, the groups are independent, so to play a table or analysis can find the law.

#include <bits/stdc++.h>typedef long long ll;const int N = 1e5 + 5;int a[n];int sg[105];int sg (int x) {    if (x &L T 2) return sg[x] = 0;    BOOL vis[105];    Memset (Vis, false, sizeof (VIS));    for (int i=1; i<x; ++i) {        vis[sg (i) ^ (SG (x-i))] = true;    }    int &ret = Sg[x] = 0;    while (Vis[ret]) ret++;    return ret;} void Test () {    memset (SG,-1, sizeof (SG));    for (int i=1; i<=20; ++i) {        printf ("sg[%d]=%d\n", I, SG (i));}    } int main () {    //test ();    int n;    scanf ("%d", &n);    for (int i=1; i<=n; ++i) scanf ("%d", a+i);    int ans = 0;    for (int i=1; i<=n; ++i) {        int res = a[i] & 1? 0:1;        Ans ^= Res;        printf ("%d\n", ans? 1:2);    }    return 0;}

Construction C-thor (Thor)

Test instructions: A mobile phone has n applications, there are three kinds of operations:

1. The first X application has an unread message;

2. Read all unread information for the current x application;

3. Read the first T message (information may be reread);

The number of bars for which the current unread information is output after each operation.

Idea: The 3rd operation "First T" is critical, so as long as the Max (T) operation. If the information to be read is read at a later point in time (the 2nd operation) then it is not updated, so maintain the latest "empty" app number and time. Before there was a place to write the continue, the answer did not output, WA for a long time.

#include <bits/stdc++.h>typedef long long ll;const int N = 3e5 + 5;int cnt[n];int clear_time[n];std::p air<int, in    t> Que[n];int Main () {int N, q;    scanf ("%d%d", &n, &q);    int m = 0, ans = 0;    int TP, X, T, maxt = 0;        for (int i=1; i<=q; ++i) {scanf ("%d", &AMP;TP);            if (tp = = 1 | | tp = = 2) {scanf ("%d", &x);                if (tp = = 1) {cnt[x]++;                ans++;            Que[++m] = {x, i};                } else {ans-= cnt[x];                Cnt[x] = 0;            CLEAR_TIME[X] = i;            }} else {scanf ("%d", &t); if (T > Maxt) {for (int j=maxt+1; j<=t; ++j) {int pos = Que[j].first, Tim = que[                    J].second;                    if (Clear_time[pos] >= Tim) continue;                    cnt[pos]--;                ans--;            } maxt = t; }} printf ("%d\n", ans); } return 0;}

Codeforces Round #366 (Div. 2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.