签到题
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
char str[100005];
void solve() {
scanf("%s",str);
if(s[0]=='k') cout<<"KK"<<endl;
if(s[0]=='d') cout<<"DDW"<<endl;
else cout<<"SMWY"<<endl;
}
int main() {
int t;
cin>>t;
while(t--) {
solve();
}
return 0;
}
快递
部分调试代码没删去,不能保证ac
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl '\n'
struct node{
int l,r;
}qj[1000005];
int n,k;
bool cmp (node x,node y) {
if(x.l!=y.l) return x.l<y.l;
else return x.r>y.r;
}
bool check(node x,node y) {
if(max(x.l,y.l) <= min(x.r,y.r))
return true;
else {
cout<<"max is "<<max(x.l,y.l)<<endl;
cout<<"min is "<<min(x.r,y.r)<<endl<<endl;
return false;
}
}
void solve() {
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>qj[i].l>>qj[i].r;
sort(qj+1,qj+1+n,cmp);
int ans=0;
for(int i=1;i<=n;) {
bool ok = 1;
int j=1;
int temp=1;
if(!check(qj[1],qj[4])) cout<<"here!"<<endl;
if((!check(qj[i],qj[i+1])) && (!check(qj[i],qj[i-1])) && 1){
ans++;
i+=1;
continue;
}
while(ok) {
if(check(qj[i],qj[i+j]) && i+j<=n && 1) {
cout<<"yes"<<endl;
temp++;
j++;
}else ok = false ;
}
i+=j;
if(temp%k==0) ans+=temp/k;
else if(temp>k) {
ans+=temp/k;
i-=temp%k;
}
else if(temp<k) ans++;
}
cout<<ans<<endl;
}
signed main() {
ios::sync_with_stdio(0),cin.tie(0) ;
int t;
cin>>t;
while(t--) {
solve();
}
return 0;
}
1011
区间排序,可以理解为贪心
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
struct node{
int x,y,w;
}ma[100005];
void solve() {
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++) {
cin>>ma[i].x>>ma[i].y>>ma[i].w;
}
for(int i=1;i<=q;i++) {
int x,y;
cin>>x>>y;
int ans=0,tt=10000000;
for(int j=1;j<=n;j++) {
tt = min(abs(ma[j].x-x)+abs(ma[j].y-y),ma[j].w);
ans = max(tt,ans);
}
cout<<ans<<endl;
}
}
int main() {
ios::sync_with_stdio(0),cin.tie(0) ;
int t;
cin>>t;
while(t--) {
solve();
}
return 0;
}