纯模拟
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
const int N = 2e4 + 7;
const int mod = 10007;
int vaild[N];
int n,k;
void solve(){
double x,y,a;
cin >> x >> y >> a;
double me = x + y / 2,sch = (x + y) * (1 - a / 100);
if (me <= sch){
cout << "By myself";
}else
cout << "Through school";
}
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr),cin.tie(nullptr);
int _ = 1;
逾越丁真鉴定为忘开longlong
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
const int N = 2e5 + 7;
const int mod = 10007;
ll a[N];
int n,k;
void solve(){
cin >> n;
int res = 0;
for (int i = 1; i <= n; ++i){
cin >> a[i];
ll x = abs(a[i]);
ll ot = 0,zt = 0;
while (x){
if (x & 1)ot++;
else
zt++;
x >>= 1;
}
if (zt >= ot)res -= 1;
else
res += 1;
}
cout << res;
}
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr),cin.tie(nullptr);
int _ = 1;//cin >> _;
while (_--){
solve();
}
}
题目度错了以为可以无序,晕倒。纯模拟。
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
const int N = 2e5 + 7;
const int mod = 10007;
int n,k;
void solve(){
string check = "NowCoder ";
string s;cin >> s;
int now = 0;
int cnt = 0;
for (auto x : s){
if (x == check[now]){
cnt++;
now++;
}
}
if (cnt == 8){
cout << "QAK\n";
}else
cout << "QIE\n";
}
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr),cin.tie(nullptr);
int _ = 1;cin >> _;
while (_--){
solve();
}
}
与C题同理。
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
const int N = 1e3 + 7;
const int mod = 10007;
int n,k,m;
void solve(){
cin >> n >> m;
vector<string> a;
for (int i = 1; i <= n; ++i){
string s;cin >> s;
a.push_back(s);
}
vector<string> check;
for (int i = 1; i <= m; ++i){
string s;cin >> s;
s.push_back(' ');
check.push_back(s);
}
for (int i = 0;i < n;i++){
int no = 0,cn = 0;
int res = 0;
for (auto x : check){
for (int j = 0;j < a[i].size();j++){
if (a[i][j] == x[no])
no++;
}
if (no == x.size() - 1)res++;
no = 0;
}
cout << res << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr),cin.tie(nullptr);
int _ = 1;
考虑全部化为分钟形式,然后考虑起床与睡觉的时间关系得出答案。
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
const int N = 1e8 + 7;
const int mod = 10007;
int n,k,m,L;
vector<pair<int,int>> d;
void solve(){
cin >> L >> m;
for (int i = 1; i <= m; ++i){
int l,r;cin >> l >> r;
d.emplace_back(l,r);
}
sort(d.begin(),d.end());
int l = d[0].first,r = d[0].second;
int res = L + 1;
for (auto [x,y] : d){
if (x <= r){
l = min(x,l),r = max(y,r);
}else{
res -= r - l + 1;
l = x,r = y;
}
}
res -= r - l + 1;
cout << res;
}
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr),cin.tie(nullptr);
int _ = 1;
样例没有NO的情况,审题没看到要输出正确答案导致全wa。晕倒
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define ll long long
const int N = 1e8 + 7;
const int mod = 10007;
int n,k,m,L;
vector<pair<int,int>> d;
void solve(){
int st1,st2,wt1,wt2,tx,ty;
char st3,wt3;
scanf("%d:%d %c.m",&st1,&st2,&st3);
scanf("%d:%d %c.m",&wt1,&wt2,&wt3);
scanf("%dh%dmin",&tx,&ty);
int res = tx * 60 + ty;
int st,wt;
st = st1 * 60 + st2;
if (st3 == 'a')st += 12 * 60;
wt = wt1 * 60 + wt2;
if (wt3 == 'a')wt += 12 * 60;
int ans;
if (st <= wt){
ans = wt - st;
}else{
ans = 24 * 60 - (st - wt);
}
if (ans == res)cout << "YES";
else{
cout << "NO\n";
cout << ans / 60 << "h" << ans % 60 << "min";
}
}
int main() {
待补.....
推导可以发现区间改变对逆序对的数量奇偶没有任何影响。故分治求出逆序对后判断即可。
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 7;
const ll mod = 1e9;
int n,m;
ll a[N];
ll c[N];
ll solve(int l,int r){
if(l == r)return 0;
int m = (l+r)/2;
int p1 = l , p2 = m+1,cnt = 0;
ll res = solve(l , m) + solve(m +1 , r);
while(p1 <= m && p2 <= r){
if(a[p1] > a[p2])c[++cnt] = a[p1++],res += r - p2 + 1;
else
c[++cnt] = a[p2++];
}
while(p1 <= m)c[++cnt] = a[p1++];
while(p2 <= r)c[++cnt] = a[p2++];
for(int i = l ;i <= r ; i++){
a[i] = c[i - l + 1];
}
return res;
}
void solution(){
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
cin >> m;
int res = solve(1,n);
for (int i = 1;i <= m;i++){
int l,r;cin >> l >> r;
res += (r - l + 1) * (r - l) / 2;