Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## c++ 47ms g++WA可以帮我找下原因吗

Posted by 980306 at 2018-03-16 12:27:41 on Problem 2549
```#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<iomanip>
#include<stdlib.h>
#include<stdio.h>
#include<string>
#include<string.h>
#include<set>
#include<stack>
#include<map>
using namespace std;
#pragma warning(disable:4996)

#define rep(i, n) for(int i=0; i<n ;i++)
#define Rep(i, n) for(int i=1; i<=n; i++)
#define SYS system("pause");
typedef long long ll;
const int INF = 0x7fffffff;
const int MAX_N = 1e3 + 5;
const int MAX_V = 0;
const int MAX_M = 0;
const int MAX_Q = 0;

const int mod = 1e6 + 5;
int N;
int a[MAX_N];
int cnt = 0;

struct Node {
int x, y, nxt;
}nd[MAX_N*MAX_N];

void add_node(int x, int y) {
nd[cnt].x = x; nd[cnt].y = y;
int key = abs(x + y) % mod;
}

bool search_node(int x, int y) {
int key = abs(x - y) % mod;
for (int i = head[key]; i != -1; i = nd[i].nxt) {
if (nd[i].x != x && nd[i].y != y && nd[i].x != y && nd[i].y != x) {
if(x-y==nd[i].x+nd[i].y)
return true;
}
}
return false;
}

int main() {
ios::sync_with_stdio(0);
while (cin >> N && N) {
cnt = 0;
rep(i, N) {
cin >> a[i];
}
sort(a, a + N);
Rep(i, N - 1) {
rep(j, i) {
}
}
for (int i = N - 1; i >= 0; i--) {
for (int j = 0; j < N; j++) {
if (i != j && search_node(a[i], a[j])) {
cout << a[i] << endl;
goto ans;
}
}
}
puts("no solution");
ans:;
}
}```

Followed by: