結果
| 問題 |
No.348 カゴメカゴメ
|
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2016-03-23 23:29:25 |
| 言語 | Text (cat 8.3) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,555 bytes |
| コンパイル時間 | 81 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 21:40:49 |
| 合計ジャッジ時間 | 1,531 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 53 |
ソースコード
// 新テストケースverify用
// Rime使えばよかったことにさっき気がついた
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
using namespace std;
void main_(); signed main() {
ios::sync_with_stdio(false);
main_(); return 0;
}
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
typedef long long ll;
int const inf = 1<<29;
int command(string s) {
return system(s.c_str());
}
string get_suffix(string s) {
string ret;
for(int i=(int)s.size()-1; i>=0; i--) {
if(s[i] == '.') { break; }
ret.push_back(s[i]);
}
reverse(all(ret));
return ret;
}
int compile(string fname) {
auto suffix = get_suffix(fname);
if(suffix == "cpp" || suffix == "cxx") {
return command("clang++ " + fname + " -std=c++1z -o __" + fname + "_exe");
}
else if(suffix == "java") {
return command("javac " + fname);
}
else {
cout << "undefined suffix: " << suffix << endl;
return -1;
}
return 0;
}
int run_program(string fname, string redirect, int index) {
auto suffix = get_suffix(fname);
if(suffix == "cpp" || suffix == "cxx") {
return command("./__" + fname + "_exe < " + redirect + " > __" + fname + "_out_" + to_string(index));
}
else if(suffix == "java") {
return command("java " + fname.substr(0, fname.size() - 5) + " < " + redirect + " > __" + fname + "_out_" + to_string(index));
}
else {
cout << "undefined suffix: " << suffix << endl;
return -1;
}
return 0;
}
void main_() {
vector<string> input_fnames;
namespace fs = boost::filesystem;
const fs::path path("new_input");
BOOST_FOREACH(const fs::path& p,
make_pair(fs::directory_iterator(path), fs::directory_iterator())) {
if (!fs::is_directory(p)) {
auto name = p.filename().string();
if(name[0] == '.') { continue; }
input_fnames.push_back(path.string() + "/" + name);
}
}
string ac_code; cin >> ac_code;
vector<string> codes;
for(string s; cin >> s; codes.push_back(s));
cout << "Compiling " << ac_code << "(AC code)" << endl;
assert(0 == compile(ac_code));
for(auto && f: codes) {
cout << "Compiling " << f << endl;
assert(0 == compile(f));
}
rep(in_idx, input_fnames.size()) {
cout << "Runnning " << ac_code << "(AC code) with " << input_fnames[in_idx] << endl;
run_program(ac_code, input_fnames[in_idx], in_idx);
}
rep(code_idx, codes.size()) {
rep(in_idx, input_fnames.size()) {
cout << "Runnning " << codes[code_idx] << " with " << input_fnames[in_idx] << endl;
run_program(codes[code_idx], input_fnames[in_idx], in_idx);
}
}
vector<int> pass_count(codes.size());
map<int, double> input_success_rate; // input_fnames'index -> rate
rep(code_idx, codes.size()) {
rep(in_idx, input_fnames.size()) {
int s = 0 == command("diff __" + ac_code + "_out_" + to_string(in_idx) + " __" + codes[code_idx] + "_out_" + to_string(in_idx));
pass_count[code_idx] += s;
input_success_rate[in_idx] += (double)s / codes.size();
}
}
rep(i, codes.size()) {
cout << codes[i] << endl;
cout << "Passed " << pass_count[i] << " / " << input_fnames.size() << endl << endl;
}
cout << "Input success rate" << endl;
for(auto && e: input_success_rate) {
cout << input_fnames[e.first] << ": " << setprecision(10) << e.second * 100.0 << "%" << endl;
}
#define TRY try {
#define CATCH } catch(fs::filesystem_error& ex) { cout << ex.what() << endl; throw; }
// remove files
TRY fs::remove("__" + ac_code + "_exe"); CATCH
rep(i, input_fnames.size()) {
TRY fs::remove("__" + ac_code + "_out_" + to_string(i)); CATCH
}
rep(i, codes.size()) {
TRY fs::remove("__" + codes[i] + "_exe"); CATCH
rep(j, input_fnames.size()) {
TRY fs::remove("__" + codes[i] + "_out_" + to_string(j)); CATCH
}
}
}
moti