제출 #648805

#제출 시각아이디문제언어결과실행 시간메모리
648805YassineBenYounesArranging Shoes (IOI19_shoes)C++17
50 / 100
1092 ms3136 KiB
/* ID: Yassine BenYounes TASK: time LANG: C++ */ #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; /*#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pbds tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds;*/ ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) ll modd(ll x, ll n){while(x < 0){x += n;}return (x % n);} // modulo for negative numbers int dx[8] = {0, -1, 0, 1, 1, 1, -1, -1}; int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}; #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 2005; const ll mod = 1e9+7; const int inf = 1e9; long long count_swaps(std::vector<int> S){ int ans = 0; int n = S.size(); for(int i = 0; i < n;i+=2){ int j = i; while(j < n && S[i] != -S[j]){ j++; } ans += j-i-1; /*cout << i << " " << j << endl; for(int x = 0; x < n;x++){ cout << S[x] << " "; } cout << endl;*/ for(int x = j;x > i;x--){ S[x] = S[x-1]; } if(S[i] > 0)ans++; } return ans; } /* int main(){ //ofstream fout ("teamwork.out"); //ifstream fin ("teamwork.in"); init(); speed; cout << count_swaps({-2, 2, 2, -2, -2, 2}) << endl; }*/ /* NEVER GIVE UP! DOING SMTHNG IS BETTER THAN DOING NTHNG!!! */

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'void init()':
shoes.cpp:40:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
shoes.cpp:42:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 | freopen("output.txt", "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...