Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
LRU - Main
#include <bits/stdc++.h> using namespace std; #define RED "\033[1m\033[31m" #define GREEN "\033[1m\033[32m" #define WHITE "\033[1m\033[37m" extern void LRUCache(int); extern int GET(int); extern void SET(int,int); int main() { cout << WHITE; freopen("test50.txt", "r", stdin); clock_t start, end; start = clock(); bool flag = true; int t; cin >> t; cout << "TEST-CASES: " << t << "\n"; for(int test_case=1;test_case<=t;test_case++) { bool localFlag = true; int capacity; cin >> capacity; LRUCache(capacity); int queries; cin >> queries; while (queries--) { string q; cin >> q; if (q == "SET") { int key; cin >> key; int value; cin >> value; SET(key, value); } else { int key; cin >> key; int userAns = GET(key); int ans; cin >> ans; if(userAns != ans) { localFlag = false; flag = false; } } } if(localFlag) { cout << GREEN << "#" << test_case << " - 100\n"; } else { cout << RED << "#" << test_case << " - 0\n"; } } end = clock(); cout << "\n" << WHITE; if(flag) cout << "SCORE : 100\n"; else cout << "SCORE : 0\n"; double time_taken = double(end - start) / double(CLOCKS_PER_SEC); cout << "RUN_TIME : " << fixed << setprecision(6) << time_taken ; cout << " sec " << endl; if(time_taken > 3) cout << RED << "VERDICT : TIME_LIMIT_EXCEEDED\n"; else if(flag == false) cout << RED << "VERDIT : WRONG_ANSWER\n"; else cout << GREEN << "VERDICT : AC\n"; }
run
|
edit
|
history
|
help
0
sdefrgthyjukiujyhtg
said
MyList
maximum_frequent_sum
Program
Lex cpp
Count squares
CODE K
memcpy
Binary tree balanced or not