求组hack wrong answer 43rd numbers differ
查看原帖
求组hack wrong answer 43rd numbers differ
877860
Just_Love_You楼主2023/9/3 19:36
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
constexpr int N=1e6+10;
constexpr int mod=1e9+7;
void solve()
{
    int n,m,d;
    cin >> n >> m >> d;
    vector<int> f(m+1);
    for(int i=1;i<=m;i++)
    {
        cin >> f[i];
    }

    int tmp=0;
    if(f[1]==1)
    {
        tmp+=m;
        for(int i=2;i<=m;i++)
        {
            tmp+=(f[i]-f[i-1]-1)/d;
        }
        tmp+=(n-f[m]-1)/d;
    }else
    {
        tmp+=m+1;
        f[0]=1;
        for(int i=1;i<=m;i++)
        {
            tmp+=(f[i]-f[i-1]-1)/d;
        }
        tmp+=(n-f[m]-1)/d;
    }
    // cout << tmp << endl;
    map<int,int> mp;

    if(f[1]==1)
    {
        mp[tmp]++;
    }else
    {
        int num=tmp;
        num--;
        num-=(f[1]-1-1)/d;
        num-=(f[2]-f[1]-1)/d;
        num+=(f[2]-1-1)/d;
        mp[num]++;
    }

    for(int i=2;i<m;i++)
    {
        int num=tmp;
        num--;
        num-=(f[i+1]-f[i]-1)/d;
        num-=(f[i]-f[i-1]-1)/d;
        
        num+=(f[i+1]-f[i-1]-1)/d;
        mp[num]++;
    }
    if(f[m]==n)
    {
        int num=tmp;
        num--;
        num-=(f[m]-f[m-1]-1)/d;
        num+=(n-f[m-1])/d;
        mp[num]++;
    }else
    {
        int num=tmp;
        num--;
        num-=(f[m]-f[m-1]-1)/d;
        num-=(n-f[m])/d;
        num+=(n-f[m-1])/d;
        mp[num]++;
    }
    auto i=mp.begin();
    cout << i->first << ' ' << i->second << endl;
}
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int o;
    cin >> o;
    while(o--)
    solve();
    return 0;
}             
//
//⠀⠀⠀             ⠀⢸⣿⣿⣿⠀⣼⣿⣿⣦⡀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀ ⠀⢸⣿⣿⡟⢰⣿⣿⣿⠟⠁
//⠀⠀⠀⠀⠀⠀⠀⢰⣿⠿⢿⣦⣀⠀⠘⠛⠛⠃⠸⠿⠟⣫⣴⣶⣾⡆
//⠀⠀⠀⠀⠀⠀⠀⠸⣿⡀⠀⠉⢿⣦⡀⠀⠀⠀⠀⠀⠀ ⠛⠿⠿⣿⠃
//⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣦⠀⠀⠹⣿⣶⡾⠛⠛⢷⣦⣄⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣧⠀⠀⠈⠉⣀⡀⠀ ⠀⠙⢿⡇
//⠀⠀⠀⠀⠀⠀⢀⣠⣴⡿⠟⠋⠀⠀⢠⣾⠟⠃⠀⠀⠀⢸⣿⡆
//⠀⠀⠀⢀⣠⣶⡿⠛⠉⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⢸⣿⠇
//⢀⣠⣾⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀⢀⣼⣧⣀⠀⠀⠀⢀⣼⠇ 
//⠈⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡿⠋⠙⠛⠛⠛⠛⠛⠁
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⡿⠋⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⢾⠿⠋⠀
//
2023/9/3 19:36
加载中...