Submission #2322898
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include <queue>
using namespace std;
typedef pair<int, int> pii;
unsigned long w;
int iter;
int dy[] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1, 1 };
int total;
int score;
int V, E;
int Vemb, Eemb;
int sqVemb;
int G[502][502];
int KG[62][62];
int phi[501][2];
//pii phi[501];
inline unsigned long xor128() {
static unsigned long x = 123456789, y = 362436069, z = 521288629 /*, w = 88675123*/;
unsigned long t = (x ^ (x << 11));
x = y; y = z; z = w;
return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
inline void swap(int u, int v) {
int* upos = phi[u];
int* vpos = phi[v];
for (int d = 0; d < 8; d++) {
int x = upos[1] + dx[d];
int y = upos[0] + dy[d];
score -= G[u][KG[y][x]];
}
KG[upos[0]][upos[1]] = 0;
for (int d = 0; d < 8; d++) {
int x = vpos[1] + dx[d];
int y = vpos[0] + dy[d];
score -= G[v][KG[y][x]];
}
KG[vpos[0]][vpos[1]] = 0;
KG[upos[0]][upos[1]] = v;
for (int d = 0; d < 8; d++) {
int x = upos[1] + dx[d];
int y = upos[0] + dy[d];
score += G[v][KG[y][x]];
}
KG[vpos[0]][vpos[1]] = u;
for (int d = 0; d < 8; d++) {
int x = vpos[1] + dx[d];
int y = vpos[0] + dy[d];
score += G[u][KG[y][x]];
}
std::swap(upos[0], vpos[0]);
std::swap(upos[1], vpos[1]);
}
inline void nswapWithoutConstraints(int n) {
for (int i = 0; i < n; i++) {
int u = xor128() % V + 1;
int v = xor128() % V + 1;
while (u == v) v = xor128() % V + 1;
swap(u, v);
}
}
inline double getTemp(double startTemp, double endTemp, double deg = 1.0, double t = (double)clock() / CLOCKS_PER_SEC, double T = 10.0) {
return endTemp + (startTemp - endTemp) * pow((T - t) / T, deg);
}
inline void nswapWithProbability(int n, double T = 10.0) {
double temp = getTemp(5, 0.1);
int R = 100000000;
for (int i = 0; i < n; i++) {
int prev_score = score;
int u = xor128() % V + 1;
int v = xor128() % V + 1;
while (u == v) v = xor128() % V + 1;
swap(u, v);
if (score < prev_score) {
double prob = exp((score - prev_score) / temp);
if (prob < (double)(xor128() % R) / R) {
swap(u, v);
}
}
}
iter++;
}
int main()
{
srand((unsigned)time(NULL));
w = rand();
memset(G, 0, sizeof(G));
memset(KG, 0, sizeof(KG));
scanf("%d%d", &V, &E);
int u, v;
for (int i = 0; i < E; i++) {
scanf("%d%d", &u, &v);
G[u][v] = G[v][u] = 1;
}
scanf("%d%d", &Vemb, &Eemb);
int a, b;
for (int i = 0; i < Eemb; i++) {
scanf("%d%d", &a, &b);
}
for (sqVemb = 1; ; sqVemb++) if (sqVemb * sqVemb == Vemb) break;
typedef pair<double, pii> pdii;
priority_queue<pdii> pq;
double cx, cy;
cx = cy = sqVemb / 2;
for (int y = 1; y <= sqVemb; y++) {
for (int x = 1; x <= sqVemb; x++) {
double d = (cx - x) * (cx - x) + (cy - y) * (cy - y);
pq.push(pdii(-d, pii(y, x)));
}
}
for (int i = 1; i <= V; i++) {
pii p = pq.top().second; pq.pop();
int x = p.second;
int y = p.first;
cout << 1 << " " << (y - 1) * sqVemb + x << endl;
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Problem 2 |
User |
latte0119 |
Language |
C++14 (GCC 5.4.1) |
Score |
725000 |
Code Size |
3313 Byte |
Status |
AC |
Exec Time |
6 ms |
Memory |
1408 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:118:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &V, &E);
^
./Main.cpp:121:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &u, &v);
^
./Main.cpp:124:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &Vemb, &Eemb);
^
./Main.cpp:127:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a, &b);
^
Judge Result
Set Name |
sample_00 |
sample_01 |
random_00 |
random_01 |
random_02 |
random_03 |
random_04 |
random_05 |
random_06 |
random_07 |
random_08 |
random_09 |
random_10 |
random_11 |
random_12 |
random_13 |
random_14 |
random_15 |
random_16 |
random_17 |
random_18 |
random_19 |
random_20 |
random_21 |
random_22 |
random_23 |
random_24 |
random_25 |
random_26 |
random_27 |
Score / Max Score |
6000 / 1000000 |
6700 / 1000000 |
16000 / 1000000 |
15200 / 1000000 |
5900 / 1000000 |
16100 / 1000000 |
14000 / 1000000 |
6400 / 1000000 |
31000 / 1000000 |
22900 / 1000000 |
12800 / 1000000 |
35400 / 1000000 |
53100 / 1000000 |
10200 / 1000000 |
38700 / 1000000 |
52700 / 1000000 |
54100 / 1000000 |
34600 / 1000000 |
23400 / 1000000 |
23000 / 1000000 |
15800 / 1000000 |
23400 / 1000000 |
43400 / 1000000 |
9800 / 1000000 |
34200 / 1000000 |
14100 / 1000000 |
6800 / 1000000 |
6900 / 1000000 |
49000 / 1000000 |
43400 / 1000000 |
Status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
sample_00 |
00_sample_00 |
sample_01 |
00_sample_01 |
random_00 |
10_random_00 |
random_01 |
10_random_01 |
random_02 |
10_random_02 |
random_03 |
10_random_03 |
random_04 |
10_random_04 |
random_05 |
10_random_05 |
random_06 |
10_random_06 |
random_07 |
10_random_07 |
random_08 |
10_random_08 |
random_09 |
10_random_09 |
random_10 |
10_random_10 |
random_11 |
10_random_11 |
random_12 |
10_random_12 |
random_13 |
10_random_13 |
random_14 |
10_random_14 |
random_15 |
10_random_15 |
random_16 |
10_random_16 |
random_17 |
10_random_17 |
random_18 |
10_random_18 |
random_19 |
10_random_19 |
random_20 |
10_random_20 |
random_21 |
10_random_21 |
random_22 |
10_random_22 |
random_23 |
10_random_23 |
random_24 |
10_random_24 |
random_25 |
10_random_25 |
random_26 |
10_random_26 |
random_27 |
10_random_27 |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00 |
AC |
2 ms |
1280 KB |
00_sample_01 |
AC |
2 ms |
1280 KB |
10_random_00 |
AC |
2 ms |
1280 KB |
10_random_01 |
AC |
2 ms |
1280 KB |
10_random_02 |
AC |
3 ms |
1280 KB |
10_random_03 |
AC |
4 ms |
1280 KB |
10_random_04 |
AC |
2 ms |
1280 KB |
10_random_05 |
AC |
2 ms |
1280 KB |
10_random_06 |
AC |
5 ms |
1280 KB |
10_random_07 |
AC |
4 ms |
1280 KB |
10_random_08 |
AC |
3 ms |
1280 KB |
10_random_09 |
AC |
5 ms |
1408 KB |
10_random_10 |
AC |
6 ms |
1280 KB |
10_random_11 |
AC |
4 ms |
1408 KB |
10_random_12 |
AC |
3 ms |
1280 KB |
10_random_13 |
AC |
5 ms |
1280 KB |
10_random_14 |
AC |
5 ms |
1280 KB |
10_random_15 |
AC |
6 ms |
1408 KB |
10_random_16 |
AC |
4 ms |
1408 KB |
10_random_17 |
AC |
5 ms |
1280 KB |
10_random_18 |
AC |
3 ms |
1408 KB |
10_random_19 |
AC |
4 ms |
1280 KB |
10_random_20 |
AC |
4 ms |
1280 KB |
10_random_21 |
AC |
4 ms |
1280 KB |
10_random_22 |
AC |
6 ms |
1408 KB |
10_random_23 |
AC |
4 ms |
1408 KB |
10_random_24 |
AC |
4 ms |
1408 KB |
10_random_25 |
AC |
3 ms |
1408 KB |
10_random_26 |
AC |
5 ms |
1408 KB |
10_random_27 |
AC |
4 ms |
1280 KB |