답안 #93641

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93641 2019-01-10T13:57:06 Z ajmasin Relativnost (COCI15_relativnost) C++14
42 / 140
4000 ms 9332 KB
#include <bits/stdc++.h>
using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)

const int maxn = 100100;
const int maxc = 25;
const int offset = (1<<17);
const int mod = 10007;

int n, c, q;

int niza[maxn];
int nizb[maxn];

int add(int a, int b)
{
    a += b;
    if(a >= mod) a -= mod;
    if(a < 0) a += mod;
    return a;
}

int mult(int a, int b)
{
    return a * b % mod;
}

struct tournament
{
    int brn[maxc][2 * offset];
    void update(int cvor)
    {
        REP(i, 0, c + 1) brn[i][cvor] = 0;
        REP(i, 0, c + 1)
        {
            REP(j, 0, c + 1)
            {
                int suma = min(i + j, c);
                brn[suma][cvor] = add(brn[suma][cvor], mult(brn[i][cvor * 2], brn[j][cvor * 2 + 1]));
            }
        }
        //REP(i, 0, c + 1) cout << brn[i][cvor] << " ";
        //cout << endl;
        return;
    }
}T;

int main()
{
    for(int i = 2 * offset - 1; i > 0; i--) T.brn[0][i] = 1;
    scanf("%d%d", &n, &c);
    int a, b;
    REP(i, 0, n)
    {
        scanf("%d", &niza[i]);
    }
    REP(i, 0, n)
    {
        scanf("%d", &nizb[i]);
    }
    REP(i, 0, n)
    {
        T.brn[0][i + offset] = nizb[i];
        T.brn[1][i + offset] = niza[i];
        int up = (i + offset) / 2;
        while(up)
        {
            T.update(up);
            up /= 2;
        }
    }
    scanf("%d", &q);
    int p;
    REP(i, 0, q)
    {
        scanf("%d%d%d", &p, &a, &b);
        p--;
        T.brn[0][p + offset] = b;
        T.brn[1][p + offset] = a;
        p += offset;
        p /= 2;
        while(p)
        {
            T.update(p);
            p /= 2;
        }
        printf("%d\n", T.brn[c][1]);
    }
    return 0;
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &c);
     ~~~~~^~~~~~~~~~~~~~~~
relativnost.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &niza[i]);
         ~~~~~^~~~~~~~~~~~~~~~
relativnost.cpp:60:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &nizb[i]);
         ~~~~~^~~~~~~~~~~~~~~~
relativnost.cpp:73:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
relativnost.cpp:77:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &p, &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1744 KB Output is correct
2 Correct 45 ms 1912 KB Output is correct
3 Correct 95 ms 2140 KB Output is correct
4 Incorrect 1068 ms 3992 KB Output isn't correct
5 Execution timed out 4010 ms 7580 KB Time limit exceeded
6 Execution timed out 4021 ms 9332 KB Time limit exceeded
7 Incorrect 3169 ms 5868 KB Output isn't correct
8 Incorrect 1669 ms 5752 KB Output isn't correct
9 Incorrect 2592 ms 5820 KB Output isn't correct
10 Execution timed out 4030 ms 8464 KB Time limit exceeded