赞
踩
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 1e2 + 10; int a[N]; void test(){ int n;cin >> n; for(int i = 1;i <= n;i++){ cin >> a[i]; } sort(a + 1,a + 1 + n); if(a[1] < 0) cout << a[1] << endl; else cout << a[n] << endl; } #undef int int main() { int t = 1;cin >> t; while(t--){ test(); } }
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 10; int p[N]; void test(){ int n;cin >> n; int aim_1,aim_2,aim_n; for(int i = 1;i <= n;i++){ cin >> p[i]; if(p[i] == 1) aim_1 = i; else if(p[i] == 2) aim_2 = i; else if(p[i] == n) aim_n = i; } if((aim_1 - aim_n)*(aim_n - aim_2) > 0) cout << 1 << ' ' << 1 << endl; else if((aim_1 - aim_2) * (aim_2 - aim_n) > 0) cout << aim_2 << ' ' << aim_n << endl; else cout << aim_1 << ' ' << aim_n << endl; } #undef int int main() { int t = 1;cin >> t; while(t--){ test(); } }
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 1e3 + 10; bool not_prime(int x){ for(int i = 2;i*i <= x;i++) if(x % i == 0) return 0; return 1; } int ans[N][N]; void test(){ int n,m;cin >> n >> m; int begin = 1; for(int i = 1;i <= n / 2;i++){ for(int j = 1;j <= m;j++) ans[i][j] = j + begin * m; begin += 2; } begin = 0; for(int i = 1;i <= n - n / 2;i++){ for(int j = 1;j <= m;j++) ans[n/2 + i][j] = j + begin * m; begin += 2; } for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++) cout << ans[i][j] << ' '; cout << endl; } } #undef int int main() { int t = 1;cin >> t; while(t--){ test(); } }
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 10; bool a[N]; set<int> se; void test(){ int n,q;cin >> n >> q; string s;cin >> s; for(int i = 0;i < n;i++){ if(s[i] == ')') a[i + 1] = 1; if(i != 0 && a[i] == a[i + 1]) se.insert(i); } if(n%2 == 1){ while(q--){ int x;cin >> x; cout << "NO" << endl; } }else{ while(q--){ int x;cin >> x; if(x != 1 && a[x] == a[x - 1]) se.erase(se.find(x - 1)); if(x != n && a[x] == a[x + 1]) se.erase(se.find(x)); a[x] = 1 - a[x]; if(x != 1 && a[x] == a[x - 1]) se.insert(x - 1); if(x != n && a[x] == a[x + 1]) se.insert(x); if(!se.empty() && a[1] == 0 && a[n] == 1 && (a[*se.begin()] != 0 || a[*(--se.end())] != 1)) cout << "NO" << endl; else if(a[1] == 1 || a[n] == 0) cout << "NO" << endl; else cout << "YES" << endl; } } } #undef int int main() { int t = 1;//cin >> t; while(t--){ test(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。