-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem.php
214 lines (194 loc) · 6.06 KB
/
problem.php
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
session_start ();
if ($_SESSION["group"]!="user" and $_SESSION["group"]!="admin") {
header ("Location: index.php");
exit (0);
}
require_once ("lib/php/dblink.php");
require_once ("lib/php/func.php");
require_once ("lib/php/security.php");
?>
<?php
$id = check_numeric($_GET["id"]);
$sql = "select * from problems where problem_id='$id' and effective='Y'";
$r = mysql_query ($sql) or die ("Invalid query: $sql");
$problem = mysql_fetch_array ($r);
if (!$problem)
header ("Location: index.php");
if ($_POST["submit"] && $_POST["tag"])
{
if ($_SESSION["group"]=="user" or $_SESSION["group"]=="admin")
{
$data['user_id'] = $_SESSION['userid'];
$data['problem_id'] = $id;
$data['value'] = $_POST['tag'];
$data['time'] = get_full_date ();
$sql = insert_into_table ('tag', $data);
mysql_query ($sql) or die ("Invalid query: $sql");
}
}
$sql = "select * from tag where problem_id=$id";
$r = mysql_query ($sql) or die ("Invalid query: $sql");
$tag_n = 0;
while ($tmp = mysql_fetch_array ($r))
{
$problem["tags"][$tag_n] = $tmp;
$tag_n++;
}
$contest_id = $problem["contest_id"];
$sql = "select * from contests where contest_id='$contest_id' and effective='Y'";
$r = mysql_query ($sql) or die ("Invalid query: $sql");
$contest = mysql_fetch_array ($r);
$now = get_full_date ();
if ($contest and $now<$contest["start_time"]) {
header ("Location: problemset.php");
exit (0);
}
if ($contest and get_full_date()<$contest["end_time"])
$no_tag_display = 1;
if ($contest and $contest["virtual"]=="Y" and get_full_date()<$contest["end_time"])
{
if ($_SESSION["group"]!="user" and $_SESSION["group"]!="admin")
{
header ("Location: index.php");
exit (0);
}
if ($contest["personal"]=="Y" and get_start_by_user ($_SESSION["userid"], $contest_id)=="")
{
header ("Location: index.php");
exit (0);
}
if ($contest["personal"]=="N" and get_start_by_team (get_team_name ($_SESSION["userid"]), $contest_id)=="")
{
header ("Location: index.php");
exit (0);
}
}
?>
<html>
<head>
<?php include_once ("html_header.php"); ?>
</head>
<body>
<!-- mean -->
<?php require ("menu.php") ?>
<!-- page -->
<div class="container jumbotron" style="padding-top: 3%;">
<div style="padding-right: 10%; padding-left: 10%;">
<div class="text-center" >
<h2 style="font-size: 3.5em;"><?=$problem["title"]?></h2>
<p style="font-size: 1.2em;"><b>Problem id : <?=sprintf ("%04d", $id)?></b></p>
</div>
<p><b>Judge Type :</b></p>
<?php
echo "<p style=\"text-indent: 2em;\">";
if ($problem["execute_type"] == 1 || $problem["judge_type"] != 0) {
if ($problem["execute_type"] == 1)
echo "<font style=\"color: blue;\">[Interactive]</font> ";
if ($problem["judge_type"] != 0)
echo "<font style=\"color: red;\">[Special Judge]</font> ";
} else {
echo "[Regular Judge] ";
}
echo "</P>";
?>
<p><b>Task Description :</b></p>
<div class="problemview"><?=$problem["description"]?></div>
<p><b>Input Format :</b></p>
<div class="problemview"><?=$problem["input"]?></div>
<p><b>Output Format :</b></p>
<div class="problemview"><?=$problem["output"]?></div>
<?php
echo "<ul style=\"font-size: 1.2em;\">";
if ($problem["execute_type"] == 1) {
echo "<li>This is an interactive problem, ".
"please make sure you have added fflush(stdout) at every time you output.</li>";
}
if ($problem["judge_type"] >= 10 && $problem["judge_type"] <= 25) {
$precision = $problem["judge_type"] - 10;
echo "<li>Your submission will be judged by a special judging program.<br>".
"Any answer with a relative or absolute error at most 1e-$precision will be accepted.</li>";
} else if ($problem["judge_type"] != 0) {
echo "<li>Your submission will be judged by a special judging program.<br>".
"Please read the output format carefully.</li>";
}
echo "</ul>";
?>
<p><b>Limit :</b></p>
<p style="text-indent: 2em; font-size: 1.2em;">Time Limit: <?=$problem["time_limit"]?> sec</p>
<p style="text-indent: 2em; font-size: 1.2em;">Output Limit: <?=$problem["output_limit"]/2?> kB</p>
<p><b>Sample Input :</b></p>
<?php if ($problem["sample_input"]!="") { ?>
<pre>
<?php echo $problem["sample_input"]?>
</pre>
<?php } else { ?>
<pre>
None Input
</pre>
<?php } ?>
<?php
if ($problem["execute_type"] == 1) {
echo "<ul style=\"font-size: 1.2em;\"><li>This is an interactive problem, ".
"the sample input is just a sample.</li></ul>";
}
?>
<p><b>Sample Output :</b></p>
<?php if ($problem["sample_output"]!="") { ?>
<pre>
<?php echo $problem["sample_output"]?>
</pre>
<?php } else { ?>
<pre>
None output
</pre>
<?php } ?>
<?php if ($problem["hint"]!="") { ?>
<p><b>Hint :</b></p>
<pre>
<?php echo $problem["hint"]?>
</pre>
<?php } ?>
<!--
<?php
// if (!$no_tag_display) {
?>
<p><b>Tags :</b></p>
<span>
<?php
// if (sizeof($problem["tags"])>0)
// {
// foreach ($problem["tags"] as $tag)
// {
// echo "<a href='volume.php?tag_id=".$tag['id']."'>";
// echo $tag['value'];
// echo "</a>";
// echo " ";
// echo "(by ";
// echo "<a href='user_info.php?user_id=".$tag['user_id']."'>";
// echo get_username($tag['user_id']);
// echo "</a>";
// echo ")<br>";
// }
// }
?>
<form method=post action="problem.php?id=<?=$id?>">
<input type="text" name="tag">
<button type="submit" class="btn btn-default" name="submit" value="Add New Tag">Submit</button>
</form>
</span>
<?php
// }
?>
-->
</div>
<div class="text-center">
<button onclick="location.href='submit.php?id=<?=sprintf ("%04d", $id)?>'" type="button" class="btn btn-default" >Submit</button>
<button onclick="location.href='status.php?problem_id=<?=$id?>'" type="button" class="btn btn-default" >Status</button>
<button onclick="location.href='status.php?problem_id=<?=$id?>&result=Accepted'" type="button" class="btn btn-default" >Status(AC)</button>
</div>
</div>
<!-- footer -->
<?php require ("footer.php") ?>
</body>
</html>