Submission #1104123

#TimeUsernameProblemLanguageResultExecution timeMemory
1104123huyngodzzNaval battle (CEOI24_battle)C++14
46 / 100
273 ms29448 KiB
///huynhocute123/// #include<bits/stdc++.h> using namespace std; #define S second #define F first #define pii pair<int,int> #define piii pair<int,pair<int,int>> #define pb push_back #define pi M_PI #define FOR(i, a, b) for(int i = a; i <= b; ++i) #define REP(i, a, b) for(int i = b; i >= a; --i) #define ALL(v) v.begin(),v.end() #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin); #define out(name) if(fopen(name, "w")) freopen(name, "w", stdout); //random_device rd; //mt19937 rng(rd()); //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") //#define int long long const int maxN = 2 * 1e5 + 9 ; const int modd = 1e9 + 7; const int base = 2309; const int MAX = 1e9+9; void minimize(int &u, int v){ if(v < u) u = v; } void maximize(int &u, int v){ if(v > u) u = v; } int n, k, t, m, res, a[maxN], crash[maxN]; int l, r; bool vis[maxN]; vector<piii> e; struct node{ int x, y ,ct; char id; } ship[maxN]; void connect(int i ,int j){ int tmp = (abs(ship[i].x - ship[j].x) + abs(ship[i].y - ship[j].y))/2; // cout << tmp; if(ship[i].id == 'N'){ if(ship[j].id =='S'){ if(ship[i].y - ship[j].y == 2*tmp)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'W'){ if(ship[i].x + tmp ==ship[j].x && ship[i].y - tmp == ship[j].y)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'E'){ if(ship[i].x - tmp ==ship[j].x && ship[i].y - tmp == ship[j].y)e.pb({tmp, {i ,j}}); } return; } if(ship[i].id == 'S'){ if(ship[j].id =='N'){ if(-ship[i].y + ship[j].y == 2*tmp)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'W'){ if(ship[i].x + tmp ==ship[j].x && ship[i].y + tmp == ship[j].y)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'E'){ if(ship[i].x - tmp ==ship[j].x && ship[i].y + tmp == ship[j].y)e.pb({tmp, {i ,j}}); } return; } if(ship[i].id == 'W'){ if(ship[j].id =='E'){ if(ship[i].x -ship[j].x == 2*tmp)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'N'){ if(ship[i].x - tmp ==ship[j].x && ship[i].y + tmp == ship[j].y)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'S'){ if(ship[i].x - tmp ==ship[j].x && ship[i].y - tmp == ship[j].y)e.pb({tmp, {i ,j}}); } } if(ship[i].id == 'E'){ if(ship[j].id =='W'){ if(-ship[i].x +ship[j].x == 2*tmp)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'N'){ if(ship[i].x + tmp ==ship[j].x && ship[i].y + tmp == ship[j].y)e.pb({tmp, {i ,j}}); } if(ship[j].id == 'S'){ if(ship[i].x + tmp ==ship[j].x && ship[i].y - tmp == ship[j].y)e.pb({tmp, {i ,j}}); } } } void sub1(){ for(int i =1;i <= n ;i++){ for(int j = i + 1; j <= n; j++){ connect(i ,j); } } sort(ALL(e)); for(auto x : e){ int u = x.S.F, v= x.S.S, TIME = x.F; if(crash[u] == 0 && crash[v] == 0){ crash[u] = TIME; crash[v] = TIME; continue; } if(crash[u] == 0 && crash[v] == TIME){ crash[u] =TIME; } if(crash[v] == 0 && crash[u] == TIME){ crash[v] =TIME; } } for(int i = 1; i <= n ;i++)if(!crash[i])cout << i << '\n'; // for(auto x : e)cout << x.F << " " ; } void sub2(){ } void solve(){ cin >> n; for(int i =1;i <= n ;i++){ cin >> ship[i].x >> ship[i].y >> ship[i].id; ship[i].ct =i; } if(n <= 5009)sub1(); else sub2(); } signed main(){ // freopen("name.inp","r",stdin); // freopen("name.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(0); inp("task.inp"); t = 1; // cin >> t; while( t-- )solve(); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:134:5: note: in expansion of macro 'inp'
  134 |     inp("task.inp");
      |     ^~~
#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...