-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRMQWithShifts_UVA12299Data.cpp
80 lines (71 loc) · 2.37 KB
/
RMQWithShifts_UVA12299Data.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <bits/stdc++.h> //includes everything, supported in CF, usaco, not POJ
#include "MyRandom.h"
using namespace std;
int main()
{
const int FileCount = 1; //note:文件数量
ofstream fout; //note:文件流
random rdNum; //note:随机数
for (int fileId = 1; fileId <= FileCount; ++fileId)
{
fout.open("RMQWithShifts_UVA12299.in");
//***************************
//在此处写入测试数据
//***************************
int N = 100;
//int q = rdNum.GetRand(2, 300);
int q = 50;
fout << N << " " <<q << "\n";
for (int i = 0; i <= N - 1; ++i)
{
fout << rdNum.GetRand(1, 1e2) << " ";
}
fout << "\n" ;
int q2=q-1;
while(q2--)
{
// if(rdNum.GetRand(1, 10) %2==0)
// {
int shift1=rdNum.GetRand(1, N);
int shift2=rdNum.GetRand(1, N);
while(shift1>=shift2)
{
shift1=rdNum.GetRand(1, N);
shift2=rdNum.GetRand(1, N);
}
fout << "shift(" << shift1 << "," << shift2;
while(shift2<N)
{
shift2+=rdNum.GetRand(1, N);
if(shift2>=N)
{
break;
}
fout << ","<< shift2;
}
fout << ")\n";
//}
//else
//{
// int query_i=rdNum.GetRand(1, N);
// int query_j=rdNum.GetRand(1, N);
// while(query_i>=query_j)
// {
// query_i=rdNum.GetRand(1, N);
// query_j=rdNum.GetRand(1, N);
// }
// fout << "query(" << query_i << "," << query_j << ")\n";
//}
}
int query_i=rdNum.GetRand(1, N);
int query_j=rdNum.GetRand(1, N);
while(query_i>=query_j)
{
query_i=rdNum.GetRand(1, N);
query_j=rdNum.GetRand(1, N);
}
fout << "query(" << query_i << "," << query_j << ")\n";
fout.close();
}
return 0;
}