Submission #473124

# Submission time Handle Problem Language Result Execution time Memory
473124 2021-09-15T08:24:10 Z Mr_Ph ZigZag (COCI17_zigzag) C++14
80 / 80
89 ms 11332 KB
///made by : Mr_Ph :D
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
const double PI=acos(-1.0);
const ll mod=(ll)1e9+7;
//int dx[4] = {0, 0, 1, -1};
//int dy[4] = {1, -1, 0, 0};
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
///the end of the defines ;)
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<string>arr(n);
    ent(arr);
    sort(all(arr));
    map<char,deque<string>>mp;
    for(int i=0;i<n;i++)
        mp[arr[i][0]].push_back(arr[i]);
    for(int i=0;i<m;i++)
    {
        char e;
        cin>>e;
        cout<<mp[e][0]<<endl;
        string temp=mp[e][0];
        mp[e].pop_front();
        mp[e].push_back(temp);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    //freopen("window.in","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;//int st;
    //cin>>t;//cin>>st;
    while(t--)
        solve();
}

Compilation message

zigzag.cpp: In function 'void solve()':
zigzag.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
      |                              ~^~~~~~~~~~~
zigzag.cpp:28:5: note: in expansion of macro 'ent'
   28 |     ent(arr);
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 79 ms 11068 KB Output is correct
8 Correct 83 ms 11092 KB Output is correct
9 Correct 89 ms 11332 KB Output is correct
10 Correct 79 ms 11172 KB Output is correct