Package cn.edu.zju.acm.onlinejudge.util

Examples of cn.edu.zju.acm.onlinejudge.util.RankListEntry


                            .prepareStatement("SELECT user_profile_id, problem_id, judge_reply_id, submission_date FROM submission " +
                                "WHERE problem_id IN " + inProblemIds + userIdsCon + " ORDER BY submission_date");
                ResultSet rs = ps.executeQuery();
                while (rs.next()) {
                    long userId = rs.getLong(1);
                    RankListEntry entry = (RankListEntry) entries.get(new Long(userId));
                    if (entry == null) {
                        entry = new RankListEntry(problems.size());
                        entries.put(new Long(userId), entry);
                        UserProfile profile = new UserProfile();
                        profile.setId(userId);
                        entry.setUserProfile(profile);
                    }
                    long problemId = rs.getLong(2);
                    long judgeReplyId = rs.getLong(3);
                    int time = (int) ((rs.getTimestamp(4).getTime() - contestStartDate) / 1000 / 60);

                    entry.update(((Integer) problemIndexes.get(new Long(problemId))).intValue(), time,
                                 judgeReplyId == JudgeReply.ACCEPTED.getId());
                }
            } finally {
                Database.dispose(ps);
            }
View Full Code Here


                        conn.prepareStatement("SELECT ac_number, submission_number FROM user_stat "
                            + "WHERE contest_id=? AND user_id=?");
                ps.setLong(1, contestId);
                ps.setLong(2, userId);
                ResultSet rs = ps.executeQuery();
                RankListEntry re = null;
                if (rs.next()) {
                    re = new RankListEntry(1);
                    re.setSolved(rs.getLong(1));
                    re.setSubmitted(rs.getLong(2));
                }
                return re;
            } finally {
                Database.dispose(ps);
            }
View Full Code Here

        }
        row.createCell(columnIndex).setCellValue("Penalty");

        int rowIndex = 6;
        for (RankListEntry rankListEntry : entries) {
            RankListEntry entry = rankListEntry;
            row = sheet.createRow(rowIndex);
            row.createCell((short) 0).setCellValue(rowIndex - 5);
            row.createCell((short) 1).setCellValue(entry.getUserProfile().getHandle());
            String nick = entry.getUserProfile().getHandle();
            if (entry.getUserProfile().getNickName() != null) {
                nick = entry.getUserProfile().getNickName();
            }
            cell = row.createCell((short) 2);
            cell.setEncoding(HSSFCell.ENCODING_UTF_16);
            cell.setCellValue(nick);

            row.createCell((short) 3).setCellValue(entry.getSolved());

            for (short i = 0; i < problems.size(); ++i) {
                String score =
                        entry.getAcceptTime(i) > 0 ? entry.getAcceptTime(i) + "(" + entry.getSubmitNumber(i) + ")"
                                                  : "" + entry.getSubmitNumber(i);
                row.createCell((short) (4 + i)).setCellValue(score);
            }
            row.createCell((short) (4 + problems.size())).setCellValue(entry.getPenalty());
            rowIndex++;
        }

        // output to stream
        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

        writer.write(lineHolder);

        int index = 0;
        for (RankListEntry rankListEntry : entries) {
            index++;
            RankListEntry entry = rankListEntry;
            writer.write(index + "\t");
            writer.write(entry.getUserProfile().getHandle() + "\t");
            writer.write((entry.getUserProfile().getNickName() == null ? entry.getUserProfile().getHandle()
                                                                      : entry.getUserProfile().getNickName()) +
                "\t");
            writer.write(entry.getSolved() + "\t");
            for (int i = 0; i < problems.size(); ++i) {
                String score =
                        entry.getAcceptTime(i) > 0 ? entry.getAcceptTime(i) + "(" + entry.getSubmitNumber(i) + ")"
                                                  : "" + entry.getSubmitNumber(i);
                writer.write(score + "\t");
            }
            writer.write(entry.getPenalty() + lineHolder);
        }
        writer.close();

        return out.toByteArray();
    }
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.util.RankListEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.