vp,为背面的比赛做预备
A.相遇
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <unordered_map>
- #include <cstring>
- #include <cstdio>
- #include <string>
- #include <queue>
- #include <stack>
- #include <map>
- #include <list>
- #include <bitset>
- #include <cmath>
- #include <numeric>
- //#define endl '\n'
- #define fi first
- #define se second
- #define pf push_front
- #define cl clear
- #define bg begin
- #define ed end
- #define sz size
- #define fd find
- #define is insert
- #define pr(x) cout<<x<<'\n'
- #define yes cout << "yes\n"
- #define no cout << "no\n"
- #define Yes cout << "Yes\n"
- #define No cout << "No\n"
- #define YES cout << "YES\n"
- #define NO cout << "NO\n"
- #define pb push_back
- #define eb emplace_back
- #define all(x) x.begin(), x.end()
- #define unq_all(x) x.erase(unique(all(x)), x.end())
- #define sort_all(x) sort(all(x))
- #define reverse_all(x) reverse(all(x))
- #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
- #define INF 0x7fffffff
- #define INFLL 0x7fffffffffffffffLL
- #define RED cout << "\033[91m"
- #define GREEN cout << "\033[92m"
- #define YELLOW cout << "\033[93m"
- #define BLUE cout << "\033[94m"
- #define MAGENTA cout << "\033[95m"
- #define CYAN cout << "\033[96m"
- #define RESET cout << "\033[0m"
- // 红色
- #define DEBUG1(x) \
- RED; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 绿色
- #define DEBUG2(x) \
- GREEN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 蓝色
- #define DEBUG3(x) \
- BLUE; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 品红
- #define DEBUG4(x) \
- MAGENTA; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 青色
- #define DEBUG5(x) \
- CYAN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 黄色
- #define DEBUG6(x) \
- YELLOW; \
- cout << #x << " : " << x << endl; \
- RESET;
- using namespace std;
- const double Eps = 1e-8;
- const double PI = acos(-1.0);
- const int N = 1e6+5;
- const int MOD = 1e9+7;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef pair<string, string> pss;
- typedef pair<string, int> psi;
- typedef pair<string, ll> psl;
- typedef vector<bool> vb;
- typedef vector<int> vi;
- typedef vector<ll> vl;
- typedef vector<string> vs;
- typedef vector<pii> vpii;
- typedef vector<pll> vpll;
- typedef vector<pss> vpss;
- typedef vector<vi> vvi;
- typedef vector<vl> vvl;
- typedef queue<int> qi;
- typedef queue<ll> ql;
- typedef queue<pii> qpii;
- typedef queue<pll> qpll;
- typedef queue<psi> qpsi;
- typedef queue<psl> qpsl;
- typedef priority_queue<int> pqi;
- typedef priority_queue<ll> pql;
- typedef priority_queue<string> pqs;
- typedef priority_queue<pii> pqpii;
- typedef priority_queue<psi> pqpsi;
- typedef priority_queue<pll> pqpl;
- typedef priority_queue<psi> pqpsl;
- typedef map<int, int> mii;
- typedef map<int, bool> mib;
- typedef map<ll, ll> mll;
- typedef map<ll, bool> mlb;
- typedef map<char, int> mci;
- typedef map<char, ll> mcl;
- typedef map<char, bool> mcb;
- typedef map<string, int> msi;
- typedef map<string, ll> msl;
- typedef map<int, bool> mib;
- typedef unordered_map<int, int> umii;
- typedef unordered_map<ll, ll> uml;
- typedef unordered_map<char, int> umci;
- typedef unordered_map<char, ll> umcl;
- typedef unordered_map<string, int> umsi;
- typedef unordered_map<string, ll> umsl;
- template <typename T>
- inline void read(T &x)
- {
- T f = 1;
- x = 0;
- char ch = getchar();
- while (0 == isdigit(ch))
- {
- if (ch == '-')
- f = -1;
- ch = getchar();
- }
- while (0 != isdigit(ch))
- x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
- x *= f;
- }
- template <typename T>
- inline void write(T x)
- {
- if (x < 0)
- {
- x = ~(x - 1);
- putchar('-');
- }
- if (x > 9)
- write(x / 10);
- putchar(x % 10 + '0');
- }
- int a,b;
- void solve()
- {
- cin>>a>>b;
- if(a==b) pr("p");
- else if(a<b&&b==a+1||a==3&&b==1) pr("a");
- else pr("b");
- }
- int main()
- {
- IOS;
- int _=1;
- // cin>>_;
- while(_--)
- {
- solve();
- }
- return 0;
- }
复制代码
B.宝石
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <unordered_map>
- #include <cstring>
- #include <cstdio>
- #include <string>
- #include <queue>
- #include <stack>
- #include <map>
- #include <list>
- #include <bitset>
- #include <cmath>
- #include <numeric>
- //#define endl '\n'
- #define fi first
- #define se second
- #define pf push_front
- #define cl clear
- #define bg begin
- #define ed end
- #define sz size
- #define fd find
- #define is insert
- #define pr(x) cout<<x<<'\n'
- #define yes cout << "yes\n"
- #define no cout << "no\n"
- #define Yes cout << "Yes\n"
- #define No cout << "No\n"
- #define YES cout << "YES\n"
- #define NO cout << "NO\n"
- #define pb push_back
- #define eb emplace_back
- #define all(x) x.begin(), x.end()
- #define unq_all(x) x.erase(unique(all(x)), x.end())
- #define sort_all(x) sort(all(x))
- #define reverse_all(x) reverse(all(x))
- #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
- #define INF 0x7fffffff
- #define INFLL 0x7fffffffffffffffLL
- #define RED cout << "\033[91m"
- #define GREEN cout << "\033[92m"
- #define YELLOW cout << "\033[93m"
- #define BLUE cout << "\033[94m"
- #define MAGENTA cout << "\033[95m"
- #define CYAN cout << "\033[96m"
- #define RESET cout << "\033[0m"
- // 红色
- #define DEBUG1(x) \
- RED; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 绿色
- #define DEBUG2(x) \
- GREEN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 蓝色
- #define DEBUG3(x) \
- BLUE; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 品红
- #define DEBUG4(x) \
- MAGENTA; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 青色
- #define DEBUG5(x) \
- CYAN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 黄色
- #define DEBUG6(x) \
- YELLOW; \
- cout << #x << " : " << x << endl; \
- RESET;
- using namespace std;
- const double Eps = 1e-8;
- const double PI = acos(-1.0);
- const int N = 1e6+5;
- const int MOD = 1e9+7;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef pair<string, string> pss;
- typedef pair<string, int> psi;
- typedef pair<string, ll> psl;
- typedef vector<bool> vb;
- typedef vector<int> vi;
- typedef vector<ll> vl;
- typedef vector<string> vs;
- typedef vector<pii> vpii;
- typedef vector<pll> vpll;
- typedef vector<pss> vpss;
- typedef vector<vi> vvi;
- typedef vector<vl> vvl;
- typedef queue<int> qi;
- typedef queue<ll> ql;
- typedef queue<pii> qpii;
- typedef queue<pll> qpll;
- typedef queue<psi> qpsi;
- typedef queue<psl> qpsl;
- typedef priority_queue<int> pqi;
- typedef priority_queue<ll> pql;
- typedef priority_queue<string> pqs;
- typedef priority_queue<pii> pqpii;
- typedef priority_queue<psi> pqpsi;
- typedef priority_queue<pll> pqpl;
- typedef priority_queue<psi> pqpsl;
- typedef map<int, int> mii;
- typedef map<int, bool> mib;
- typedef map<ll, ll> mll;
- typedef map<ll, bool> mlb;
- typedef map<char, int> mci;
- typedef map<char, ll> mcl;
- typedef map<char, bool> mcb;
- typedef map<string, int> msi;
- typedef map<string, ll> msl;
- typedef map<int, bool> mib;
- typedef unordered_map<int, int> umii;
- typedef unordered_map<ll, ll> uml;
- typedef unordered_map<char, int> umci;
- typedef unordered_map<char, ll> umcl;
- typedef unordered_map<string, int> umsi;
- typedef unordered_map<string, ll> umsl;
- template <typename T>
- inline void read(T &x)
- {
- T f = 1;
- x = 0;
- char ch = getchar();
- while (0 == isdigit(ch))
- {
- if (ch == '-')
- f = -1;
- ch = getchar();
- }
- while (0 != isdigit(ch))
- x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
- x *= f;
- }
- template <typename T>
- inline void write(T x)
- {
- if (x < 0)
- {
- x = ~(x - 1);
- putchar('-');
- }
- if (x > 9)
- write(x / 10);
- putchar(x % 10 + '0');
- }
- int a,b;
- void solve()
- {
- cin>>a>>b;
- cout<<min(a+5*b,min(11*a,a+b+a+a+b+a+a+b));
- }
- int main()
- {
- IOS;
- int _=1;
- // cin>>_;
- while(_--)
- {
- solve();
- }
- return 0;
- }
复制代码 C.相助 / E.相依
dp,想了想维护最小值即可 ,绘图就看出来了
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <unordered_map>
- #include <cstring>
- #include <cstdio>
- #include <string>
- #include <queue>
- #include <stack>
- #include <map>
- #include <list>
- #include <bitset>
- #include <cmath>
- #include <numeric>
- //#define endl '\n'
- #define fi first
- #define se second
- #define pf push_front
- #define cl clear
- #define bg begin
- #define ed end
- #define sz size
- #define fd find
- #define is insert
- #define pr(x) cout<<x<<'\n'
- #define yes cout << "yes\n"
- #define no cout << "no\n"
- #define Yes cout << "Yes\n"
- #define No cout << "No\n"
- #define YES cout << "YES\n"
- #define NO cout << "NO\n"
- #define pb push_back
- #define eb emplace_back
- #define all(x) x.begin(), x.end()
- #define unq_all(x) x.erase(unique(all(x)), x.end())
- #define sort_all(x) sort(all(x))
- #define reverse_all(x) reverse(all(x))
- #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
- #define INF 0x7fffffff
- #define INFLL 0x7fffffffffffffffLL
- #define RED cout << "\033[91m"
- #define GREEN cout << "\033[92m"
- #define YELLOW cout << "\033[93m"
- #define BLUE cout << "\033[94m"
- #define MAGENTA cout << "\033[95m"
- #define CYAN cout << "\033[96m"
- #define RESET cout << "\033[0m"
- // 红色
- #define DEBUG1(x) \
- RED; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 绿色
- #define DEBUG2(x) \
- GREEN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 蓝色
- #define DEBUG3(x) \
- BLUE; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 品红
- #define DEBUG4(x) \
- MAGENTA; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 青色
- #define DEBUG5(x) \
- CYAN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 黄色
- #define DEBUG6(x) \
- YELLOW; \
- cout << #x << " : " << x << endl; \
- RESET;
- using namespace std;
- const double Eps = 1e-8;
- const double PI = acos(-1.0);
- const int N = 1e6+5;
- const int MOD = 1e9+7;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef pair<string, string> pss;
- typedef pair<string, int> psi;
- typedef pair<string, ll> psl;
- typedef vector<bool> vb;
- typedef vector<int> vi;
- typedef vector<ll> vl;
- typedef vector<string> vs;
- typedef vector<pii> vpii;
- typedef vector<pll> vpll;
- typedef vector<pss> vpss;
- typedef vector<vi> vvi;
- typedef vector<vl> vvl;
- typedef queue<int> qi;
- typedef queue<ll> ql;
- typedef queue<pii> qpii;
- typedef queue<pll> qpll;
- typedef queue<psi> qpsi;
- typedef queue<psl> qpsl;
- typedef priority_queue<int> pqi;
- typedef priority_queue<ll> pql;
- typedef priority_queue<string> pqs;
- typedef priority_queue<pii> pqpii;
- typedef priority_queue<psi> pqpsi;
- typedef priority_queue<pll> pqpl;
- typedef priority_queue<psi> pqpsl;
- typedef map<int, int> mii;
- typedef map<int, bool> mib;
- typedef map<ll, ll> mll;
- typedef map<ll, bool> mlb;
- typedef map<char, int> mci;
- typedef map<char, ll> mcl;
- typedef map<char, bool> mcb;
- typedef map<string, int> msi;
- typedef map<string, ll> msl;
- typedef map<int, bool> mib;
- typedef unordered_map<int, int> umii;
- typedef unordered_map<ll, ll> uml;
- typedef unordered_map<char, int> umci;
- typedef unordered_map<char, ll> umcl;
- typedef unordered_map<string, int> umsi;
- typedef unordered_map<string, ll> umsl;
- template <typename T>
- inline void read(T &x)
- {
- T f = 1;
- x = 0;
- char ch = getchar();
- while (0 == isdigit(ch))
- {
- if (ch == '-')
- f = -1;
- ch = getchar();
- }
- while (0 != isdigit(ch))
- x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
- x *= f;
- }
- template <typename T>
- inline void write(T x)
- {
- if (x < 0)
- {
- x = ~(x - 1);
- putchar('-');
- }
- if (x > 9)
- write(x / 10);
- putchar(x % 10 + '0');
- }
- //vi vec[500010];
- int n,f[500010];
- int dp[500010],minn[500010];
- void solve()
- {
- cin>>n;
- for(int i=1;i<=n;i++)
- {
- cin>>f[i];
- // vec[f[i]].pb(i);
- }
- if(n==1)
- {
- pr(-1);
- return;
- }
- for(int i=0;i<=n;i++) dp[i]=minn[i]=10000000;
- minn[f[1]]=0;
- for(int i=2;i<=n;i++)
- {
- dp[i]=minn[f[i]]+1;
- minn[f[i]]=min(minn[f[i]],dp[i-1]);
- // cout<<dp[i]<<endl;
- }
- if(dp[n]>=500000) pr(-1);
- else pr(dp[n]);
- }
- int main()
- {
- IOS;
- int _=1;
- // cin>>_;
- while(_--)
- {
- solve();
- }
- return 0;
- }
- /*
- 1 1 2 1 2
- */
复制代码 D.异或炸弹(easy)
看了看hard版本,像是二维差分但还得加点东西,他这个外形是菱形而二位差分得是矩形,大概得转一下,不太会
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <unordered_map>
- #include <cstring>
- #include <cstdio>
- #include <string>
- #include <queue>
- #include <stack>
- #include <map>
- #include <list>
- #include <bitset>
- #include <cmath>
- #include <numeric>
- //#define endl '\n'
- #define fi first
- #define se second
- #define pf push_front
- #define cl clear
- #define bg begin
- #define ed end
- #define sz size
- #define fd find
- #define is insert
- #define pr(x) cout<<x<<'\n'
- #define yes cout << "yes\n"
- #define no cout << "no\n"
- #define Yes cout << "Yes\n"
- #define No cout << "No\n"
- #define YES cout << "YES\n"
- #define NO cout << "NO\n"
- #define pb push_back
- #define eb emplace_back
- #define all(x) x.begin(), x.end()
- #define unq_all(x) x.erase(unique(all(x)), x.end())
- #define sort_all(x) sort(all(x))
- #define reverse_all(x) reverse(all(x))
- #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
- #define INF 0x7fffffff
- #define INFLL 0x7fffffffffffffffLL
- #define RED cout << "\033[91m"
- #define GREEN cout << "\033[92m"
- #define YELLOW cout << "\033[93m"
- #define BLUE cout << "\033[94m"
- #define MAGENTA cout << "\033[95m"
- #define CYAN cout << "\033[96m"
- #define RESET cout << "\033[0m"
- // 红色
- #define DEBUG1(x) \
- RED; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 绿色
- #define DEBUG2(x) \
- GREEN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 蓝色
- #define DEBUG3(x) \
- BLUE; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 品红
- #define DEBUG4(x) \
- MAGENTA; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 青色
- #define DEBUG5(x) \
- CYAN; \
- cout << #x << " : " << x << endl; \
- RESET;
- // 黄色
- #define DEBUG6(x) \
- YELLOW; \
- cout << #x << " : " << x << endl; \
- RESET;
- using namespace std;
- const double Eps = 1e-8;
- const double PI = acos(-1.0);
- const int N = 1e6+5;
- const int MOD = 1e9+7;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef pair<string, string> pss;
- typedef pair<string, int> psi;
- typedef pair<string, ll> psl;
- typedef vector<bool> vb;
- typedef vector<int> vi;
- typedef vector<ll> vl;
- typedef vector<string> vs;
- typedef vector<pii> vpii;
- typedef vector<pll> vpll;
- typedef vector<pss> vpss;
- typedef vector<vi> vvi;
- typedef vector<vl> vvl;
- typedef queue<int> qi;
- typedef queue<ll> ql;
- typedef queue<pii> qpii;
- typedef queue<pll> qpll;
- typedef queue<psi> qpsi;
- typedef queue<psl> qpsl;
- typedef priority_queue<int> pqi;
- typedef priority_queue<ll> pql;
- typedef priority_queue<string> pqs;
- typedef priority_queue<pii> pqpii;
- typedef priority_queue<psi> pqpsi;
- typedef priority_queue<pll> pqpl;
- typedef priority_queue<psi> pqpsl;
- typedef map<int, int> mii;
- typedef map<int, bool> mib;
- typedef map<ll, ll> mll;
- typedef map<ll, bool> mlb;
- typedef map<char, int> mci;
- typedef map<char, ll> mcl;
- typedef map<char, bool> mcb;
- typedef map<string, int> msi;
- typedef map<string, ll> msl;
- typedef map<int, bool> mib;
- typedef unordered_map<int, int> umii;
- typedef unordered_map<ll, ll> uml;
- typedef unordered_map<char, int> umci;
- typedef unordered_map<char, ll> umcl;
- typedef unordered_map<string, int> umsi;
- typedef unordered_map<string, ll> umsl;
- template <typename T>
- inline void read(T &x)
- {
- T f = 1;
- x = 0;
- char ch = getchar();
- while (0 == isdigit(ch))
- {
- if (ch == '-')
- f = -1;
- ch = getchar();
- }
- while (0 != isdigit(ch))
- x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
- x *= f;
- }
- template <typename T>
- inline void write(T x)
- {
- if (x < 0)
- {
- x = ~(x - 1);
- putchar('-');
- }
- if (x > 9)
- write(x / 10);
- putchar(x % 10 + '0');
- }
- int n,m,f[3010][3010];
- int x,y,r,cnt;
- void solve()
- {
- cin>>n>>m;
- for(int i=1;i<=m;i++)
- {
- // cin>>p[i].fi>>p[i].se;
- cin>>x>>y>>r;
- for(int j=max(x-r,1);j<=min(x+r,n);j++)
- {
- int l=r-abs(j-x);
- f[j][max(1,y-l)]++;
- f[j][min(n+1,y+l+1)]--;
- }
- }
- for(int i=1;i<=n;i++)
- {
- int p=0;
- for(int j=1;j<=n;j++)
- {
- p+=f[i][j];
- if(p&1) cnt++;
- }
- }
- pr(cnt);
- }
- int main()
- {
- IOS;
- int _=1;
- // cin>>_;
- while(_--)
- {
- solve();
- }
- return 0;
- }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |