// Problem: A. Secret Sport
// Contest: Codeforces - Codeforces Round 908 (Div. 2)
// URL: https://codeforces.com/contest/1894/problem/A
// Memory Limit: 512 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<sstream>//切割strtream头文件
#include<climits>//INT_MAX文件
#include <utility>
#include<memory>//for unique_ptr shared_ptr
using i64 = int64_t;
using namespace std;
#define int i64
#define endl '\n'
#define AC return 0;
#define WA(x) cout << x << endl;
#define lowbit(x) x & -x
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int n, m, k, d, T = 1, A, B;
template<typename T>void read(T &x) {
T f = 1;x = 0;char s = getchar();
while(s < '0' || s > '9') {if(s == '-')f = -1;s = getchar();}
while(s >= '0' && s <= '9') {x = x * 10 + s - '0';s = getchar();}
x *= f;
}
template<typename T>void print(T x) {
if(x < 0) putchar('-'),x = -x;
if(x > 9) print(x / 10);
putchar(x % 10 + '0');
putchar('\n');
}
constexpr int Init(int x)
{
return x * 2;
}
void solve()
{
cin >> n;
char ans;
for (int i = 0; i < n; i++)cin >> ans;
std::cout << ans << endl;
}
signed main() {
cin.tie(0) -> sync_with_stdio(false);
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
是3个条件有且仅有2个条件被满足
// Problem: B. Two Out of Three
// Contest: Codeforces - Codeforces Round 908 (Div. 2)
// URL: https://codeforces.com/contest/1894/problem/B
// Memory Limit: 512 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<sstream>//切割strtream头文件
#include<climits>//INT_MAX文件
#include <utility>
#include<memory>//for unique_ptr shared_ptr
using i64 = int64_t;
using namespace std;
#define int i64
#define endl '\n'
#define AC return 0;
#define WA(x) cout << x << endl;
#define lowbit(x) x & -x
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int n, m, k, d, T = 1, A, B;
template<typename T>void read(T &x) {
T f = 1;x = 0;char s = getchar();
while(s < '0' || s > '9') {if(s == '-')f = -1;s = getchar();}
while(s >= '0' && s <= '9') {x = x * 10 + s - '0';s = getchar();}
x *= f;
}
template<typename T>void print(T x) {
if(x < 0) putchar('-'),x = -x;
if(x > 9) print(x / 10);
putchar(x % 10 + '0');
putchar('\n');
}
constexpr int Init(int x)
{
return x * 2;
}
void solve()
{
cin >> n;
vector<int>a(n + 1,1);
map<int,int> M;
int k = 1,d = -1;
for(int i = 1;i <= n;i++)
{
cin >> m;
M[m]++;
if(M[m] >= 2)
{
if(k == 1){k++;d = m;}
if(m == d)a[i] = 2;
else {a[i] = 3;
k++;}
}
}
if(k <= 2)cout << -1;
else
for(int i = 1;i <= n;i++)cout << a[i] << " ";
cout << endl;
}
signed main() {
cin.tie(0) -> sync_with_stdio(false);
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
反向模拟即可,若满足题意要求,pos = x && a[x] == x 的左移规则,a[x ]不可能 > n
// Problem: C. Anonymous Informant
// Contest: Codeforces - Codeforces Round 908 (Div. 2)
// URL: https://codeforces.com/contest/1894/problem/C
// Memory Limit: 512 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<sstream>//切割strtream头文件
#include<climits>//INT_MAX文件
#include <utility>
#include<memory>//for unique_ptr shared_ptr
using i64 = int64_t;
using namespace std;
#define int i64
#define endl '\n'
#define AC return 0;
#define WA(x) cout << x << endl;
#define lowbit(x) x & -x
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int n, m, k, d, T = 1, A, B;
template<typename T>void read(T &x) {
T f = 1;x = 0;char s = getchar();
while(s < '0' || s > '9') {if(s == '-')f = -1;s = getchar();}
while(s >= '0' && s <= '9') {x = x * 10 + s - '0';s = getchar();}
x *= f;
}
template<typename T>void print(T x) {
if(x < 0) putchar('-'),x = -x;
if(x > 9) print(x / 10);
putchar(x % 10 + '0');
putchar('\n');
}
constexpr int Init(int x)
{
return x * 2;
}
int a[maxn];
void solve()
{
auto x = make_unique<int>();
cin >> n >> k;
for(int i = 1;i <= n;i++)cin >> a[i];
k = min(n,k);
int pos = n;
while(k--)
{
if(a[pos] > n)
{
cout << "No" << endl;
return;
}
pos -= a[pos];
if(pos <= 0)pos += n;
}
cout << "Yes" << endl;
}
signed main() {
cin.tie(0) -> sync_with_stdio(false);
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
更多【编程技术-Codeforces Round 908】相关视频教程:www.yxfzedu.com