File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,52 @@ int main()
45
45
delete[] x;
46
46
return 0 ;
47
47
}
48
+
49
+
50
+ // 4304381 Aug 17, 2013 7:46:43 PM fuwutu 254A - Cards with Numbers GNU C++0x Accepted 404 ms 6900 KB
51
+ #include < cstdio>
52
+ #include < vector>
53
+
54
+ using namespace std ;
55
+
56
+ int main ()
57
+ {
58
+ freopen (" input.txt" , " r" , stdin);
59
+ freopen (" output.txt" , " w" , stdout);
60
+
61
+ int n, a;
62
+ vector<int > index[5001 ];
63
+ scanf (" %d" , &n);
64
+ for (int i = 1 ; i <= n * 2 ; ++i)
65
+ {
66
+ scanf (" %d" , &a);
67
+ index[a].push_back (i);
68
+ }
69
+
70
+ bool possible = true ;
71
+ for (int i = 1 ; i < 5001 ; ++i)
72
+ {
73
+ if (index[i].size () % 2 == 1 )
74
+ {
75
+ possible = false ;
76
+ break ;
77
+ }
78
+ }
79
+
80
+ if (possible)
81
+ {
82
+ for (int i = 1 ; i < 5001 ; ++i)
83
+ {
84
+ for (size_t j = 0 ; j < index[i].size (); j += 2 )
85
+ {
86
+ printf (" %d %d\n " , index[i][j], index[i][j+1 ]);
87
+ }
88
+ }
89
+ }
90
+ else
91
+ {
92
+ printf (" -1\n " );
93
+ }
94
+
95
+ return 0 ;
96
+ }
You can’t perform that action at this time.
0 commit comments