제출 #238433

#제출 시각아이디문제언어결과실행 시간메모리
238433KastandaTenis (COI19_tenis)C++11
100 / 100
257 ms7832 KiB
// Criminal
#include<bits/stdc++.h>
#define lc (id << 1)
#define rc (lc ^ 1)
#define md (l + r >> 1)
using namespace std;
const int N = 100005;
int n, q, R[N][3], Mn[N * 4], F[N * 4], Lz[N * 4];
void Build(int id = 1, int l = 0, int r = n)
{
    F[id] = r - 1;
    if (r - l > 1)
        Build(lc, l, md), Build(rc, md, r);
}
void Add(int le, int ri, int val, int id = 1, int l = 0, int r = n)
{
    if (ri <= l || r <= le)
        return ;
    if (le <= l && r <= ri)
    {
        Lz[id] += val;
        Mn[id] += val;
        return ;
    }
    Add(le, ri, val, lc, l, md);
    Add(le, ri, val, rc, md, r);
    Mn[id] = min(Mn[lc], Mn[rc]) + Lz[id];
    if (Mn[rc] <= Mn[lc])
        F[id] = F[rc];
    else
        F[id] = F[lc];
}
inline void Do(int i, int val)
{
    int l = * min_element(R[i], R[i] + 3);
    int r = * max_element(R[i], R[i] + 3);
    Add(l, r, val);
}
int main()
{
    scanf("%d%d", &n, &q);
    for (int w = 0; w < 3; w ++)
        for (int i = 1, a; i <= n; i ++)
            scanf("%d", &a), R[a][w] = n - i + 1;
    Build();
    for (int i = 1; i <= n; i ++)
        Do(i, 1);
    for (; q; q --)
    {
        int tp, w, a, b;
        scanf("%d%d", &tp, &w);
        if (tp == 1)
            puts(R[w][0] > F[1] ? "DA" : "NE");
        else
        {
            scanf("%d%d", &a, &b);
            w --; Do(a, -1); Do(b, -1);
            swap(R[a][w], R[b][w]);
            Do(a, 1); Do(b, 1);
        }
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

tenis.cpp: In function 'void Build(int, int, int)':
tenis.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
tenis.cpp:13:22: note: in expansion of macro 'md'
         Build(lc, l, md), Build(rc, md, r);
                      ^~
tenis.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
tenis.cpp:13:37: note: in expansion of macro 'md'
         Build(lc, l, md), Build(rc, md, r);
                                     ^~
tenis.cpp: In function 'void Add(int, int, int, int, int, int)':
tenis.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
tenis.cpp:25:29: note: in expansion of macro 'md'
     Add(le, ri, val, lc, l, md);
                             ^~
tenis.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
tenis.cpp:26:26: note: in expansion of macro 'md'
     Add(le, ri, val, rc, md, r);
                          ^~
tenis.cpp: In function 'int main()':
tenis.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:44:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a), R[a][w] = n - i + 1;
             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
tenis.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &tp, &w);
         ~~~~~^~~~~~~~~~~~~~~~~
tenis.cpp:56:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...