定制高端网站的公司,信用 网站 建设方案,公益网站建设,南昌抖音推广公司A
太简单#xff0c;写完删了B 我写的繁了#xff0c;但是意思是这么个意思#xff0c;就遍历打擂台一样#xff0c;找到最后的胜者#xff0c;然后在遍历一遍找是不是最厉害的
#include bits/stdc.h
using namespace std;
#define int long long
int op[200095…A
太简单写完删了B 我写的繁了但是意思是这么个意思就遍历打擂台一样找到最后的胜者然后在遍历一遍找是不是最厉害的
#include bits/stdc.h
using namespace std;
#define int long long
int op[200095][16];
signed main()
{int t;cin t;while (t--){int n;cin n;int k -1;int maxn[6];memset(maxn, 0x3f3f3f3f, sizeof(maxn));int ch[6];for (int j 1; j n; j){int cou 0;for (int i 0; i 5; i){cin ch[i];op[j][i] ch[i];if (ch[i] maxn[i])cou;}if (cou 3){for (int i 0; i 5; i){maxn[i] ch[i];}k j;}}bool flag true;for (int i 1; i n; i){int cou 0;if (i ! k)for (int j 0; j 5; j){if (maxn[j] op[i][j])cou;}elsecou 5;if (cou 3){flag false;break;}}if (flag)cout k endl;elsecout -1 endl;}
}D 别人代码直接拿来用了 应该是最精简的了
#includebits/stdc.h
using namespace std;
mapint,int mp;
int a[101000];
int n,flag 0;
void dfs(int now,int all)
{if(now n){if(mp[all]!0){flag 1;}mp[all] ;return ;}now ;dfs(now,all a[now]);dfs(now,all);
}
int main()
{int T;scanf(%d,T);while(T--){scanf(%d,n);for(int i 1;in;i){scanf(%d,a[i]);}mp.clear();flag 0;dfs(0,0);if(flag){printf(YES\n);}else{printf(NO\n);}}
}
tourist代码 思路一个数可以取或者取反例或者不取
#include bits/stdc.h
using namespace std;
int main() {ios::sync_with_stdio(false);cin.tie(0);int tt;cin tt;while (tt--) {int n;cin n;vectorint a(n);for (int i 0; i n; i) {cin a[i];}int p3 1;for (int i 0; i n; i) {p3 * 3;}bool found false;for (int t 1; t p3; t) {int tmp t;int sum 0;for (int i 0; i n; i) {int d tmp % 3;if (d 1) sum a[i];if (d 2) sum - a[i];tmp / 3;}if (sum 0) {found true;break;}}cout (found ? YES : NO) \n;}return 0;
}