QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751729#8363. interactivecaiminghui0 1ms3852kbC++143.8kb2024-11-15 20:20:152024-11-15 20:20:17

Judging History

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

  • [2024-11-15 20:20:17]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3852kb
  • [2024-11-15 20:20:15]
  • 提交

answer

#include<cstdio>
#include<vector>
#include "interactive.h"
using namespace std;
const int N=510;
int f[N][N];
bool bz[N];
std::vector<int> solve(int n)
{
    for(int i=2;i<n;i++)
    {
        int t1,t2,t3,t4;
        vector<int>b;
        b.clear();
        b.push_back(1),b.push_back(i),b.push_back(i+1);    
        for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
        t1=query(b);
        b.clear();
        b.push_back(i),b.push_back(1),b.push_back(i+1);    
        for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
        t2=query(b);
        if(t1==t2)
        {
            b.clear();
            b.push_back(i+1),b.push_back(i),b.push_back(1);    
            for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
            t3=query(b);
            b.clear();
            b.push_back(i),b.push_back(i+1),b.push_back(1);    
            for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
            t4=query(b);
            if(t3!=t4) f[1][i+1]=f[i+1][1]=1,f[i][i+1]=f[i+1][i]=1;
        }
        else
        {
            if(t1>t2)
            {
                b.clear();
                b.push_back(i+1),b.push_back(1),b.push_back(i);    
                for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
                t3=query(b);
                b.clear();
                b.push_back(1),b.push_back(i+1),b.push_back(i);    
                for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
                t4=query(b);
                f[i][i+1]=f[i+1][i]=1;
                if(t3==t4) f[i][1]=f[1][i]=1;
            }
            else
            {
                b.clear();
                b.push_back(i+1),b.push_back(i),b.push_back(1);    
                for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
                t3=query(b);
                b.clear();
                b.push_back(i),b.push_back(i+1),b.push_back(1);    
                for(int j=2;j<=n;j++) if(j!=i&&j!=i+1) b.push_back(j);
                t4=query(b);
                f[1][i+1]=f[i+1][1]=1;
                if(t3==t4) f[i][1]=f[1][i]=1;
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
    	if(i==2)
    	{
    		i=2;
		}
        vector<int>b;
        b.clear();
        for(int j=1;j<=i;j++)
        {
            if(j&1) for(int k=j;k<=n;k+=i) b.push_back(k);
            else for(int k=(n-j)/i*i+j;k>=j;k-=i) b.push_back(k);
        }
        int nw=1,s1=0;
        while(nw<n-1)
        {
            int l=nw+1,r=n-1,s=0;
            while(l<=r)
            {
                int mid=(l+r)/2;
                vector<int>nww;
                nww.clear();
                for(int i=1;i<=n;i++) bz[i]=0;
                for(int i=1;i<=mid;i++) nww.push_back(b[i]),bz[b[i]]=1;
                nww.push_back(1),bz[1]=1;
                for(int i=1;i<=n;i++) if(!bz[i]) nww.push_back(i);
                int tt=query(nww),ts=0;
                for(int i=mid-1;i<n-1;i++)
                {
                    if(f[nww[i]][nww[i+1]]) ts++;
                }
                if(ts+s1<tt) s=mid,r=mid-1;
                else l=mid+1;
            }
            if(!s) break;
            f[b[s-1]][b[s]]=f[b[s]][b[s-1]]=1;
            nw=s;
            s1++;
        }
    }
    int u=0;
    for(int i=1;i<=n;i++)
    {
        int du=0;
        for(int j=1;j<=n;j++) if(f[i][j]) du++;
        if(du==1)
        {
            u=i;
            break;
        }
    }
    vector<int>anss;
    int lst=0;
    anss.clear();
	anss.push_back(u);
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j!=lst&&f[u][j])
            {
            	lst=u;
                u=j;
                break;
            }
        }
        anss.push_back(u);
    }
    return anss;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 3784kb

input:

1 3
3 1 2

output:

6 759807717 7113

result:

points 1.0

Test #2:

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

input:

1 30
6 28 10 9 13 4 7 1 21 15 20 27 19 5 17 2 22 12 29 23 14 30 18 3 11 24 26 16 8 25

output:

0 0 0

result:

FAIL WA

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 1ms
memory: 3848kb

input:

1 27
17 16 3 20 27 5 2 13 24 21 25 23 19 9 7 4 22 12 26 15 14 11 1 18 6 10 8

output:

0 0 0

result:

FAIL WA