|
#include <bits/stdc++.h> |
|
#include <curl/curl.h> |
|
using namespace std; |
|
|
|
int main() { |
|
CURL *curl; |
|
CURLcode res; |
|
curl = curl_easy_init(); |
|
if(curl) { |
|
curl_easy_setopt(curl, CURLOPT_URL, "https://codeforces.com/api/problemset.problems"); |
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); |
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); |
|
res = curl_easy_perform(curl); |
|
if(res != CURLE_OK) { |
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", |
|
curl_easy_strerror(res)); |
|
} |
|
curl_easy_cleanup(curl); |
|
} |
|
} |
|
|
|
size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) |
|
{ |
|
((std::string*)userp)->append((char*)contents, size * nmemb); |
|
return size * nmemb; |
|
} |
|
|
|
|
|
class DeepReinforcementLearningAgent { |
|
public: |
|
void initialize() { |
|
|
|
} |
|
|
|
int getAction(std::string problem) { |
|
|
|
|
|
return action; |
|
} |
|
|
|
void update(double reward, std::string problem, int action) { |
|
|
|
|
|
} |
|
}; |
|
|
|
int main() { |
|
DeepReinforcementLearningAgent agent; |
|
agent.initialize(); |
|
|
|
CURL *curl; |
|
CURLcode res; |
|
std::string response; |
|
curl = curl_easy_init(); |
|
|
|
while (true) { |
|
curl_easy_setopt(curl, CURLOPT_URL, "https://codeforces.com/api/problemset.problems"); |
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); |
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); |
|
res = curl_easy_perform(curl); |
|
if(res != CURLE_OK) { |
|
|
|
} |
|
|
|
|
|
std::string problem = ... |
|
|
|
int action = agent.getAction(problem); |
|
std::string solution = getSolution(action); |
|
|
|
|
|
double reward; |
|
if (result == "Accepted") reward = 1; |
|
else if (result == "Compilation Error") reward = -0.5; |
|
else if (result == "Wrong Answer") reward = 0.1; |
|
else if (result == "Time Limit Exceeded") reward = 0.2; |
|
|
|
agent.update(reward, problem, action); |
|
|
|
if (result == "Accepted") std::cout << "Accepted" << '\n'; |
|
else if (result == "Compilation Error") std::cout << "Compilation Error" << '\n'; |
|
else if (result == "Wrong Answer") std::cout << "Wrong Answer" << '\n'; |
|
else std::cout << "Time Limit Exceeded" << '\n'; |
|
} |
|
} |