Submission #696058

#TimeUsernameProblemLanguageResultExecution timeMemory
696058Vu_CG_CoderTram (CEOI13_tram)C++14
0 / 100
1080 ms2228 KiB
/* [Author : Hoang Duy Vu] - THPT Chuyen Nguyen Du */ //#pragma GCC optimize(" unroll-loops") //#pragma gcc optimize("Ofast") //#pragma GCC optimization("Ofast") //#pragma optimize(Ofast) #include <bits/stdc++.h> #define All(x) (x).begin(),(x).end() #define ll long long #define C make_pair #define fi first #define se second #define two second.first #define thr second.second #define TASK "txt" using namespace std; template<typename T> bool maximize(T &res, const T &val) { if (res < val) { res = val; return true; } return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val) { res = val; return true; } return false; } typedef pair<ll,ll> ii; typedef pair<ll,ii> iii; const int LOG = 20; const int INF = 1e9 + 7; const ll LNF = 1e18 + 7; const int mod = 1e9 + 7; const int N = 30300; set <int> p; set <iii> t; int f[200100][2]; map <ii,ii> k; int n , m; iii find(int x , int y) { if (x == 0 && y == n + 1) return C(n*n + 1,C(1,0)); if (x == 0) { if (!f[y][0]) return C((y - 1)*(y - 1) + 1,C(1,0)); if (!f[y][1]) return C((y - 1)*(y - 1) + 1,C(1,1)); if (!f[1][0]) return C((y - 1)*(y - 1),C(1,0)); else return C((y - 1)*(y - 1),C(1,1)); } if (y == n + 1) { if (!f[x][0]) return C((n - x)*(n - x) + 1,C(n,0)); if (!f[x][1]) return C((n - x)*(n - x) + 1,C(n,1)); if (!f[n][0]) return C((n - x)*(n - x),C(n,0)); else return C((n - x)*(n - x),C(n,1)); } ll k = (x + y); ll z = k/2; iii res = C(0,C(0,0)); if (!f[z][0]) res = max(res,min(C(1ll*(z - x)*(z - x) + (f[x][0] == 0),C(z,0ll)),C(1ll*(y - z)*(y - z) + (f[y][0] == 0),C(z,0ll)))); if (!f[z][1]) res = max(res,min(C(1ll*(z - x)*(z - x) + (f[x][1] == 0),C(z,1ll)),C(1ll*(y - z)*(y - z) + (f[y][1] == 0),C(z,1ll)))); if (k&1) z = k/2 + 1; if (!f[z][0]) res = max(res,min(C(1ll*(z - x)*(z - x) + (f[x][0] == 0),C(z,0ll)),C(1ll*(y - z)*(y - z) + (f[y][0] == 0),C(z,0ll)))); if (!f[z][1]) res = max(res,min(C(1ll*(z - x)*(z - x) + (f[x][1] == 0),C(z,1ll)),C(1ll*(y - z)*(y - z) + (f[y][1] == 0),C(z,1ll)))); return res; } set <ii> a; ii T[N]; void input() { cin >> n >> m; } void solve() { a.insert(C(0,0)); a.insert(C(n + 1,0)); int cnt = 0; while (m--) { cnt++; char v; cin >> v; if (v == 'E') { iii res = C(0,C(0,0)); for (auto d = a.begin() ; d != a.end() ; d++) { auto k = ++d; d--; if (k == a.end()) break; // cout << (*d).fi << " " << (*k).fi << "\n"; res = max(res,find((*d).fi,(*k).fi)); } f[res.two][res.thr] = 1; cout << res.two << " " << res.thr + 1 << "\n"; T[cnt] = C(res.two,res.thr); a.insert(C(res.two,res.thr)); } else { int x; cin >> x; int X = T[x].fi; int Y = T[x].se; a.erase(C(X,Y)); f[X][Y] = 0; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); if(fopen(TASK".inp", "r")){ freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout); } int tk; tk = 1; //cin >> tk; while (tk--) { input(); solve(); } return 0; }

Compilation message (stderr)

tram.cpp: In function 'int main()':
tram.cpp:132:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  132 |     freopen(TASK".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tram.cpp:133:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  133 |     freopen(TASK".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...