拼手速
#includeB.Who is missing?using namespace std; inline void solve(){ string s; cin >> s; int a, b; cin >> a >> b; for(int i = 0; i < s.size(); i++){ if(i == a - 1) cout << s[b - 1]; else if(i == b - 1) cout << s[a - 1]; else cout << s[i]; } } signed main(){ solve(); return 0; }
拼手速
#includeC.Route Mapusing namespace std; const int N = 1e6 + 10; int a[N]; inline void solve(){ int n = 0; cin >> n; for(int i = 1; i <= 4 * n - 1; i++){ int num = 0; cin >> num; a[num]++; } for(int i = 1; i <= n; i++) if(a[i] < 4){ cout << i << endl; return; } } signed main(){ solve(); return 0; }
拼手速
#includeD.Danceusing namespace std; const int N = 1e5 + 10; string s[N]; map t; inline void solve(){ int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) cin >> s[i]; for(int i = 1; i <= m; i++){ string ss; cin >> ss; t[ss] = 1; } for(int i = 1; i <= n; i++){ if(t.count(s[i])) cout << "Yes" << endl; else cout << "No" << endl; } } signed main(){ solve(); return 0; }
暴力枚举即可, 1 ≤ N ≤ 8 1leq N leq 8 1≤N≤8。
#include#define int long long using namespace std; const int N = 100; int a[N][N], vis[1000], n, cnt, ans, tmp = 0; void dfs(int now){ if(now == (n << 1 | 1)){ if (cnt == (n << 1) && tmp > ans) ans = tmp; return; } if(vis[now]){ dfs(now + 1); return; } for(int i = now + 1; i <= 2 * n; i++){ if(vis[i] == 1) continue; vis[i] = vis[now] = 1, tmp ^= a[now][i], cnt += 2; dfs(now + 1); vis[i] = vis[now] = 0, tmp ^= a[now][i], cnt -= 2; } } inline void solve(){ cin >> n; for(int i = 1; i <= 2 * n - 1; i++) for(int j = i + 1; j <= 2 * n; j++) cin >> a[i][j]; dfs(1); cout << ans << endl; } signed main(){ solve(); return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)