QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#412775 | #5985. Merlin QA | do_while_true | 38 ✓ | 979ms | 3640kb | C++20 | 2.3kb | 2024-05-16 19:18:46 | 2024-05-16 19:18:46 |
Judging History
answer
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<array>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
r=0;bool w=0;char ch=getchar();
while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
int s=1;
while(y){
if(y&1)s=1ll*s*x%mod;
x=1ll*x*x%mod;
y>>=1;
}
return s;
}
int n,m;
int a[110][110],p[110];
void solve(){
read(n,m);
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)read(a[i][j]);
for(int i=1;i<=n;i++)p[i]=i;
ll ans=0;
do{
ll sum=0;
for(int i=1;i<=n;i++){
ll mx=0,s=0;
for(int j=1;j<=m;j++){
s+=a[i][p[j]];
cmax(mx,s);
}
sum+=mx;
}
cmax(ans,sum);
}while(next_permutation(p+1,p+m+1));
cout<<ans<<'\n';
}
signed main(){
#ifdef do_while_true
// assert(freopen("data.in","r",stdin));
// assert(freopen("data.out","w",stdout));
#endif
int T;read(T);
for(int o=1;o<=T;o++){
cout<<"Case #"<<o<<": ";
solve();
}
#ifdef do_while_true
// cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
#endif
return 0;
}
详细
Subtask #1:
score: 8
Accepted
Test #1:
score: 8
Accepted
time: 0ms
memory: 3640kb
input:
100 80 2 -13 81 -8 -37 7 3 -10 -29 98 -67 -5 -78 38 -87 2 -16 -28 30 31 68 29 86 38 -70 76 -85 -3 55 90 -68 78 -44 60 -67 -27 100 44 -5 69 21 64 64 -91 0 -25 68 31 34 23 -84 13 96 -63 49 -90 46 60 7 79 98 -30 61 88 16 -27 -9 89 14 14 -28 28 85 47 -91 79 86 -60 15 -72 -23 96 -25 59 -18 -5 55 -12 60 -...
output:
Case #1: 3816 Case #2: 727 Case #3: 1700 Case #4: 3652 Case #5: 187 Case #6: 479 Case #7: 94 Case #8: 5129 Case #9: 0 Case #10: 4226 Case #11: 3185 Case #12: 3185 Case #13: 2172 Case #14: 1015 Case #15: 4122 Case #16: 597 Case #17: 3812 Case #18: 2105 Case #19: 1277 Case #20: 4395 Case #21: 1813 Cas...
result:
ok 100 lines
Subtask #2:
score: 30
Accepted
Test #2:
score: 30
Accepted
time: 979ms
memory: 3500kb
input:
100 100 8 56 77 -31 -50 -71 -89 19 -65 -33 8 60 74 72 -66 94 -86 8 -11 -89 72 37 51 -46 -72 -76 -41 -11 -36 7 69 85 19 -8 22 21 -54 7 -73 -4 13 51 68 -38 99 -90 -73 -41 47 -83 -52 0 -57 -22 94 -86 -36 -32 -51 68 77 -14 27 38 61 10 84 68 35 8 -38 34 98 44 -71 90 87 73 -28 -34 -90 30 4 15 -67 48 -25 5...
output:
Case #1: 11445 Case #2: 7168 Case #3: 2693 Case #4: 10726 Case #5: 661 Case #6: 1912 Case #7: 8978 Case #8: 5310 Case #9: 248 Case #10: 9735 Case #11: 3364 Case #12: 310 Case #13: 258 Case #14: 269 Case #15: 10807 Case #16: 363 Case #17: 39778 Case #18: 9595 Case #19: 2000 Case #20: 10985 Case #21: ...
result:
ok 100 lines
Extra Test:
score: 0
Extra Test Passed