2025 ICPC Asia Pacific Championship - Online Mirror (Unrated, Online Mirror, ICPC Rules, Teams Preferred)2025/3/19组队记录

比赛链接:https://codeforces.com/contest/2073
这次组队记录不写思路

A.Control Towers

#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<functional>
#include<stack>
#include<unordered_map>
#include<string>
#define ll                        long long 
#define lowbit(x) (x & -x)
#define endl "\n"//                           交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 1e9 + 7;
//const ll p=rnd()%mod;
#define F first
#define S second
ll ksm(ll x, ll y)
{
    ll ans = 1;
    x %= mod;
    while (y)
    {
        if (y & 1)
        {
            ans = ans * x % mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
void fio()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
struct s
{
    ll l, r, id;
    friend bool operator<(const s& a, const s& b)
    {

        if (a.l != b.l)
            return a.l < b.l;
        else return a.r < b.r;
    }
};
string f[2005];
int main()
{
    fio();
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        for(ll i=1;i<=n;i++)
        {
            cin>>f[i];
            f[i]='0'+f[i];
        }
        vector<ll>p1(n+5,0),p2(m+5,0);//行与列
        for(ll i=1;i<=n;i++)
        {
            for(ll j=1;j<=m;j++)
            {
                if(f[i][j]=='.')p2[j]++,p1[i]++;
            }
        }
        ll ans=0;
        for(ll i=1;i<=n;i++)
        {
            ll cf=0,kk=0;
            //ll dd=0;
            if(p1[i]>=2)//2和3同行,1和4都在列
            {
            for(ll j=1;j<=m;j++)
            {
                //cout<<p2[j]<<" ";
                if(p2[j]>=2&&f[i][j]=='.')
                {
                    cf+=kk*(p2[j]-1);
                    kk+=p2[j]-1;
                }
                if(p1[i]>=3&&p2[j]>=2&&f[i][j]=='.')
                {
                    ans+=(p2[j]-1)*(p1[i]-1)*(p1[i]-2)*2;
                }
            }
            //cout<<endl;
            ans+=2*cf;  
            }
            if(p1[i]>=4)//同行
            {
                ans+=p1[i]*(p1[i]-1)*(p1[i]-2)*(p1[i]-3);
            }
        }
       // cout<<ans<<endl;
        for(ll i=1;i<=m;i++)
        {
            ll cf=0,kk=0;
            //ll dd=0;
            if(p2[i]>=2)//2和3同行,1和4都在列
            {
            for(ll j=1;j<=n;j++)
            {
                if(p1[j]>=2&&f[j][i]=='.')
                {
                    cf+=kk*(p1[j]-1);
                    kk+=p1[j]-1;
                }
                if(p2[i]>=3&&p1[j]>=2&&f[j][i]=='.')
                {
                    ans+=(p1[j]-1)*(p2[i]-1)*(p2[i]-2)*2;
                }
            }
            ans+=2*cf;
            }
            if(p2[i]>=4)//同行
            {
                ans+=p2[i]*(p2[i]-1)*(p2[i]-2)*(p2[i]-3);
            }
        }
        cout<<ans<<endl;
    }
}

G.Corrupted File

#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<functional>
#include<stack>
#include<unordered_map>
#include<string>
#define ll                        long long 
#define lowbit(x) (x & -x)
#define endl "\n"//                           交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 1e9 + 7;
//const ll p=rnd()%mod;
#define F first
#define S second
ll ksm(ll x, ll y)
{
    ll ans = 1;
    x %= mod;
    while (y)
    {
        if (y & 1)
        {
            ans = ans * x % mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
void fio()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
struct s
{
    ll l, r, id;
    friend bool operator<(const s& a, const s& b)
    {

        if (a.l != b.l)
            return a.l < b.l;
        else return a.r < b.r;
    }
};
int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        string f1,f2;
        cin>>f1>>f2;
        ll l=0;
        ll pd=0;
        ll wz=-1;
        for(ll i=0;i<f1.size();i++)
        {
            if(f2.size()==l)
            {
                if(f2[l-1]=='0')continue;
                if(f1[i]==f2[l-1])continue;
                else 
                {
                    if(wz==-1)
                    {
                        pd=1;
                        break;
                    }
                    else l=wz+1;
                }
                continue;
            }
            if(f1[i]=='1')
            {
                if(f1[i]==f2[l])l++;
                else continue;
            }
            else
            {
                if(f1[i]==f2[l])wz=l,l++;
                else 
                {
                    if(wz==-1)
                    {
                        pd=1;
                        break;
                    }
                    else l=wz+1;
                }
            }
        }
        if(l!=f2.size())pd=1;
        if(pd)
        {
            cout<<"no"<<endl;
        }
        else cout<<"yes"<<endl;
    }
}

H.Secret Lilies and Roses(补充)

//赛后补题
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<functional>
#include<stack>
#include<unordered_map>
#include<string>
#define ll                        long long 
#define lowbit(x) (x & -x)
// #define endl "\n"//                           交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 1e9 + 7;
//const ll p=rnd()%mod;
#define F first
#define S second
ll ksm(ll x, ll y)
{
    ll ans = 1;
    x %= mod;
    while (y)
    {
        if (y & 1)
        {
            ans = ans * x % mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
void fio()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
struct s
{
    ll l, r, id;
    friend bool operator<(const s& a, const s& b)
    {

        if (a.l != b.l)
            return a.l < b.l;
        else return a.r < b.r;
    }
};
//lily  0  rose 1
int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int l=1,r=n,mid,ans;
        string x;
        while(l<=r){
            mid=(l+r)/2;
            cout<<"type "<<mid<<endl;
            cout.flush();
            cin>>x;
            if(x=="lily"){
                r=mid-1;
            }else{
                l=mid+1;
            }
        }
        l--;
        // cout<<l;
        int cnt;
        if(l==0){
            cout<<"multi 1"<<endl;
            cout.flush();
            cin>>cnt;
            if(cnt==0){
                cout<<"answer 0"<<endl;
            }else{
                cout<<"answer "<<cnt<<endl;
            }
        }else{
            if(l==n){
                cout<<"multi "<<n-1<<endl;
                cout.flush();
                cin>>cnt;
                if(cnt==0){
                    cout<<"answer "<<n<<endl;
                }else{
                    cout<<"answer "<<n-cnt<<endl;
                }
            }else{
                cout<<"multi "<<l-1<<endl;
                cout.flush();
                cin>>cnt;
                int a,b;
                if(cnt==0){
                    cout<<"multi "<<l+1<<endl;
                    cout.flush();
                    cin>>a;
                    if(a==0){
                        cout<<"answer "<<l<<endl;
                    }else{
                        cout<<"answer "<<l+a<<endl;
                    }
                }else{
                    cout<<"multi "<<l<<endl;
                    cout.flush();
                    cin>>a;
                    int zeroleft=cnt-a;
                    int one=cnt/(cnt-a);
                    cout<<"answer "<<l-1-zeroleft+one<<endl;
                }
            }
        }
    }
}

J.Gathering Sharks

#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<functional>
#include<stack>
#include<unordered_map>
#include<string>
#define ll                        long long 
#define lowbit(x) (x & -x)
#define endl "\n"//                           交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 1e9 + 7;
//const ll p=rnd()%mod;
#define F first
#define S second
ll ksm(ll x, ll y)
{
    ll ans = 1;
    x %= mod;
    while (y)
    {
        if (y & 1)
        {
            ans = ans * x % mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
void fio()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
struct s
{
    ll l, r, id;
    friend bool operator<(const s& a, const s& b)
    {

        if (a.l != b.l)
            return a.l < b.l;
        else return a.r < b.r;
    }
};
int a[600];
int dp[600][600];//0left 1 right
int main()
{
    fio();
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++){
            int x;
            cin>>x;
            a[x]=i;//posi
       }
       for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                dp[i][j]=100000000;
                // dp[i][j]=100000000;
                if(i==j)dp[i][j]=0;
            }
        }
       for(int i=2;i<=n;i++){
        if(a[i]>a[i-1]){
            dp[i][i-1]=a[i]-a[i-1];
        }else{
            dp[i][i-1]=a[i-1]-a[i];
        }
       }
       for(int len=2;len<=n;len++){
        for(int j=1;j+len-1<=n;j++){
            int r=j+len-1;
            for(int k=j;k<r;k++){
               dp[j][r]=min(dp[j][r],dp[j][k]+dp[k+1][r]+abs(a[k+1]-a[j]));
            }
        }
       }
       cout<<dp[1][n];
    }
}

L.Boarding Queue

#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<deque>
#include<cctype>
#include<string.h>
#include<math.h>
#include<time.h>
#include<random>
#include<functional>
#include<stack>
#include<unordered_map>
#include<string>
#define ll                        long long 
#define lowbit(x) (x & -x)
#define endl "\n"//                           交互题记得删除
using namespace std;
mt19937 rnd(time(0));
const ll mod = 1e9 + 7;
//const ll p=rnd()%mod;
#define F first
#define S second
ll ksm(ll x, ll y)
{
    ll ans = 1;
    x %= mod;
    while (y)
    {
        if (y & 1)
        {
            ans = ans * x % mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
void fio()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
struct s
{
    ll l, r, id;
    friend bool operator<(const s& a, const s& b)
    {

        if (a.l != b.l)
            return a.l < b.l;
        else return a.r < b.r;
    }
};
string f[2005];
ll e[4]={0,1,0,-1};
ll r[4]={1,0,-1,0};
int main()
{
    fio();
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
       ll n,m,k,p;
       cin>>n>>m>>k>>p;
       vector<vector<ll>>a(n+5,vector<ll>(m+5,0));
       vector<bool>vis(k+2,0);
       for(ll i=1;i<=n;i++)
       {
        for(ll j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
       }
       ll cnt=0;
       for(ll i=1;i<=n;i++)
       {
        for(ll j=1;j<=m;j++)
        {
            if(a[i][j]>p||a[i][j]==0)continue;
            for(ll z=0;z<4;z++)
            {
                ll nx=e[z]+i;
                ll ny=r[z]+j;
                if(nx<1||nx>n||ny<1||ny>m||a[nx][ny]==0)continue;
                ll dis=a[nx][ny]-a[i][j];
                if(p+dis>k||p+dis<1)continue;
                if(vis[p+dis])continue;
                else
                { 
                    //cout<<p+dis<<endl;
                    vis[p+dis]=1,cnt++;
                }
            }
        }
       }
       cout<<cnt<<"/"<<k-1<<endl;
    }
}
posted @ 2025-03-19 20:06  长皆  阅读(199)  评论(0)    收藏  举报