#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1000010];
signed main()
{
#define wanye
int n,home;
cin>>n>>home;
for(int i=1;i<=n;i++)
{
int begin,end;
string mid;
cin>>begin>>mid>>end;
a[begin]++;a[end]++;
}
if(n%2==0) cout<<home;
else
for(int i=1;i<1000010;i++)
if(a[i]%2==1&&i!=home)
{
cout<<i;
return 0;
}
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[210][210],dp[210][210];
int so[210*210];
bool cmp(int ys,int bt)
{
return ys>=bt;
}
signed main()
{
#define wanye
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)
for(int j=1;j<=k;j++)
cin>>a[i][j];
sort(a[1]+1,a[1]+k+1,cmp);
for(int i=1;i<=k;i++) dp[1][i]=a[1][i];
for(int i=2;i<=n;i++)
{
for(int j=1;j<=k;j++)
for(int f=1;f<=k;f++)
so[(j-1)*k+f]=dp[i-1][j]+a[i][f];
sort(so+1,so+k*k+1,cmp);
int cnt=unique(so+1,so+k*k+1)-so;
for(int j=1;j<=k;j++) dp[i][j]=so[j];
}
for(int i=1;i<=k;i++) cout<<dp[n][i]<<" ";
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct city{
int x,y,w;
int sortw;
}a[100010];
bool cmp1(city A,city B)
{
if(A.x!=B.x) return A.x<B.x;
else return A.y<=B.y;
}
bool cmp2(city A,city B)
{
return A.w<=B.w;
}
signed main()
{
#define wanye
int n,m;
cin>>n>>m;
for(int i=1;i<=m;i++)
cin>>a[i].x>>a[i].y,a[i].w=i;
sort(a+1,a+m+1,cmp1);
for(int i=1;i<=m;i++)
if(a[i].x==a[i-1].x) a[i].sortw=a[i-1].sortw+1;
else a[i].sortw=1;
sort(a+1,a+m+1,cmp2);
for(int i=1;i<=m;i++)
printf("%06d%06d\n",a[i].x,a[i].sortw);
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct cake{
int l,r;
};
stack<cake> s;
signed main()
{
#define wanye
int T;
cin>>T;
while(T--)
{
int op;
cin>>op;
if(op==1)
{
int l,r;
cin>>l>>r;
s.push((cake){l,r});
}
else
{
int k,money=0;
cin>>k;
while(1)
{
int tl=s.top().l,tr=s.top().r;
s.pop();
if(k>=tr-tl+1) money+=(tl+tr)*(tr-tl+1)/2,k-=tr-tl+1;
else
{
money+=(tr+tr-k+1)*k/2;
s.push((cake){tl,tr-k});
k=0;
}
if(!k) break;
}
cout<<money<<endl;
}
}
return 0;
}
开发者:Federico2903 & Murasame & quanac-lcx