QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182851#5420. InscryptionKAZE_mae#WA 606ms3884kbC++172.3kb2023-09-18 16:59:542023-09-18 16:59:54

Judging History

你现在查看的是最新测评结果

  • [2023-09-18 16:59:54]
  • 评测
  • 测评结果:WA
  • 用时:606ms
  • 内存:3884kb
  • [2023-09-18 16:59:54]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include <functional>
#include<list>
#include<string>
#include<bitset>
#include<stack>
#include<cstring>
#include<stdio.h>

#define int long long
#define endl '\n'
#define mod 998244353
#define ffor(n) for(int i = 0;i < n;++i)


const int N = 2000006; 

using namespace std;

void build_log();
int mv_x[4] = {1,0,-1,0};
int mv_y[4] = {0,1,0,-1};
int t;
int m_log2[500005]; // log2(x) + 1
int k;
int n,m;
int h;

int ss;
int tt;




signed main()
{
    //ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a = 0;
        int b = 0;
        int c = 0;
        double sum = 1;
        double pos = 1;
        double x;
        int ff = 0;
        ffor(n)
        {
            cin>>x;
            if(x == 1)
            {
                sum++;
                pos++;
            }
            else if(x == -1)
            {
                if(sum - 1 <= 0)
                {
                    if(c > 0)
                    {
                        c--;
                        sum++;
                        pos++;
                    }
                }
                sum--;
                if(sum <= 0)
                {
                    ff = 1;
                }
            }
            else
            {
                c++;
            }
        }
        if(ff)
        {
            cout<<-1<<endl;
        }
        else
        {
            if(sum > c)
            {
                sum -= c;
            }
            else
            {
                c -= sum - 1;
                sum = 1;
                if(c % 2 == 0)
                {
                    pos += c / 2;
                }
                else
                {
                    pos += c / 2 + 1;
                    sum += 1;
                }
            }

            int xpos = pos;
            int xsum = sum;
            int kt = __gcd(xpos,xsum);
            cout<<xpos/kt<<' '<<xsum/kt<<endl;
        }


        



    }




    return 0;
}





void build_log()
{
    for(int i = 1;i <= n;i++)
    {
        m_log2[i] = m_log2[i-1] + ((1 << m_log2[i-1]) == i);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3884kb

input:

6
7
1 1 1 -1 1 1 -1
4
1 0 -1 0
4
0 -1 -1 0
1
0
2
0 0
1
-1

output:

3 2
3 1
-1
1 1
2 1
-1

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 606ms
memory: 3756kb

input:

1000000
1
1
1
-1
1
1
1
1
1
1
1
1
1
-1
1
-1
1
0
1
0
1
1
1
0
1
-1
1
0
1
1
1
0
1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
-1
1
1
1
1
1
-1
1
0
1
1
1
0
1
-1
1
0
1
-1
1
1
1
-1
1
0
1
1
1
1
1
-1
1
0
1
-1
1
-1
1
-1
1
-1
1
0
1
0
1
-1
1
0
1
-1
1
0
1
0
1
0
1
0
1
0
1
-1
1
1
1
0
1
0
1
1
1
0
1
-1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
...

output:

1 1
-1
1 1
1 1
1 1
1 1
-1
-1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
-1
1 1
1 1
-1
1 1
1 1
1 1
-1
1 1
-1
1 1
-1
1 1
1 1
1 1
-1
1 1
-1
-1
-1
-1
1 1
1 1
-1
1 1
-1
1 1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
-1
-1
1 1
1 1
-1
1 1
1 1
1 1
1 1
-1
1 1
1 1
1 ...

result:

ok 1000000 lines

Test #3:

score: -100
Wrong Answer
time: 262ms
memory: 3764kb

input:

181249
6
1 0 -1 0 1 0
4
1 -1 -1 -1
8
-1 0 0 0 1 -1 1 1
3
0 1 0
6
1 0 -1 1 -1 0
4
1 -1 -1 -1
9
0 1 0 -1 -1 0 -1 0 1
1
-1
3
0 -1 1
5
0 0 1 -1 1
3
1 -1 0
6
-1 0 0 -1 0 1
8
1 -1 -1 -1 0 1 -1 0
2
0 0
3
-1 1 0
3
0 -1 -1
10
0 1 0 -1 1 1 0 -1 1 0
3
1 0 0
9
1 -1 1 -1 0 -1 0 0 0
3
0 1 0
3
-1 0 0
7
-1 0 -1 -1 ...

output:

4 1
-1
-1
3 2
4 1
-1
3 1
-1
3 2
2 1
3 2
-1
-1
2 1
-1
-1
6 1
3 2
3 1
3 2
-1
-1
-1
-1
2 1
5 3
-1
2 1
2 1
-1
3 2
5 1
1 1
-1
3 2
-1
1 1
-1
2 1
1 1
-1
1 1
-1
1 1
3 2
-1
-1
-1
-1
3 2
5 2
1 1
-1
3 1
-1
-1
1 1
-1
6 1
3 2
-1
3 2
4 3
2 1
-1
5 3
3 1
6 1
-1
2 1
2 1
-1
1 1
-1
3 1
-1
-1
4 1
1 1
2 1
5 2
-1
3 1
4 3...

result:

wrong answer 28th lines differ - expected: '5 4', found: '2 1'