Submission #1019602

# Submission time Handle Problem Language Result Execution time Memory
1019602 2024-07-11T04:50:53 Z LIF Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 14560 KB
#include "closing.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
long long int a[500005];
long long int b[500005];
long long int c[500005];
long long int sua[50005];
long long int sub[50005];
long long int suc[50005];
int flag[50005];
long long int kk;
bool check(int l1,int r1,int l2,int r2)
{
    flag[l1] += 1;
    flag[r1+1] -= 1;
    flag[l2] += 2;
    flag[r2+1] -= 2;
    vector<int> v;
    v.push_back(l1);v.push_back(r1+1);v.push_back(l2);v.push_back(r2+1);
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    int num = 0;
    long long int allsu = 0;
    for(int i=0;i<v.size()-1;i++)
    {
        int nowx = v[i];
        int nextx = v[i+1];
        num += flag[v[i]];
       // cout<<num<<endl;
        //calculate: v[i],v[i+1]-1;
        if(num == 1)allsu += sua[nextx-1] - sua[nowx-1];
        if(num == 2)allsu += sub[nextx-1] - sub[nowx-1];
        if(num == 3)allsu += suc[nextx-1] - suc[nowx-1];
    }
    flag[l1] = 0;flag[l2] = 0;flag[r1+1] = 0;flag[r2+1] = 0;
    if(r2 - l2 + 1 + r1 - l1 + 1 == 98)cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<" "<<allsu<<endl;
    if(allsu > kk)return false;
    return true;
}
int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W)
{
    
    kk = K;
    for(int i=0;i<U.size();i++)U[i]+=1;
    for(int i=0;i<V.size();i++)V[i]+=1;
    X+=1;
    Y+=1;
    //process X;
    long long int now = 0;
    for(int i=X-1;i>=1;i--)
    {
        now += W[i-1];
        a[i] = now;
    }
    now = 0;
    for(int i=X+1;i<=N;i++)
    {
        now += W[i-2];
        a[i] = now;
    }
    now = 0;
    for(int i=Y-1;i>=1;i--)
    {
        now += W[i-1];
        b[i] = now;
    }
    now = 0;
    for(int i=Y+1;i<=N;i++)
    {
        now += W[i-2];
        b[i] = now;
    }
    for(int i=1;i<=N;i++)c[i] = max(a[i],b[i]);
    a[X] = 0;
    b[Y] = 0;
    for(int i=1;i<=N;i++)
    {
        sua[i] = sua[i-1] + a[i];
        sub[i] = sub[i-1] + b[i];
        suc[i] = suc[i-1] + c[i]; // it can't be written as max(sua[i],sub[i]) since it can larger than both of them.
    }
    //cout<<suc[50] - suc[1]<<endl;
    int all = 0;
    for(int l1=1;l1<=X;l1++)
    {
        for(int r1=X;r1<=N;r1++)
        {
            int l2 = 1;
            int r2 = Y;
            while(l2 <= Y)
            {
                bool ad = false;
                while(check(l1,r1,l2,r2) == true && r2<=N)
                {
                    ad = true;
                    r2++;
                }
                if(ad == true)r2 -= 1;
                if(r2 > N)break;
                //otherwise, it is true
                if(check(l1,r1,l2,r2) == true)all = max(all,r1 - l1 + 1 + r2 - l2 + 1);
                l2++;
            }
        }
    }
    return all;
}

Compilation message

closing.cpp: In function 'bool check(int, int, int, int)':
closing.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v.size()-1;i++)
      |                 ~^~~~~~~~~~~
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=0;i<U.size();i++)U[i]+=1;
      |                 ~^~~~~~~~~
closing.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i<V.size();i++)V[i]+=1;
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 14560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 5 ms 600 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 476 KB Output is correct
10 Incorrect 1 ms 344 KB Possible tampering with the output
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 5 ms 600 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 476 KB Output is correct
10 Incorrect 1 ms 344 KB Possible tampering with the output
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 5 ms 600 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 476 KB Output is correct
10 Incorrect 1 ms 344 KB Possible tampering with the output
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -