QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#887152#10049. Grid Coloringmodwwe0 210ms31724kbC++232.8kb2025-02-07 15:23:502025-02-07 15:23:52

Judging History

This is the latest submission verdict.

  • [2025-02-07 15:23:52]
  • Judged
  • Verdict: 0
  • Time: 210ms
  • Memory: 31724kb
  • [2025-02-07 15:23:50]
  • Submitted

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int   long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l,int r)
{
    return uniform_int_distribution<int>(l,r)(rd);
}
inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+7;
const int  mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
    if(x+y>=mod2) x-=mod2;
    if(x+y<0)x+=mod2;
    return x+y;
}
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};
int  n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r ;
int kk;
int el = 19;
main()
{
    if(fopen(task2".inp","r"))
    {
        fin(task2);
        fou(task2);
    }
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    /// cin>>s1;
    //modwwe
    phongbeo(),down
    // checktime
}
int a[200001];
int b[200001];
map<int,int> cnt;
void phongbeo()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i],cnt[a[i]]++;
    for(int i=1; i<=n; i++)
        cin>>b[i],cnt[b[i]]++;
    cnt[a[1]]--;
    for(int i=3; i<=n; i++)
    {
        a[i]=max(a[i],a[i-1]);
        b[i]=max(b[i],b[i-1]);
    }
    l=2;
    for(int i=2; i<=n; i++)
    {
        while(l<=n&&a[i]>=b[l])
        {
            l++;
        }
        cnt[a[i]]+=l-2;
    }
    l=2;
    for(int i=2; i<=n; i++)
    {
        while(l<=n&&b[i]>a[l])
            l++;
        cnt[b[i]]+=l-2;
    }
    s4=a[1];
    for(int i=2; i<=n; i++)
        if(cnt[a[i]]>cnt[s4])
            s4=a[i];
    for(int i=2; i<=n; i++)
        if(cnt[b[i]]>cnt[s4])
            s4=b[i];
    cout<<s4<<" "<<cnt[s4],down
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 1ms
memory: 3712kb

input:

500
443 443 567 680 1057 1143 1196 1213 1385 1534 1621 1741 1812 1944 2186 2861 2970 3022 3385 3451 3902 3968 4007 4048 4066 4109 4162 4997 5031 5043 5051 5311 5612 5735 5914 6068 6125 6269 6354 6683 7095 7134 7285 7500 7507 7550 7681 7829 7905 8039 8047 8111 8438 8453 8476 8842 8900 9051 9154 9224 ...

output:

443 501


result:

ok single line: '443 501'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3712kb

input:

500
422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 ...

output:

422 500


result:

wrong answer 1st lines differ - expected: '99516 500', found: '422 500'

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 10
Accepted
time: 1ms
memory: 3712kb

input:

500
4195946 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 600922 6...

output:

4195946 501


result:

ok single line: '4195946 501'

Test #22:

score: 0
Wrong Answer
time: 0ms
memory: 5872kb

input:

500
821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 821209 82...

output:

821209 500


result:

wrong answer 1st lines differ - expected: '999171721 500', found: '821209 500'

Subtask #3:

score: 0
Wrong Answer

Test #38:

score: 20
Accepted
time: 4ms
memory: 4480kb

input:

47321
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1 1119638521


result:

ok single line: '1 1119638521'

Test #39:

score: 20
Accepted
time: 18ms
memory: 6768kb

input:

199999
2 1 2 2 2 1 1 2 1 1 1 2 2 1 2 1 1 1 1 1 1 2 2 1 1 1 2 1 2 2 2 1 2 1 2 1 2 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 1 1 1 1 2 2 1 1 1 1 2 1 1 2 1 1 2 1 2 1 1 1 2 2 1 2 1 2 1 2 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 2 2 2 1 2 1 1 1 1 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 2 2 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 2 1 2 1 2 2 1 2 2...

output:

2 39999400146


result:

ok single line: '2 39999400146'

Test #40:

score: 20
Accepted
time: 17ms
memory: 6768kb

input:

200000
2 2 1 1 1 2 2 2 1 2 2 1 1 1 2 1 2 2 1 1 2 2 1 1 1 2 1 2 1 2 2 1 1 2 1 1 2 1 2 1 1 1 1 2 2 1 1 1 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 2 1 2 1 1 1 1 1 1 2 1 1 2 1 1 2 2 1 1 1 1 2 2 2 2 2 1 2 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 2 1 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 1 1 1 2 1 2 1 2 1 1 1 2 2 2...

output:

2 39999800282


result:

ok single line: '2 39999800282'

Test #41:

score: 20
Accepted
time: 13ms
memory: 6892kb

input:

200000
1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2 39999600003


result:

ok single line: '2 39999600003'

Test #42:

score: 0
Wrong Answer
time: 13ms
memory: 6912kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 20000000000


result:

wrong answer 1st lines differ - expected: '2 20000000000', found: '1 20000000000'

Subtask #4:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 210ms
memory: 31724kb

input:

200000
920 1463 4431 7058 11118 13005 30856 33341 34539 39227 40209 43007 43510 49602 51105 55241 55810 56016 57083 58973 60147 62082 62452 68622 70787 73408 79126 83852 86224 91963 94622 97983 98446 99211 100001 100206 101048 101583 104042 105734 109201 111247 112684 114852 116012 117918 119202 122...

output:

499013612 200000


result:

wrong answer 1st lines differ - expected: '999995694 200000', found: '499013612 200000'

Subtask #5:

score: 0
Wrong Answer

Test #63:

score: 30
Accepted
time: 115ms
memory: 19436kb

input:

200000
14788 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 9714 97...

output:

14788 200001


result:

ok single line: '14788 200001'

Test #64:

score: 0
Wrong Answer
time: 122ms
memory: 19184kb

input:

200000
7592 10647 12202 18910 20019 22476 23681 24457 25222 25530 38396 43068 47172 60367 61133 65809 77851 80815 86221 90021 94965 103145 105362 107509 109518 118658 125856 132367 144055 148495 153157 154214 156356 157657 160798 160920 174264 182075 183747 186604 199358 199772 201119 213377 219989 ...

output:

7592 200000


result:

wrong answer 1st lines differ - expected: '999985769 200000', found: '7592 200000'