EasyをHackされて0完。
Div1 Easy MarriageAndCirclingChallenge
ツイートの通りです。
C++を使うときはOverflowを気にするのは当然だと思っているし、コンテスト中も気にしていたのに、こんなミスをするのは酷い。
一応、システムテストを通ったコードを貼り付けます。
#include <bits/stdc++.h>
using namespace std;
class MarriageAndCirclingChallenge
{
public:
long long solve(int N, int threshold, int state)
{
vector<vector<int>> E(N);
long long sc=state;
int ch=0;
for (int i = 0; i < N; i += 1){
for (int j = i+1; j < N; j += 1){
sc=(sc * 1103515245 + 12345) % (1<<31);
ch=sc%100;
//printf("%d ",ch);
if (ch < threshold){
E[i].push_back(j);
}
else{
E[j].push_back(i);
}
}
}
long long ANS=0;
vector<vector<int>> X(N, vector<int>(N));
for (int i = 0; i < N; i += 1){
for (int j = 0; j < N; j += 1){
X[i][j]=0;
}
}
for (int i = 0; i < N; i += 1){
for (auto j:E[i]){
for (auto k:E[j]){
X[i][k]+=1;
}
}
}
for (int i = 0; i < N; i += 1){
for (int j = 0; j < N; j += 1){
ANS+=X[i][j]*X[j][i];
}
}
return ANS/4;
}
};
0 件のコメント:
コメントを投稿