답안 #340243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340243 2020-12-27T10:42:24 Z beksultan04 움직이는 개미 (IZhO12_ants) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define ll long long
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 2e5+12,INF=1e9+7;

vector <pair<pii,int> > v[3];
pair <pii,int> ans[N];

bool comp(pair <pii,int> a,pair <pii,int> b){
    if (a.fr.sc == b.fr.sc){
        if (a.fr.fr==b.fr.fr)
            ret a.sc>b.sc;
        else
            ret a.fr.fr<b.fr.fr;
    }
    ret a.fr.sc<b.fr.sc;
}
bool cmp(pair <pii,int> a,pair <pii,int> b){
    if (a.fr.fr == b.fr.fr){
        if (a.fr.sc==b.fr.sc)
            ret a.sc>b.sc;
        else
            ret a.fr.sc<b.fr.sc;
    }
    ret a.fr.fr<b.fr.fr;
}
main(){
    int w,h,t,k,i,j;
    scan2(w,h)
    scan2(k,t)
    vector <int> dd,d;
    int tw = (t%(w*2));
    int th = (t%(h*2));
    for (i=1;i<=k;++i){
        int a,b,c;
        scan3(a,b,c)
        if (c%2){
            dd.pb(i);
            v[1].pb({{a,b},c});
        }
        else {
            d.pb(i);
            v[2].pb({{a,b},c});
        }
    }
    while (tw--){
        for (i=0;i<v[1].size();++i){
            if (v[1][i].sc == 1){
                v[1][i].fr.fr++;
                if (v[1][i].fr.fr == w){
                    v[1][i].sc = 3;
                }
            }
            else {
                v[1][i].fr.fr--;
                if (v[1][i].fr.fr == 0){
                    v[1][i].sc = 1;
                }
            }
        }
    }
    sort(all(v[1]),cmp);
    for (i=0;i<v[1].size();++i){
        ans[dd[i]] = {{v[1][i].fr.fr,v[1][i].fr.sc},v[1][i].sc};
    }
    while (th--){
        for (i=0;i<v[2].size();++i){
            if (v[2][i].sc == 2){
                v[2][i].fr.sc++;
                if (v[2][i].fr.sc == h){
                    v[2][i].sc = 4;
                }
            }
            else {
                v[2][i].fr.sc--;
                if (v[2][i].fr.sc == 0){
                    v[2][i].sc = 2;
                }
            }
        }
    }
    sort(all(v[2]),comp);
    for (i=0;i<v[2].size();++i){
        ans[d[i]] = {{v[2][i].fr.fr,v[2][i].fr.sc},v[2][i].sc};
    }
    for (i=1;i<=k;++i){
        cout <<ans[i].fr.fr<<" "<<ans[i].fr.sc<<" "<<ans[i].sc<<"\n";
    }
}

Compilation message

ants.cpp:42:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main(){
      |      ^
ants.cpp: In function 'int main()':
ants.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for (i=0;i<v[1].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:78:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for (i=0;i<v[1].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:82:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |         for (i=0;i<v[2].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:98:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |     for (i=0;i<v[2].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:43:19: warning: unused variable 'j' [-Wunused-variable]
   43 |     int w,h,t,k,i,j;
      |                   ^
ants.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
ants.cpp:44:5: note: in expansion of macro 'scan2'
   44 |     scan2(w,h)
      |     ^~~~~
ants.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
ants.cpp:45:5: note: in expansion of macro 'scan2'
   45 |     scan2(k,t)
      |     ^~~~~
ants.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 | #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~
ants.cpp:51:9: note: in expansion of macro 'scan3'
   51 |         scan3(a,b,c)
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -