답안 #340226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340226 2020-12-27T10:30:27 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,pii> > v[3];
pair <pii,int> ans[N];
main(){
    int w,h,t,k,i,j;
    scan2(w,h)
    scan2(k,t)
    vector <int> dd,d;
    int tw = t;
    int th = t;
    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,i}});
        }
        else {
            d.pb(i);
            v[2].pb({{a,b},{c,i}});
        }
    }
    while (tw--){
        for (i=0;i<v[1].size();++i){
            if (v[1][i].sc.fr == 1){
                v[1][i].fr.fr++;
                if (v[1][i].fr.fr == w){
                    v[1][i].sc.fr = 3;
                }
            }
            else {
                v[1][i].fr.fr--;
                if (v[1][i].fr.fr == 0){
                    v[1][i].sc.fr = 1;
                }
            }
        }
    }
    sort(all(v[1]));
    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.fr};
    }
    while (th--){
        for (i=0;i<v[2].size();++i){
            if (v[2][i].sc.fr == 2){
                v[2][i].fr.sc++;
                if (v[2][i].fr.sc == h){
                    v[2][i].sc.fr = 4;
                }
            }
            else {
                v[2][i].fr.sc--;
                if (v[2][i].fr.sc == 0){
                    v[2][i].sc.fr = 2;
                }
            }
        }
    }
    sort(all(v[2]));
    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.fr};
    }
    for (i=1;i<=k;++i){
        cout <<ans[i].fr.fr<<" "<<ans[i].fr.sc<<" "<<ans[i].sc<<"\n";
    }
}

Compilation message

ants.cpp:23:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main(){
      |      ^
ants.cpp: In function 'int main()':
ants.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (i=0;i<v[1].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:59:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (i=0;i<v[1].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:63:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for (i=0;i<v[2].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:79:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for (i=0;i<v[2].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:24:19: warning: unused variable 'j' [-Wunused-variable]
   24 |     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:25:5: note: in expansion of macro 'scan2'
   25 |     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:26:5: note: in expansion of macro 'scan2'
   26 |     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:32:9: note: in expansion of macro 'scan3'
   32 |         scan3(a,b,c)
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -