Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
73877 陆彦哲 金矿 C++ 运行超时 60 795 MS 272 KB 5318 2023-04-11 13:15:34

Tests(3/5):


#include<bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC target("avx") #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") using namespace std; long long a[10010],dp[10010]; bool book[1010][1010]; long long ans; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar(); return x*f; } void write(int x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); return; } int add(int num1, int num2){ if(num2 == 0) return num1; int sum = num1 ^ num2; int carry = (num1 & num2) << 1; return add(sum, carry); } int substract(int num1, int num2){ //num1:减数 //num2:被减数 int subtractor = add(~num2, 1); int result = add(num1, subtractor); return result ; } int multiply(int a, int b) { //将乘数和被乘数都取绝对值  int multiplicand = a < 0 ? add(~a, 1) : a; int multiplier = b < 0 ? add(~b , 1) : b; //计算绝对值的乘积   int product = 0; while(multiplier > 0) { if((multiplier & 0x1) > 0) {// 每次考察乘数的最后一位    product = add(product, multiplicand); } multiplicand = multiplicand << 1;// 每运算一次,被乘数要左移一位     multiplier = multiplier >> 1;// 每运算一次,乘数要右移一位(可对照上图理解)   } //计算乘积的符号   if((a ^ b) < 0) { product = add(~product, 1); } return product; } int divide_v2(int a,int b) { // 先取被除数和除数的绝对值 int dividend = a > 0 ? a : add(~a, 1); int divisor = b > 0 ? a : add(~b, 1); int quotient = 0;// 商 int remainder = 0;// 余数 for(int i = 31; i >= 0; i--) { //比较dividend是否大于divisor的(1<<i)次方,不要将dividend与(divisor<<i)比较,而是用(dividend>>i)与divisor比较, //效果一样,但是可以避免因(divisor<<i)操作可能导致的溢出,如果溢出则会可能dividend本身小于divisor,但是溢出导致dividend大于divisor if((dividend >> i) >= divisor) { quotient = add(quotient, 1 << i); dividend = substract(dividend, divisor << i); } } // 确定商的符号 if((a ^ b) < 0){ // 如果除数和被除数异号,则商为负数 quotient = add(~quotient, 1); } // 确定余数符号 remainder = b > 0 ? dividend : add(~dividend, 1); return quotient;// 返回商 } int n; int main(){ n=read(); for(int i=1;i<=n;i=add(i,1))a[i]=read(); for(int i=1;i<=n;i=add(i,1)){ char ch; int x; cin>>x; while(true){ ch=getchar(); if(ch==' '){ cin>>x; if(i!=x)book[i][x]=1; } if(ch=='\n')break; } } for(int i=1;i<=n;i=add(i,1))dp[i]=a[i]; for(int i=1;i<=n;i=add(i,1)){ for(int j=i+1;j<=n;j=add(j,1)){ if(book[i][j]==1)dp[j]=max(dp[j],dp[i]+a[j]); ans=max(ans,dp[j]); } } write(ans); return 0; }


测评信息: