codeforces #586 ABC~D
A. Cards
Description
给定一个仅由onezr组成的字符串,one-1,zero-0。
问能组成的最大的数值是多少。
Solution
模拟贪心。
B. Multiplication Table
Description
给定一个n×n的矩阵m,其主对角线上元素为0。
求一个a向量使得a[i]×a[j]=m[i][j],i!=j。
Solution
a[i]×a[j]=m[i][j],a[i]×a[k]=m[i][k]a[j]×a[k]=m[j][k]→a[i]2=m[i][j]×m[i][k]m[j][k]
C. Substring Game in the Lesson
Description
Solution
显然r不能增大。
那么只要左边存在一个子串字典序小于s[k],那么Ann跳到最左一个即可。

1 #include <algorithm> 2 #include <cctype> 3 #include <cmath> 4 #include <cstdio> 5 #include <cstdlib> 6 #include <cstring> 7 #include <iostream> 8 #include <map> 9 #include <numeric> 10 #include <queue> 11 #include <set> 12 #include <stack> 13 #if __cplusplus >= 201103L 14 #include <unordered_map> 15 #include <unordered_set> 16 #endif 17 #include <vector> 18 #define lson rt << 1, l, mid 19 #define rson rt << 1 | 1, mid + 1, r 20 #define LONG_LONG_MAX 9223372036854775807LL 21 #define pblank putchar(' ') 22 #define ll LL 23 #define fastIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) 24 using namespace std; 25 typedef long long ll; 26 typedef long double ld; 27 typedef unsigned long long ull; 28 typedef pair<int, int> P; 29 int n, m, k; 30 const int maxn = 5e5 + 10; 31 template <class T> 32 inline T read() 33 { 34 int f = 1; 35 T ret = 0; 36 char ch = getchar(); 37 while (!isdigit(ch)) 38 { 39 if (ch == '-') 40 f = -1; 41 ch = getchar(); 42 } 43 while (isdigit(ch)) 44 { 45 ret = (ret << 1) + (ret << 3) + ch - '0'; 46 ch = getchar(); 47 } 48 ret *= f; 49 return ret; 50 } 51 template <class T> 52 inline void write(T n) 53 { 54 if (n < 0) 55 { 56 putchar('-'); 57 n = -n; 58 } 59 if (n >= 10) 60 { 61 write(n / 10); 62 } 63 putchar(n % 10 + '0'); 64 } 65 template <class T> 66 inline void writeln(const T &n) 67 { 68 write(n); 69 puts(""); 70 } 71 template <typename T> 72 void _write(const T &t) 73 { 74 write(t); 75 } 76 template <typename T, typename... Args> 77 void _write(const T &t, Args... args) 78 { 79 write(t), pblank; 80 _write(args...); 81 } 82 template <typename T, typename... Args> 83 inline void write_line(const T &t, const Args &... data) 84 { 85 _write(t, data...); 86 } 87 char s[maxn]; 88 int pre[maxn], tmp[maxn]; 89 int main(int argc, char const *argv[]) 90 { 91 #ifndef ONLINE_JUDGE 92 freopen("in.txt", "r", stdin); 93 // freopen("out.txt", "w", stdout); 94 #endif 95 fastIO; 96 cin >> s + 1; 97 n = strlen(s + 1); 98 tmp[0] = 1e9; 99 for (int i = 1; i <= n; i++) 100 tmp[i] = min(tmp[i - 1], (int)s[i]); 101 for (int i = 1; i <= n; i++) 102 { 103 int f = tmp[i] >= s[i]; 104 if (f) 105 puts("Mike"); 106 else 107 puts("Ann"); 108 } 109 return 0; 110 }
D. Alex and Julian
Description
给定一个数字集合S。
当集合内元素满足|i−j|inS时,i向j连一条无向边。
求删除最少的数字使集合内剩余的数构成一个二分图(不存在奇环)
Solution
不是很懂还,再想想。

1 #include <algorithm> 2 #include <cctype> 3 #include <cmath> 4 #include <cstdio> 5 #include <cstdlib> 6 #include <cstring> 7 #include <iostream> 8 #include <map> 9 #include <numeric> 10 #include <queue> 11 #include <set> 12 #include <stack> 13 #if __cplusplus >= 201103L 14 #include <unordered_map> 15 #include <unordered_set> 16 #endif 17 #include <vector> 18 #define lson rt << 1, l, mid 19 #define rson rt << 1 | 1, mid + 1, r 20 #define LONG_LONG_MAX 9223372036854775807LL 21 #define pblank putchar(' ') 22 #define ll LL 23 #define fastIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) 24 using namespace std; 25 typedef long long ll; 26 typedef long double ld; 27 typedef unsigned long long ull; 28 typedef pair<int, int> P; 29 int n, m, k; 30 const int maxn = 2e5 + 10; 31 template <class T> 32 inline T read() 33 { 34 int f = 1; 35 T ret = 0; 36 char ch = getchar(); 37 while (!isdigit(ch)) 38 { 39 if (ch == '-') 40 f = -1; 41 ch = getchar(); 42 } 43 while (isdigit(ch)) 44 { 45 ret = (ret << 1) + (ret << 3) + ch - '0'; 46 ch = getchar(); 47 } 48 ret *= f; 49 return ret; 50 } 51 template <class T> 52 inline void write(T n) 53 { 54 if (n < 0) 55 { 56 putchar('-'); 57 n = -n; 58 } 59 if (n >= 10) 60 { 61 write(n / 10); 62 } 63 putchar(n % 10 + '0'); 64 } 65 template <class T> 66 inline void writeln(const T &n) 67 { 68 write(n); 69 puts(""); 70 } 71 template <typename T> 72 void _write(const T &t) 73 { 74 write(t); 75 } 76 template <typename T, typename... Args> 77 void _write(const T &t, Args... args) 78 { 79 write(t), pblank; 80 _write(args...); 81 } 82 template <typename T, typename... Args> 83 inline void write_line(const T &t, const Args &... data) 84 { 85 _write(t, data...); 86 } 87 ll a[maxn]; 88 vector<int> g[65]; 89 int main(int argc, char const *argv[]) 90 { 91 #ifndef ONLINE_JUDGE 92 freopen("in.txt", "r", stdin); 93 // freopen("out.txt", "w", stdout); 94 #endif 95 n = read<int>(); 96 for (int i = 1; i <= n; i++) 97 { 98 ll x = read<ll>(); 99 k = 0; 100 while (x % 2 == 0) 101 { 102 ++k; 103 x /= 2; 104 } 105 g[k].emplace_back(i); 106 } 107 int maxx = 0, f = -1; 108 for (int i = 0; i < 64; i++) 109 if (g[i].size() > maxx) 110 maxx = g[i].size(), f = i; 111 int res = 0; 112 for (int i = 0; i < 64; i++) 113 if (i != f) 114 res += g[i].size(); 115 writeln(res); 116 for (int i = 0; i < 64; i++) 117 if (i != f) 118 for (int j = 0; j < g[i].size(); j++) 119 write(g[i][j]), pblank; 120 return 0; 121 }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 2025成都.NET开发者Connect圆满结束
· 后端思维之高并发处理方案
· 千万级大表的优化技巧
· 在 VS Code 中,一键安装 MCP Server!
· 10年+ .NET Coder 心语 ── 继承的思维:从思维模式到架构设计的深度解析