Submission #1103683

#TimeUsernameProblemLanguageResultExecution timeMemory
1103683TVSownNaval battle (CEOI24_battle)C++17
46 / 100
256 ms27476 KiB
///***LTT***/// /// ->NHAT QUOC GIA<- /// #include<bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") //#define int long long #define endl "\n" #define F first #define S second #define pb push_back using namespace std; vector <int> lg2; //void MAKE_LOG_ARR(int n){ // lg2.resize(n + 3); // for (int i = 1;i <= n;++i){ // lg2[i] = __lg(i); // } //} const long long oo = 1e9+7; const int N = 2 * 1e5 + 10; int n; int x[N], y[N]; char type[N]; pair <int, pair <int ,int>> a[2500004]; int die[N]; long long giao(int a, int b){ if (type[a] == type[b]) return -1; if (type[a] > type[b])swap(a,b); if (type[a] == 'E' and type[b] == 'S'){ int deltax = x[b] - x[a]; int deltay = y[a] - y[b]; if (deltax > 0 and deltax == deltay) return deltax; else return -1; } if (type[a] == 'E' and type[b] == 'N'){ int deltax = x[b] - x[a]; int deltay = y[b] - y[a]; if (deltax > 0 and deltax == deltay) return deltax; else return -1; } if (type[a] == 'E' and type[b] == 'W'){ int deltax = x[b] - x[a]; deltax /= 2; if (deltax > 0 and y[b] == y[a]) return deltax; else return -1; } if (type[a] == 'N' and type[b] == 'S'){ int deltay = y[a] - y[b]; deltay /= 2; if (deltay > 0 and x[a] == x[b]) return deltay; else return -1; } if (type[a] == 'N' and type[b] == 'W'){ int deltay = y[a] - y[b]; int deltax = x[b] - x[a]; if (deltay > 0 and deltax == deltay) return deltax; else return -1; } if (type[a] == 'S' and type[b] == 'W'){ int deltay = y[b] - y[a]; int deltax = x[b] - x[a]; if (deltay > 0 and deltax == deltay) return deltax; else return -1; } } void solve(){ cin >> n; for (int i = 1;i <= n;++i){ cin >> x[i] >> y[i] >> type[i]; } assert(n <= 5000); int pt = 0; for (int i = 1;i <= n;++i){ for (int j = i + 1;j <= n;++j){ int z = giao(i,j); if (z != -1){ a[++pt] = {z,{i,j}}; } } } for (int i= 1;i <= n;++i) die[i] = oo + 100; sort(a + 1,a + pt + 1); for (int i = 1;i <= pt;++i){ int u = a[i].S.F; int v = a[i].S.S; int ti = a[i].F; if (die[u] < ti or die[v] < ti) continue; die[u] = ti; die[v] = ti; } bool found = false; for (int i = 1;i <= n;++i){ if (die[i] == oo + 100){ cout << i <<"\n"; found = true; } } // if (!found) cout << 0; return; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); if (fopen("ltt.inp", "r")){ freopen("ltt.inp", "r", stdin); freopen("ltt.out", "w", stdout); } // int t; // cin >> t; // while(t--){ solve(); // } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:86:10: warning: variable 'found' set but not used [-Wunused-but-set-variable]
   86 |     bool found = false;
      |          ^~~~~
Main.cpp: In function 'long long int giao(int, int)':
Main.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
Main.cpp: In function 'int main()':
Main.cpp:101:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |         freopen("ltt.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:102:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |         freopen("ltt.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...